Handle IFileSystem rename.
This commit is contained in:
parent
7667eba34e
commit
d51dad9560
|
|
@ -5,7 +5,7 @@ using System;
|
|||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.FileSystems;
|
||||
using Microsoft.AspNet.FileProviders;
|
||||
using Microsoft.AspNet.Hosting;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.AspNet.Http.Interfaces;
|
||||
|
|
@ -73,18 +73,18 @@ namespace Microsoft.AspNet.Mvc
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the <see cref="IFileSystem"/> used to resolve paths.
|
||||
/// Gets or sets the <see cref="IFileProvider"/> used to resolve paths.
|
||||
/// </summary>
|
||||
public IFileSystem FileSystem { get; set; }
|
||||
public IFileProvider FileProvider { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override Task WriteFileAsync(HttpResponse response, CancellationToken cancellation)
|
||||
{
|
||||
var sendFile = response.HttpContext.GetFeature<IHttpSendFileFeature>();
|
||||
|
||||
var fileSystem = GetFileSystem(response.HttpContext.RequestServices);
|
||||
var fileProvider = GetFileProvider(response.HttpContext.RequestServices);
|
||||
|
||||
var filePath = ResolveFilePath(fileSystem);
|
||||
var filePath = ResolveFilePath(fileProvider);
|
||||
|
||||
if (sendFile != null)
|
||||
{
|
||||
|
|
@ -100,7 +100,7 @@ namespace Microsoft.AspNet.Mvc
|
|||
}
|
||||
}
|
||||
|
||||
internal string ResolveFilePath(IFileSystem fileSystem)
|
||||
internal string ResolveFilePath(IFileProvider fileProvider)
|
||||
{
|
||||
// Let the file system try to get the file and if it can't,
|
||||
// fallback to trying the path directly unless the path starts with '/'.
|
||||
|
|
@ -117,10 +117,10 @@ namespace Microsoft.AspNet.Mvc
|
|||
return path;
|
||||
}
|
||||
|
||||
var fileInfo = fileSystem.GetFileInfo(path);
|
||||
var fileInfo = fileProvider.GetFileInfo(path);
|
||||
if (fileInfo.Exists)
|
||||
{
|
||||
// The path is relative and IFileSystem found the file, so return the full
|
||||
// The path is relative and IFileProvider found the file, so return the full
|
||||
// path.
|
||||
return fileInfo.PhysicalPath;
|
||||
}
|
||||
|
|
@ -157,7 +157,7 @@ namespace Microsoft.AspNet.Mvc
|
|||
if (path.StartsWith("~\\", StringComparison.Ordinal))
|
||||
{
|
||||
// ~\ is not a valid virtual path, and we don't want to replace '\' with '/' as it
|
||||
// ofuscates the error, so just return the original path and throw at a later point
|
||||
// obfuscates the error, so just return the original path and throw at a later point
|
||||
// when we can't find the file.
|
||||
return path;
|
||||
}
|
||||
|
|
@ -195,19 +195,17 @@ namespace Microsoft.AspNet.Mvc
|
|||
path.StartsWith("\\\\", StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
private IFileSystem GetFileSystem(IServiceProvider requestServices)
|
||||
private IFileProvider GetFileProvider(IServiceProvider requestServices)
|
||||
{
|
||||
if (FileSystem != null)
|
||||
if (FileProvider != null)
|
||||
{
|
||||
return FileSystem;
|
||||
return FileProvider;
|
||||
}
|
||||
|
||||
// For right now until we can use IWebRootFileSystemProvider, see
|
||||
// https://github.com/aspnet/Hosting/issues/86 for details.
|
||||
var hostingEnvironment = requestServices.GetService<IHostingEnvironment>();
|
||||
FileSystem = new PhysicalFileSystem(hostingEnvironment.WebRoot);
|
||||
FileProvider = hostingEnvironment.WebRootFileProvider;
|
||||
|
||||
return FileSystem;
|
||||
return FileProvider;
|
||||
}
|
||||
|
||||
private static async Task CopyStreamToResponse(
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
"warningsAsErrors": true
|
||||
},
|
||||
"dependencies": {
|
||||
"Microsoft.AspNet.FileSystems": "1.0.0-*",
|
||||
"Microsoft.AspNet.FileProviders": "1.0.0-*",
|
||||
"Microsoft.AspNet.Hosting": "1.0.0-*",
|
||||
"Microsoft.AspNet.Http.Extensions": "1.0.0-*",
|
||||
"Microsoft.AspNet.Mvc.Common": { "version": "6.0.0-*", "type": "build" },
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Microsoft.AspNet.FileSystems;
|
||||
using Microsoft.AspNet.FileProviders;
|
||||
using Microsoft.AspNet.Razor;
|
||||
using Microsoft.AspNet.Razor.Generator.Compiler;
|
||||
using Microsoft.AspNet.Razor.Parser;
|
||||
|
|
@ -20,21 +20,21 @@ namespace Microsoft.AspNet.Mvc.Razor.Directives
|
|||
{
|
||||
private readonly Dictionary<string, CodeTree> _parsedCodeTrees;
|
||||
private readonly MvcRazorHost _razorHost;
|
||||
private readonly IFileSystem _fileSystem;
|
||||
private readonly IFileProvider _fileProvider;
|
||||
private readonly IReadOnlyList<Chunk> _defaultInheritedChunks;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of <see cref="ChunkInheritanceUtility"/>.
|
||||
/// </summary>
|
||||
/// <param name="razorHost">The <see cref="MvcRazorHost"/> used to parse _ViewStart pages.</param>
|
||||
/// <param name="fileSystem">The filesystem that represents the application.</param>
|
||||
/// <param name="fileProvider">The fileProvider that represents the application.</param>
|
||||
/// <param name="defaultInheritedChunks">Sequence of <see cref="Chunk"/>s inherited by default.</param>
|
||||
public ChunkInheritanceUtility([NotNull] MvcRazorHost razorHost,
|
||||
[NotNull] IFileSystem fileSystem,
|
||||
[NotNull] IFileProvider fileProvider,
|
||||
[NotNull] IReadOnlyList<Chunk> defaultInheritedChunks)
|
||||
{
|
||||
_razorHost = razorHost;
|
||||
_fileSystem = fileSystem;
|
||||
_fileProvider = fileProvider;
|
||||
_defaultInheritedChunks = defaultInheritedChunks;
|
||||
_parsedCodeTrees = new Dictionary<string, CodeTree>(StringComparer.Ordinal);
|
||||
}
|
||||
|
|
@ -42,7 +42,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Directives
|
|||
/// <summary>
|
||||
/// Gets an ordered <see cref="IReadOnlyList{T}"/> of parsed <see cref="CodeTree"/> for each _ViewStart that
|
||||
/// is applicable to the page located at <paramref name="pagePath"/>. The list is ordered so that the
|
||||
/// <see cref="CodeTree"/> for the _ViewStart closest to the <paramref name="pagePath"/> in the filesystem
|
||||
/// <see cref="CodeTree"/> for the _ViewStart closest to the <paramref name="pagePath"/> in the fileProvider
|
||||
/// appears first.
|
||||
/// </summary>
|
||||
/// <param name="pagePath">The path of the page to locate inherited chunks for.</param>
|
||||
|
|
@ -62,7 +62,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Directives
|
|||
}
|
||||
else
|
||||
{
|
||||
var fileInfo = _fileSystem.GetFileInfo(viewStartPath);
|
||||
var fileInfo = _fileProvider.GetFileInfo(viewStartPath);
|
||||
if (fileInfo.Exists)
|
||||
{
|
||||
// viewStartPath contains the app-relative path of the ViewStart.
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Microsoft.AspNet.FileSystems;
|
||||
using Microsoft.AspNet.FileProviders;
|
||||
using Microsoft.AspNet.Mvc.Razor.Directives;
|
||||
using Microsoft.AspNet.Razor;
|
||||
using Microsoft.AspNet.Razor.Generator;
|
||||
|
|
@ -31,7 +31,7 @@ namespace Microsoft.AspNet.Mvc.Razor
|
|||
new InjectChunk("Microsoft.AspNet.Mvc.IUrlHelper", "Url"),
|
||||
};
|
||||
|
||||
private readonly IFileSystem _fileSystem;
|
||||
private readonly IFileProvider _fileProvider;
|
||||
|
||||
// CodeGenerationContext.DefaultBaseClass is set to MyBaseType<dynamic>.
|
||||
// This field holds the type name without the generic decoration (MyBaseType)
|
||||
|
|
@ -45,18 +45,18 @@ namespace Microsoft.AspNet.Mvc.Razor
|
|||
/// </summary>
|
||||
/// <param name="root">The path to the application base.</param>
|
||||
public MvcRazorHost(string root) :
|
||||
this(new PhysicalFileSystem(root))
|
||||
this(new PhysicalFileProvider(root))
|
||||
{
|
||||
}
|
||||
#endif
|
||||
/// <summary>
|
||||
/// Initializes a new instance of <see cref="MvcRazorHost"/> using the specified <paramref name="fileSystem"/>.
|
||||
/// Initializes a new instance of <see cref="MvcRazorHost"/> using the specified <paramref name="fileProvider"/>.
|
||||
/// </summary>
|
||||
/// <param name="fileSystem">A <see cref="IFileSystem"/> rooted at the application base path.</param>
|
||||
public MvcRazorHost(IFileSystem fileSystem)
|
||||
/// <param name="fileProvider">A <see cref="IFileProvider"/> rooted at the application base path.</param>
|
||||
public MvcRazorHost(IFileProvider fileProvider)
|
||||
: base(new CSharpRazorCodeLanguage())
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
_fileProvider = fileProvider;
|
||||
_baseType = BaseType;
|
||||
|
||||
TagHelperDescriptorResolver = new TagHelperDescriptorResolver();
|
||||
|
|
@ -164,7 +164,7 @@ namespace Microsoft.AspNet.Mvc.Razor
|
|||
if (_chunkInheritanceUtility == null)
|
||||
{
|
||||
// This needs to be lazily evaluated to support DefaultInheritedChunks being virtual.
|
||||
_chunkInheritanceUtility = new ChunkInheritanceUtility(this, _fileSystem, DefaultInheritedChunks);
|
||||
_chunkInheritanceUtility = new ChunkInheritanceUtility(this, _fileProvider, DefaultInheritedChunks);
|
||||
}
|
||||
|
||||
return _chunkInheritanceUtility;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
"warningsAsErrors": true
|
||||
},
|
||||
"dependencies": {
|
||||
"Microsoft.AspNet.FileSystems": "1.0.0-*",
|
||||
"Microsoft.AspNet.FileProviders": "1.0.0-*",
|
||||
"Microsoft.AspNet.Mvc.Common": { "version": "6.0.0-*", "type": "build" },
|
||||
"Microsoft.AspNet.Razor.Runtime": "4.0.0-*"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Microsoft.AspNet.FileSystems;
|
||||
using Microsoft.AspNet.FileProviders;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.Razor
|
||||
{
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ using System.Collections.Concurrent;
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Microsoft.AspNet.FileSystems;
|
||||
using Microsoft.AspNet.FileProviders;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.Razor
|
||||
{
|
||||
|
|
@ -14,7 +14,7 @@ namespace Microsoft.AspNet.Mvc.Razor
|
|||
public class CompilerCache : ICompilerCache
|
||||
{
|
||||
private readonly ConcurrentDictionary<string, CompilerCacheEntry> _cache;
|
||||
private readonly IFileSystem _fileSystem;
|
||||
private readonly IFileProvider _fileProvider;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of <see cref="CompilerCache"/> populated with precompiled views
|
||||
|
|
@ -24,18 +24,18 @@ namespace Microsoft.AspNet.Mvc.Razor
|
|||
/// An <see cref="IAssemblyProvider"/> representing the assemblies
|
||||
/// used to search for pre-compiled views.
|
||||
/// </param>
|
||||
/// <param name="fileSystem">An <see cref="IRazorFileSystemCache"/> instance that represents the application's
|
||||
/// <param name="fileProvider">An <see cref="IRazorFileProviderCache"/> instance that represents the application's
|
||||
/// file system.
|
||||
/// </param>
|
||||
public CompilerCache(IAssemblyProvider provider, IRazorFileSystemCache fileSystem)
|
||||
: this(GetFileInfos(provider.CandidateAssemblies), fileSystem)
|
||||
public CompilerCache(IAssemblyProvider provider, IRazorFileProviderCache fileProvider)
|
||||
: this(GetFileInfos(provider.CandidateAssemblies), fileProvider)
|
||||
{
|
||||
}
|
||||
|
||||
// Internal for unit testing
|
||||
internal CompilerCache(IEnumerable<RazorFileInfoCollection> viewCollections, IFileSystem fileSystem)
|
||||
internal CompilerCache(IEnumerable<RazorFileInfoCollection> viewCollections, IFileProvider fileProvider)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
_fileProvider = fileProvider;
|
||||
_cache = new ConcurrentDictionary<string, CompilerCacheEntry>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
foreach (var viewCollection in viewCollections)
|
||||
|
|
@ -184,7 +184,7 @@ namespace Microsoft.AspNet.Mvc.Razor
|
|||
var viewStartLocations = ViewStartUtility.GetViewStartLocations(relativePath);
|
||||
foreach (var viewStartLocation in viewStartLocations)
|
||||
{
|
||||
var viewStartFileInfo = _fileSystem.GetFileInfo(viewStartLocation);
|
||||
var viewStartFileInfo = _fileProvider.GetFileInfo(viewStartLocation);
|
||||
if (viewStartFileInfo.Exists)
|
||||
{
|
||||
var relativeFileInfo = new RelativeFileInfo(viewStartFileInfo, viewStartLocation);
|
||||
|
|
|
|||
|
|
@ -3,31 +3,31 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using Microsoft.AspNet.FileSystems;
|
||||
using Microsoft.AspNet.FileProviders;
|
||||
using Microsoft.Framework.Expiration.Interfaces;
|
||||
using Microsoft.Framework.OptionsModel;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.Razor
|
||||
{
|
||||
/// <summary>
|
||||
/// Default implementation for the <see cref="IRazorFileSystemCache"/> interface that caches
|
||||
/// the results of <see cref="RazorViewEngineOptions.FileSystem"/>.
|
||||
/// Default implementation for the <see cref="IRazorFileProviderCache"/> interface that caches
|
||||
/// the results of <see cref="RazorViewEngineOptions.FileProvider"/>.
|
||||
/// </summary>
|
||||
public class DefaultRazorFileSystemCache : IRazorFileSystemCache
|
||||
public class DefaultRazorFileProviderCache : IRazorFileProviderCache
|
||||
{
|
||||
private readonly ConcurrentDictionary<string, ExpiringFileInfo> _fileInfoCache =
|
||||
new ConcurrentDictionary<string, ExpiringFileInfo>(StringComparer.Ordinal);
|
||||
|
||||
private readonly IFileSystem _fileSystem;
|
||||
private readonly IFileProvider _fileProvider;
|
||||
private readonly TimeSpan _offset;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of <see cref="DefaultRazorFileSystemCache"/>.
|
||||
/// Initializes a new instance of <see cref="DefaultRazorFileProviderCache"/>.
|
||||
/// </summary>
|
||||
/// <param name="optionsAccessor">Accessor to <see cref="RazorViewEngineOptions"/>.</param>
|
||||
public DefaultRazorFileSystemCache(IOptions<RazorViewEngineOptions> optionsAccessor)
|
||||
public DefaultRazorFileProviderCache(IOptions<RazorViewEngineOptions> optionsAccessor)
|
||||
{
|
||||
_fileSystem = optionsAccessor.Options.FileSystem;
|
||||
_fileProvider = optionsAccessor.Options.FileProvider;
|
||||
_offset = optionsAccessor.Options.ExpirationBeforeCheckingFilesOnDisk;
|
||||
}
|
||||
|
||||
|
|
@ -42,7 +42,7 @@ namespace Microsoft.AspNet.Mvc.Razor
|
|||
/// <inheritdoc />
|
||||
public IDirectoryContents GetDirectoryContents(string subpath)
|
||||
{
|
||||
return _fileSystem.GetDirectoryContents(subpath);
|
||||
return _fileProvider.GetDirectoryContents(subpath);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
|
@ -58,7 +58,7 @@ namespace Microsoft.AspNet.Mvc.Razor
|
|||
}
|
||||
else
|
||||
{
|
||||
var fileInfo = _fileSystem.GetFileInfo(subpath);
|
||||
var fileInfo = _fileProvider.GetFileInfo(subpath);
|
||||
|
||||
expiringFileInfo = new ExpiringFileInfo()
|
||||
{
|
||||
|
|
@ -75,7 +75,7 @@ namespace Microsoft.AspNet.Mvc.Razor
|
|||
/// <inheritdoc />
|
||||
public IExpirationTrigger Watch(string filter)
|
||||
{
|
||||
return _fileSystem.Watch(filter);
|
||||
return _fileProvider.Watch(filter);
|
||||
}
|
||||
|
||||
private class ExpiringFileInfo
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using Microsoft.AspNet.FileSystems;
|
||||
using Microsoft.AspNet.FileProviders;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.Razor
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using Microsoft.AspNet.FileSystems;
|
||||
using Microsoft.AspNet.FileProviders;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.Razor
|
||||
{
|
||||
/// <summary>
|
||||
/// An <see cref="IFileSystem"/> that caches the results of <see cref="IFileSystem.GetFileInfo(string)"/> for a
|
||||
/// An <see cref="IFileProvider"/> that caches the results of <see cref="IFileProvider.GetFileInfo(string)"/> for a
|
||||
/// duration specified by <see cref="RazorViewEngineOptions.ExpirationBeforeCheckingFilesOnDisk"/>.
|
||||
/// </summary>
|
||||
public interface IRazorFileSystemCache : IFileSystem
|
||||
public interface IRazorFileProviderCache : IFileProvider
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -10,7 +10,7 @@ using System.Linq;
|
|||
using System.Reflection;
|
||||
using System.Reflection.PortableExecutable;
|
||||
using System.Runtime.InteropServices;
|
||||
using Microsoft.AspNet.FileSystems;
|
||||
using Microsoft.AspNet.FileProviders;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.CSharp;
|
||||
using Microsoft.CodeAnalysis.Emit;
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNet.FileSystems;
|
||||
using Microsoft.AspNet.FileProviders;
|
||||
using Microsoft.AspNet.Mvc.Razor.OptionDescriptors;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.Razor
|
||||
|
|
@ -14,12 +14,12 @@ namespace Microsoft.AspNet.Mvc.Razor
|
|||
public class RazorViewEngineOptions
|
||||
{
|
||||
private TimeSpan _expirationBeforeCheckingFilesOnDisk = TimeSpan.FromSeconds(2);
|
||||
private IFileSystem _fileSystem;
|
||||
private IFileProvider _fileProvider;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the <see cref="TimeSpan"/> that specifies the duration for which results of
|
||||
/// <see cref="FileSystem"/> are cached by <see cref="DefaultRazorFileSystemCache"/>.
|
||||
/// <see cref="DefaultRazorFileSystemCache"/> is used to query for file changes during Razor compilation.
|
||||
/// <see cref="FileProvider"/> are cached by <see cref="DefaultRazorFileProviderCache"/>.
|
||||
/// <see cref="DefaultRazorFileProviderCache"/> is used to query for file changes during Razor compilation.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <see cref="TimeSpan"/> of <see cref="TimeSpan.Zero"/> or less, means no caching.
|
||||
|
|
@ -53,16 +53,16 @@ namespace Microsoft.AspNet.Mvc.Razor
|
|||
= new List<ViewLocationExpanderDescriptor>();
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the <see cref="IFileSystem" /> used by <see cref="RazorViewEngine"/> to locate Razor files on
|
||||
/// Gets or sets the <see cref="IFileProvider" /> used by <see cref="RazorViewEngine"/> to locate Razor files on
|
||||
/// disk.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// At startup, this is initialized to an instance of <see cref="PhysicalFileSystem"/> that is rooted at the
|
||||
/// At startup, this is initialized to an instance of <see cref="PhysicalFileProvider"/> that is rooted at the
|
||||
/// application root.
|
||||
/// </remarks>
|
||||
public IFileSystem FileSystem
|
||||
public IFileProvider FileProvider
|
||||
{
|
||||
get { return _fileSystem; }
|
||||
get { return _fileProvider; }
|
||||
|
||||
set
|
||||
{
|
||||
|
|
@ -71,7 +71,7 @@ namespace Microsoft.AspNet.Mvc.Razor
|
|||
throw new ArgumentNullException(nameof(value));
|
||||
}
|
||||
|
||||
_fileSystem = value;
|
||||
_fileProvider = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ using System.Collections.Generic;
|
|||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.FileSystems;
|
||||
using Microsoft.AspNet.FileProviders;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.Framework.Cache.Memory;
|
||||
using Microsoft.Framework.DependencyInjection;
|
||||
|
|
@ -19,7 +19,7 @@ namespace Microsoft.AspNet.Mvc.Razor
|
|||
public class RazorPreCompiler
|
||||
{
|
||||
private readonly IServiceProvider _serviceProvider;
|
||||
private readonly IFileSystem _fileSystem;
|
||||
private readonly IFileProvider _fileProvider;
|
||||
|
||||
public RazorPreCompiler([NotNull] IServiceProvider designTimeServiceProvider,
|
||||
[NotNull] IMemoryCache precompilationCache,
|
||||
|
|
@ -37,7 +37,7 @@ namespace Microsoft.AspNet.Mvc.Razor
|
|||
[NotNull] CompilationSettings compilationSettings)
|
||||
{
|
||||
_serviceProvider = designTimeServiceProvider;
|
||||
_fileSystem = optionsAccessor.Options.FileSystem;
|
||||
_fileProvider = optionsAccessor.Options.FileProvider;
|
||||
CompilationSettings = compilationSettings;
|
||||
PreCompilationCache = precompilationCache;
|
||||
}
|
||||
|
|
@ -120,10 +120,10 @@ namespace Microsoft.AspNet.Mvc.Razor
|
|||
|
||||
if (entry != null)
|
||||
{
|
||||
cacheSetContext.AddExpirationTrigger(_fileSystem.Watch(fileInfo.RelativePath));
|
||||
cacheSetContext.AddExpirationTrigger(_fileProvider.Watch(fileInfo.RelativePath));
|
||||
foreach (var viewStartPath in ViewStartUtility.GetViewStartLocations(fileInfo.RelativePath))
|
||||
{
|
||||
cacheSetContext.AddExpirationTrigger(_fileSystem.Watch(viewStartPath));
|
||||
cacheSetContext.AddExpirationTrigger(_fileProvider.Watch(viewStartPath));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -132,7 +132,7 @@ namespace Microsoft.AspNet.Mvc.Razor
|
|||
|
||||
private void GetFileInfosRecursive(string root, List<RelativeFileInfo> razorFiles)
|
||||
{
|
||||
var fileInfos = _fileSystem.GetDirectoryContents(root);
|
||||
var fileInfos = _fileProvider.GetDirectoryContents(root);
|
||||
|
||||
foreach (var fileInfo in fileInfos)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using Microsoft.AspNet.FileSystems;
|
||||
using Microsoft.AspNet.FileProviders;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.Razor
|
||||
{
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Security.Cryptography;
|
||||
using Microsoft.AspNet.FileSystems;
|
||||
using Microsoft.AspNet.FileProviders;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.Razor
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using Microsoft.AspNet.FileSystems;
|
||||
using Microsoft.AspNet.FileProviders;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.AspNet.PageExecutionInstrumentation;
|
||||
using Microsoft.Framework.DependencyInjection;
|
||||
|
|
@ -17,19 +17,19 @@ namespace Microsoft.AspNet.Mvc.Razor
|
|||
{
|
||||
private readonly ITypeActivator _activator;
|
||||
private readonly IServiceProvider _serviceProvider;
|
||||
private readonly IRazorFileSystemCache _fileSystemCache;
|
||||
private readonly IRazorFileProviderCache _fileProviderCache;
|
||||
private readonly ICompilerCache _compilerCache;
|
||||
private IRazorCompilationService _razorcompilationService;
|
||||
|
||||
public VirtualPathRazorPageFactory(ITypeActivator typeActivator,
|
||||
IServiceProvider serviceProvider,
|
||||
ICompilerCache compilerCache,
|
||||
IRazorFileSystemCache fileSystemCache)
|
||||
IRazorFileProviderCache fileProviderCache)
|
||||
{
|
||||
_activator = typeActivator;
|
||||
_serviceProvider = serviceProvider;
|
||||
_compilerCache = compilerCache;
|
||||
_fileSystemCache = fileSystemCache;
|
||||
_fileProviderCache = fileProviderCache;
|
||||
}
|
||||
|
||||
private IRazorCompilationService RazorCompilationService
|
||||
|
|
@ -40,7 +40,7 @@ namespace Microsoft.AspNet.Mvc.Razor
|
|||
{
|
||||
// it is ok to use the cached service provider because both this, and the
|
||||
// resolved service are in a lifetime of Scoped.
|
||||
// We don't want to get it upgront because it will force Roslyn to load.
|
||||
// We don't want to get it upfront because it will force Roslyn to load.
|
||||
_razorcompilationService = _serviceProvider.GetRequiredService<IRazorCompilationService>();
|
||||
}
|
||||
|
||||
|
|
@ -53,11 +53,11 @@ namespace Microsoft.AspNet.Mvc.Razor
|
|||
{
|
||||
if (relativePath.StartsWith("~/", StringComparison.Ordinal))
|
||||
{
|
||||
// For tilde slash paths, drop the leading ~ to make it work with the underlying IFileSystem.
|
||||
// For tilde slash paths, drop the leading ~ to make it work with the underlying IFileProvider.
|
||||
relativePath = relativePath.Substring(1);
|
||||
}
|
||||
|
||||
var fileInfo = _fileSystemCache.GetFileInfo(relativePath);
|
||||
var fileInfo = _fileProviderCache.GetFileInfo(relativePath);
|
||||
|
||||
if (fileInfo.Exists)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -102,13 +102,13 @@ namespace Microsoft.AspNet.Mvc
|
|||
yield return describe.Transient<IViewLocationExpanderProvider, DefaultViewLocationExpanderProvider>();
|
||||
// Caches view locations that are valid for the lifetime of the application.
|
||||
yield return describe.Singleton<IViewLocationCache, DefaultViewLocationCache>();
|
||||
yield return describe.Singleton<IRazorFileSystemCache, DefaultRazorFileSystemCache>();
|
||||
yield return describe.Singleton<IRazorFileProviderCache, DefaultRazorFileProviderCache>();
|
||||
|
||||
// The host is designed to be discarded after consumption and is very inexpensive to initialize.
|
||||
yield return describe.Transient<IMvcRazorHost>(serviceProvider =>
|
||||
{
|
||||
var cachedFileSystem = serviceProvider.GetRequiredService<IRazorFileSystemCache>();
|
||||
return new MvcRazorHost(cachedFileSystem);
|
||||
var cachedFileProvider = serviceProvider.GetRequiredService<IRazorFileProviderCache>();
|
||||
return new MvcRazorHost(cachedFileProvider);
|
||||
});
|
||||
|
||||
// Caches compilation artifacts across the lifetime of the application.
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using Microsoft.AspNet.FileSystems;
|
||||
using Microsoft.AspNet.FileProviders;
|
||||
using Microsoft.AspNet.Mvc.Razor;
|
||||
using Microsoft.Framework.OptionsModel;
|
||||
using Microsoft.Framework.Runtime;
|
||||
|
|
@ -26,7 +26,7 @@ namespace Microsoft.AspNet.Mvc
|
|||
private static void ConfigureRazor(RazorViewEngineOptions razorOptions,
|
||||
IApplicationEnvironment applicationEnvironment)
|
||||
{
|
||||
razorOptions.FileSystem = new PhysicalFileSystem(applicationEnvironment.ApplicationBasePath);
|
||||
razorOptions.FileProvider = new PhysicalFileProvider(applicationEnvironment.ApplicationBasePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.FileSystems;
|
||||
using Microsoft.AspNet.FileProviders;
|
||||
using Microsoft.AspNet.Hosting;
|
||||
using Microsoft.AspNet.Http.Core;
|
||||
using Microsoft.AspNet.Http.Interfaces;
|
||||
|
|
@ -37,7 +37,7 @@ namespace Microsoft.AspNet.Mvc
|
|||
|
||||
var result = new FilePathResult(path, "text/plain")
|
||||
{
|
||||
FileSystem = new PhysicalFileSystem(Path.GetFullPath(".")),
|
||||
FileProvider = new PhysicalFileProvider(Path.GetFullPath(".")),
|
||||
};
|
||||
|
||||
var httpContext = new DefaultHttpContext();
|
||||
|
|
@ -56,15 +56,15 @@ namespace Microsoft.AspNet.Mvc
|
|||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteResultAsync_FallsBackToThePhysicalFileSystem_IfNoFileSystemIsPresent()
|
||||
public async Task ExecuteResultAsync_FallsBackToThePhysicalFileProvider_IfNoFileProviderIsPresent()
|
||||
{
|
||||
// Arrange
|
||||
var path = Path.Combine("TestFiles", "FilePathResultTestFile.txt");
|
||||
var result = new FilePathResult(path, "text/plain");
|
||||
|
||||
var appEnvironment = new Mock<IHostingEnvironment>();
|
||||
appEnvironment.Setup(app => app.WebRoot)
|
||||
.Returns(Directory.GetCurrentDirectory());
|
||||
appEnvironment.Setup(app => app.WebRootFileProvider)
|
||||
.Returns(new PhysicalFileProvider(Directory.GetCurrentDirectory()));
|
||||
|
||||
var httpContext = new DefaultHttpContext();
|
||||
httpContext.Response.Body = new MemoryStream();
|
||||
|
|
@ -92,7 +92,7 @@ namespace Microsoft.AspNet.Mvc
|
|||
|
||||
var result = new FilePathResult(path, "text/plain")
|
||||
{
|
||||
FileSystem = new PhysicalFileSystem(Path.GetFullPath(".")),
|
||||
FileProvider = new PhysicalFileProvider(Path.GetFullPath(".")),
|
||||
};
|
||||
|
||||
var sendFileMock = new Mock<IHttpSendFileFeature>();
|
||||
|
|
@ -122,10 +122,10 @@ namespace Microsoft.AspNet.Mvc
|
|||
// forward slashes.
|
||||
path = path.Replace('/', '\\');
|
||||
|
||||
// Point the FileSystemRoot to a subfolder
|
||||
// Point the FileProviderRoot to a subfolder
|
||||
var result = new FilePathResult(path, "text/plain")
|
||||
{
|
||||
FileSystem = new PhysicalFileSystem(Path.GetFullPath("Utils")),
|
||||
FileProvider = new PhysicalFileProvider(Path.GetFullPath("Utils")),
|
||||
};
|
||||
|
||||
var httpContext = new DefaultHttpContext();
|
||||
|
|
@ -151,10 +151,10 @@ namespace Microsoft.AspNet.Mvc
|
|||
var path = Path.GetFullPath(Path.Combine(".", "TestFiles", "FilePathResultTestFile.txt"));
|
||||
path = path.Replace(@"\", "/");
|
||||
|
||||
// Point the FileSystemRoot to a subfolder
|
||||
// Point the FileProviderRoot to a subfolder
|
||||
var result = new FilePathResult(path, "text/plain")
|
||||
{
|
||||
FileSystem = new PhysicalFileSystem(Path.GetFullPath("Utils")),
|
||||
FileProvider = new PhysicalFileProvider(Path.GetFullPath("Utils")),
|
||||
};
|
||||
|
||||
var httpContext = new DefaultHttpContext();
|
||||
|
|
@ -203,15 +203,15 @@ namespace Microsoft.AspNet.Mvc
|
|||
public void GetFilePath_Resolves_RelativePaths(string path, string relativePathToFile)
|
||||
{
|
||||
// Arrange
|
||||
var fileSystem = new PhysicalFileSystem(Path.GetFullPath("./TestFiles"));
|
||||
var fileProvider = new PhysicalFileProvider(Path.GetFullPath("./TestFiles"));
|
||||
var expectedPath = Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(), relativePathToFile));
|
||||
var filePathResult = new FilePathResult(path, "text/plain")
|
||||
{
|
||||
FileSystem = fileSystem,
|
||||
FileProvider = fileProvider,
|
||||
};
|
||||
|
||||
// Act
|
||||
var result = filePathResult.ResolveFilePath(fileSystem);
|
||||
var result = filePathResult.ResolveFilePath(fileProvider);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(expectedPath, result);
|
||||
|
|
@ -224,15 +224,15 @@ namespace Microsoft.AspNet.Mvc
|
|||
public void GetFilePath_FailsToResolve_InvalidVirtualPaths(string path, string relativePathToFile)
|
||||
{
|
||||
// Arrange
|
||||
var fileSystem = new PhysicalFileSystem(Path.GetFullPath("./TestFiles"));
|
||||
var fileProvider = new PhysicalFileProvider(Path.GetFullPath("./TestFiles"));
|
||||
var expectedPath = Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(), relativePathToFile));
|
||||
var filePathResult = new FilePathResult(path, "text/plain")
|
||||
{
|
||||
FileSystem = fileSystem,
|
||||
FileProvider = fileProvider,
|
||||
};
|
||||
|
||||
// Act
|
||||
var ex = Assert.Throws<FileNotFoundException>(() => filePathResult.ResolveFilePath(fileSystem));
|
||||
var ex = Assert.Throws<FileNotFoundException>(() => filePathResult.ResolveFilePath(fileProvider));
|
||||
|
||||
// Assert
|
||||
Assert.Equal("Could not find file: " + path, ex.Message);
|
||||
|
|
@ -271,18 +271,18 @@ namespace Microsoft.AspNet.Mvc
|
|||
{
|
||||
// Arrange
|
||||
|
||||
// Point the IFileSystem root to a different subfolder
|
||||
var fileSystem = new PhysicalFileSystem(Path.GetFullPath("./Utils"));
|
||||
// Point the IFileProvider root to a different subfolder
|
||||
var fileProvider = new PhysicalFileProvider(Path.GetFullPath("./Utils"));
|
||||
var filePathResult = new FilePathResult(path, "text/plain")
|
||||
{
|
||||
FileSystem = fileSystem,
|
||||
FileProvider = fileProvider,
|
||||
};
|
||||
|
||||
var expectedFileName = path.TrimStart('~').Replace('\\', '/');
|
||||
var expectedMessage = "Could not find file: " + expectedFileName;
|
||||
|
||||
// Act
|
||||
var ex = Assert.Throws<FileNotFoundException>(() => filePathResult.ResolveFilePath(fileSystem));
|
||||
var ex = Assert.Throws<FileNotFoundException>(() => filePathResult.ResolveFilePath(fileProvider));
|
||||
|
||||
// Assert
|
||||
Assert.Equal(expectedMessage, ex.Message);
|
||||
|
|
@ -322,7 +322,7 @@ namespace Microsoft.AspNet.Mvc
|
|||
// Arrange
|
||||
var fileResult = new FilePathResult(path, "text/plain")
|
||||
{
|
||||
FileSystem = Mock.Of<IFileSystem>(),
|
||||
FileProvider = Mock.Of<IFileProvider>(),
|
||||
};
|
||||
|
||||
// Act
|
||||
|
|
@ -342,7 +342,7 @@ namespace Microsoft.AspNet.Mvc
|
|||
// Arrange
|
||||
var fileResult = new FilePathResult(path, "text/plain")
|
||||
{
|
||||
FileSystem = Mock.Of<IFileSystem>(),
|
||||
FileProvider = Mock.Of<IFileProvider>(),
|
||||
};
|
||||
|
||||
// Act
|
||||
|
|
@ -362,7 +362,7 @@ namespace Microsoft.AspNet.Mvc
|
|||
// Arrange
|
||||
var fileResult = new FilePathResult(path, "text/plain")
|
||||
{
|
||||
FileSystem = Mock.Of<IFileSystem>(),
|
||||
FileProvider = Mock.Of<IFileProvider>(),
|
||||
};
|
||||
|
||||
// Act
|
||||
|
|
@ -382,7 +382,7 @@ namespace Microsoft.AspNet.Mvc
|
|||
// Arrange
|
||||
var fileResult = new FilePathResult(path, "text/plain")
|
||||
{
|
||||
FileSystem = Mock.Of<IFileSystem>(),
|
||||
FileProvider = Mock.Of<IFileProvider>(),
|
||||
};
|
||||
|
||||
// Act
|
||||
|
|
@ -427,7 +427,7 @@ namespace Microsoft.AspNet.Mvc
|
|||
// Arrange
|
||||
var fileResult = new FilePathResult(path, "text/plain")
|
||||
{
|
||||
FileSystem = Mock.Of<IFileSystem>(),
|
||||
FileProvider = Mock.Of<IFileProvider>(),
|
||||
};
|
||||
|
||||
// Act
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
private readonly Action<IApplicationBuilder> _app = new Startup().Configure;
|
||||
|
||||
[Fact]
|
||||
public async Task RazorViewEngine_UsesFileSystemOnViewEngineOptionsToLocateViews()
|
||||
public async Task RazorViewEngine_UsesFileProviderOnViewEngineOptionsToLocateViews()
|
||||
{
|
||||
// Arrange
|
||||
var expectedMessage = "Hello test-user, this is /RazorViewEngineOptions_Home";
|
||||
|
|
@ -31,7 +31,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RazorViewEngine_UsesFileSystemOnViewEngineOptionsToLocateAreaViews()
|
||||
public async Task RazorViewEngine_UsesFileProviderOnViewEngineOptionsToLocateAreaViews()
|
||||
{
|
||||
// Arrange
|
||||
var expectedMessage = "Hello admin-user, this is /Restricted/RazorViewEngineOptions_Admin/Login";
|
||||
|
|
|
|||
|
|
@ -12,11 +12,11 @@ namespace Microsoft.AspNet.Mvc.Razor.Directives
|
|||
public void GetInheritedChunks_ReadsChunksFromViewStartsInPath()
|
||||
{
|
||||
// Arrange
|
||||
var fileSystem = new TestFileSystem();
|
||||
fileSystem.AddFile(@"Views\accounts\_ViewStart.cshtml", "@using AccountModels");
|
||||
fileSystem.AddFile(@"Views\Shared\_ViewStart.cshtml", "@inject SharedHelper Shared");
|
||||
fileSystem.AddFile(@"Views\home\_ViewStart.cshtml", "@using MyNamespace");
|
||||
fileSystem.AddFile(@"Views\_ViewStart.cshtml",
|
||||
var fileProvider = new TestFileProvider();
|
||||
fileProvider.AddFile(@"Views\accounts\_ViewStart.cshtml", "@using AccountModels");
|
||||
fileProvider.AddFile(@"Views\Shared\_ViewStart.cshtml", "@inject SharedHelper Shared");
|
||||
fileProvider.AddFile(@"Views\home\_ViewStart.cshtml", "@using MyNamespace");
|
||||
fileProvider.AddFile(@"Views\_ViewStart.cshtml",
|
||||
@"@inject MyHelper<TModel> Helper
|
||||
@inherits MyBaseType
|
||||
|
||||
|
|
@ -30,8 +30,8 @@ namespace Microsoft.AspNet.Mvc.Razor.Directives
|
|||
new InjectChunk("MyTestHtmlHelper", "Html"),
|
||||
new UsingChunk { Namespace = "AppNamespace.Model" },
|
||||
};
|
||||
var host = new MvcRazorHost(fileSystem);
|
||||
var utility = new ChunkInheritanceUtility(host, fileSystem, defaultChunks);
|
||||
var host = new MvcRazorHost(fileProvider);
|
||||
var utility = new ChunkInheritanceUtility(host, fileProvider, defaultChunks);
|
||||
|
||||
// Act
|
||||
var codeTrees = utility.GetInheritedCodeTrees(@"Views\home\Index.cshtml");
|
||||
|
|
@ -66,17 +66,17 @@ namespace Microsoft.AspNet.Mvc.Razor.Directives
|
|||
public void GetInheritedChunks_ReturnsEmptySequenceIfNoViewStartsArePresent()
|
||||
{
|
||||
// Arrange
|
||||
var fileSystem = new TestFileSystem();
|
||||
fileSystem.AddFile(@"_ViewStart.cs", string.Empty);
|
||||
fileSystem.AddFile(@"Views\_Layout.cshtml", string.Empty);
|
||||
fileSystem.AddFile(@"Views\home\_not-viewstart.cshtml", string.Empty);
|
||||
var host = new MvcRazorHost(fileSystem);
|
||||
var fileProvider = new TestFileProvider();
|
||||
fileProvider.AddFile(@"_ViewStart.cs", string.Empty);
|
||||
fileProvider.AddFile(@"Views\_Layout.cshtml", string.Empty);
|
||||
fileProvider.AddFile(@"Views\home\_not-viewstart.cshtml", string.Empty);
|
||||
var host = new MvcRazorHost(fileProvider);
|
||||
var defaultChunks = new Chunk[]
|
||||
{
|
||||
new InjectChunk("MyTestHtmlHelper", "Html"),
|
||||
new UsingChunk { Namespace = "AppNamespace.Model" },
|
||||
};
|
||||
var utility = new ChunkInheritanceUtility(host, fileSystem, defaultChunks);
|
||||
var utility = new ChunkInheritanceUtility(host, fileProvider, defaultChunks);
|
||||
|
||||
// Act
|
||||
var codeTrees = utility.GetInheritedCodeTrees(@"Views\home\Index.cshtml");
|
||||
|
|
@ -89,10 +89,10 @@ namespace Microsoft.AspNet.Mvc.Razor.Directives
|
|||
public void MergeInheritedChunks_MergesDefaultInheritedChunks()
|
||||
{
|
||||
// Arrange
|
||||
var fileSystem = new TestFileSystem();
|
||||
fileSystem.AddFile(@"Views\_ViewStart.cshtml",
|
||||
var fileProvider = new TestFileProvider();
|
||||
fileProvider.AddFile(@"Views\_ViewStart.cshtml",
|
||||
"@inject DifferentHelper<TModel> Html");
|
||||
var host = new MvcRazorHost(fileSystem);
|
||||
var host = new MvcRazorHost(fileProvider);
|
||||
var defaultChunks = new Chunk[]
|
||||
{
|
||||
new InjectChunk("MyTestHtmlHelper", "Html"),
|
||||
|
|
@ -117,7 +117,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Directives
|
|||
}
|
||||
};
|
||||
|
||||
var utility = new ChunkInheritanceUtility(host, fileSystem, defaultChunks);
|
||||
var utility = new ChunkInheritanceUtility(host, fileProvider, defaultChunks);
|
||||
var codeTree = new CodeTree();
|
||||
|
||||
// Act
|
||||
|
|
|
|||
|
|
@ -146,7 +146,7 @@ MyType1
|
|||
private static CodeBuilderContext CreateContext()
|
||||
{
|
||||
return new CodeBuilderContext(
|
||||
new CodeGeneratorContext(new MvcRazorHost(new TestFileSystem()),
|
||||
new CodeGeneratorContext(new MvcRazorHost(new TestFileProvider()),
|
||||
"MyClass",
|
||||
"MyNamespace",
|
||||
string.Empty,
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ Environment.NewLine +
|
|||
private static CodeBuilderContext CreateContext()
|
||||
{
|
||||
return new CodeBuilderContext(
|
||||
new CodeGeneratorContext(new MvcRazorHost(new TestFileSystem()),
|
||||
new CodeGeneratorContext(new MvcRazorHost(new TestFileProvider()),
|
||||
"MyClass",
|
||||
"MyNamespace",
|
||||
string.Empty,
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Microsoft.AspNet.FileSystems;
|
||||
using Microsoft.AspNet.FileProviders;
|
||||
using Microsoft.AspNet.Razor;
|
||||
using Microsoft.AspNet.Razor.Generator;
|
||||
using Microsoft.AspNet.Razor.Generator.Compiler;
|
||||
|
|
@ -19,7 +19,7 @@ namespace Microsoft.AspNet.Mvc.Razor
|
|||
public void MvcRazorHost_EnablesInstrumentationByDefault()
|
||||
{
|
||||
// Arrange
|
||||
var host = new MvcRazorHost(new TestFileSystem());
|
||||
var host = new MvcRazorHost(new TestFileProvider());
|
||||
|
||||
// Act
|
||||
var instrumented = host.EnableInstrumentation;
|
||||
|
|
@ -32,7 +32,7 @@ namespace Microsoft.AspNet.Mvc.Razor
|
|||
public void MvcRazorHost_GeneratesTagHelperModelExpressionCode_DesignTime()
|
||||
{
|
||||
// Arrange
|
||||
var host = new MvcRazorHost(new TestFileSystem())
|
||||
var host = new MvcRazorHost(new TestFileProvider())
|
||||
{
|
||||
DesignTimeMode = true
|
||||
};
|
||||
|
|
@ -84,7 +84,7 @@ namespace Microsoft.AspNet.Mvc.Razor
|
|||
public void MvcRazorHost_ParsesAndGeneratesCodeForBasicScenarios(string scenarioName)
|
||||
{
|
||||
// Arrange
|
||||
var host = new TestMvcRazorHost(new TestFileSystem());
|
||||
var host = new TestMvcRazorHost(new TestFileProvider());
|
||||
|
||||
// Act and Assert
|
||||
RunRuntimeTest(host, scenarioName);
|
||||
|
|
@ -94,7 +94,7 @@ namespace Microsoft.AspNet.Mvc.Razor
|
|||
public void InjectVisitor_GeneratesCorrectLineMappings()
|
||||
{
|
||||
// Arrange
|
||||
var host = new MvcRazorHost(new TestFileSystem())
|
||||
var host = new MvcRazorHost(new TestFileProvider())
|
||||
{
|
||||
DesignTimeMode = true
|
||||
};
|
||||
|
|
@ -113,7 +113,7 @@ namespace Microsoft.AspNet.Mvc.Razor
|
|||
public void InjectVisitorWithModel_GeneratesCorrectLineMappings()
|
||||
{
|
||||
// Arrange
|
||||
var host = new MvcRazorHost(new TestFileSystem())
|
||||
var host = new MvcRazorHost(new TestFileProvider())
|
||||
{
|
||||
DesignTimeMode = true
|
||||
};
|
||||
|
|
@ -133,7 +133,7 @@ namespace Microsoft.AspNet.Mvc.Razor
|
|||
public void ModelVisitor_GeneratesCorrectLineMappings()
|
||||
{
|
||||
// Arrange
|
||||
var host = new MvcRazorHost(new TestFileSystem())
|
||||
var host = new MvcRazorHost(new TestFileProvider())
|
||||
{
|
||||
DesignTimeMode = true
|
||||
};
|
||||
|
|
@ -229,8 +229,8 @@ namespace Microsoft.AspNet.Mvc.Razor
|
|||
/// </summary>
|
||||
private class TestMvcRazorHost : MvcRazorHost
|
||||
{
|
||||
public TestMvcRazorHost(IFileSystem fileSystem)
|
||||
: base(fileSystem)
|
||||
public TestMvcRazorHost(IFileProvider fileProvider)
|
||||
: base(fileProvider)
|
||||
{ }
|
||||
|
||||
public override CodeBuilder DecorateCodeBuilder(CodeBuilder incomingBuilder, CodeBuilderContext context)
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using Microsoft.AspNet.FileSystems;
|
||||
using Microsoft.AspNet.FileProviders;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.Razor
|
||||
{
|
||||
|
|
|
|||
|
|
@ -4,12 +4,12 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Microsoft.AspNet.FileSystems;
|
||||
using Microsoft.AspNet.FileProviders;
|
||||
using Microsoft.Framework.Expiration.Interfaces;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.Razor
|
||||
{
|
||||
public class TestFileSystem : IFileSystem
|
||||
public class TestFileProvider : IFileProvider
|
||||
{
|
||||
private readonly Dictionary<string, IFileInfo> _lookup =
|
||||
new Dictionary<string, IFileInfo>(StringComparer.Ordinal);
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System.IO;
|
||||
using Microsoft.AspNet.FileSystems;
|
||||
using Microsoft.AspNet.FileProviders;
|
||||
using Microsoft.Framework.Runtime;
|
||||
using Microsoft.Framework.Runtime.Infrastructure;
|
||||
using Xunit;
|
||||
|
|
@ -56,7 +56,7 @@ namespace Microsoft.AspNet.Mvc.Razor
|
|||
@"Views\_ViewStart.cshtml",
|
||||
@"_ViewStart.cshtml"
|
||||
};
|
||||
var fileSystem = new PhysicalFileSystem(GetTestFileSystemBase());
|
||||
var fileProvider = new PhysicalFileProvider(GetTestFileProviderBase());
|
||||
|
||||
// Act
|
||||
var result = ViewStartUtility.GetViewStartLocations(inputPath);
|
||||
|
|
@ -116,7 +116,7 @@ namespace Microsoft.AspNet.Mvc.Razor
|
|||
public void GetViewStartLocations_ReturnsEmptySequence_IfViewStartIsAtRoot()
|
||||
{
|
||||
// Arrange
|
||||
var appBase = GetTestFileSystemBase();
|
||||
var appBase = GetTestFileProviderBase();
|
||||
var viewPath = "_ViewStart.cshtml";
|
||||
|
||||
// Act
|
||||
|
|
@ -130,7 +130,7 @@ namespace Microsoft.AspNet.Mvc.Razor
|
|||
public void GetViewStartLocations_ReturnsEmptySequence_IfPathIsRooted()
|
||||
{
|
||||
// Arrange
|
||||
var appBase = GetTestFileSystemBase();
|
||||
var appBase = GetTestFileProviderBase();
|
||||
var absolutePath = Path.Combine(Directory.GetCurrentDirectory(), "Index.cshtml");
|
||||
|
||||
// Act
|
||||
|
|
@ -140,7 +140,7 @@ namespace Microsoft.AspNet.Mvc.Razor
|
|||
Assert.Empty(result);
|
||||
}
|
||||
|
||||
private static string GetTestFileSystemBase()
|
||||
private static string GetTestFileProviderBase()
|
||||
{
|
||||
var serviceProvider = CallContextServiceLocator.Locator.ServiceProvider;
|
||||
var appEnv = (IApplicationEnvironment)serviceProvider.GetService(typeof(IApplicationEnvironment));
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using Microsoft.AspNet.FileSystems;
|
||||
using Microsoft.AspNet.FileProviders;
|
||||
using Moq;
|
||||
using Xunit;
|
||||
|
||||
|
|
|
|||
|
|
@ -16,8 +16,8 @@ namespace Microsoft.AspNet.Mvc.Razor
|
|||
public void GetOrAdd_ReturnsCompilationResultFromFactory()
|
||||
{
|
||||
// Arrange
|
||||
var fileSystem = new TestFileSystem();
|
||||
var cache = new CompilerCache(Enumerable.Empty<RazorFileInfoCollection>(), fileSystem);
|
||||
var fileProvider = new TestFileProvider();
|
||||
var cache = new CompilerCache(Enumerable.Empty<RazorFileInfoCollection>(), fileProvider);
|
||||
var fileInfo = new TestFileInfo
|
||||
{
|
||||
LastModified = DateTime.FromFileTimeUtc(10000)
|
||||
|
|
@ -111,8 +111,8 @@ namespace Microsoft.AspNet.Mvc.Razor
|
|||
var instance = new RuntimeCompileIdentical();
|
||||
var length = Encoding.UTF8.GetByteCount(instance.Content);
|
||||
var collection = new ViewCollection();
|
||||
var fileSystem = new TestFileSystem();
|
||||
var cache = new CompilerCache(new[] { new ViewCollection() }, fileSystem);
|
||||
var fileProvider = new TestFileProvider();
|
||||
var cache = new CompilerCache(new[] { new ViewCollection() }, fileProvider);
|
||||
|
||||
var fileInfo = new TestFileInfo
|
||||
{
|
||||
|
|
@ -153,8 +153,8 @@ namespace Microsoft.AspNet.Mvc.Razor
|
|||
var instance = (View)Activator.CreateInstance(resultViewType);
|
||||
var length = Encoding.UTF8.GetByteCount(instance.Content);
|
||||
var collection = new ViewCollection();
|
||||
var fileSystem = new TestFileSystem();
|
||||
var cache = new CompilerCache(new[] { new ViewCollection() }, fileSystem);
|
||||
var fileProvider = new TestFileProvider();
|
||||
var cache = new CompilerCache(new[] { new ViewCollection() }, fileProvider);
|
||||
|
||||
var fileInfo = new TestFileInfo
|
||||
{
|
||||
|
|
@ -189,7 +189,7 @@ namespace Microsoft.AspNet.Mvc.Razor
|
|||
// Arrange
|
||||
var instance = (View)Activator.CreateInstance(typeof(PreCompile));
|
||||
var length = Encoding.UTF8.GetByteCount(instance.Content);
|
||||
var fileSystem = new TestFileSystem();
|
||||
var fileProvider = new TestFileProvider();
|
||||
|
||||
var lastModified = DateTime.UtcNow;
|
||||
|
||||
|
|
@ -207,7 +207,7 @@ namespace Microsoft.AspNet.Mvc.Razor
|
|||
Content = viewStartContent,
|
||||
LastModified = DateTime.UtcNow
|
||||
};
|
||||
fileSystem.AddFile("_ViewStart.cshtml", viewStartFileInfo);
|
||||
fileProvider.AddFile("_ViewStart.cshtml", viewStartFileInfo);
|
||||
var viewStartRazorFileInfo = new RazorFileInfo
|
||||
{
|
||||
Hash = RazorFileHash.GetHash(GetMemoryStream(viewStartContent)),
|
||||
|
|
@ -219,7 +219,7 @@ namespace Microsoft.AspNet.Mvc.Razor
|
|||
|
||||
var precompiledViews = new ViewCollection();
|
||||
precompiledViews.Add(viewStartRazorFileInfo);
|
||||
var cache = new CompilerCache(new[] { precompiledViews }, fileSystem);
|
||||
var cache = new CompilerCache(new[] { precompiledViews }, fileProvider);
|
||||
|
||||
// Act
|
||||
var actual = cache.GetOrAdd(runtimeFileInfo,
|
||||
|
|
@ -235,18 +235,18 @@ namespace Microsoft.AspNet.Mvc.Razor
|
|||
// Arrange
|
||||
var expectedType = typeof(RuntimeCompileDifferent);
|
||||
var lastModified = DateTime.UtcNow;
|
||||
var fileSystem = new TestFileSystem();
|
||||
var fileProvider = new TestFileProvider();
|
||||
var collection = new ViewCollection();
|
||||
var precompiledFile = collection.FileInfos[0];
|
||||
precompiledFile.RelativePath = "Views\\home\\index.cshtml";
|
||||
var cache = new CompilerCache(new[] { collection }, fileSystem);
|
||||
var cache = new CompilerCache(new[] { collection }, fileProvider);
|
||||
var testFile = new TestFileInfo
|
||||
{
|
||||
Content = new PreCompile().Content,
|
||||
LastModified = precompiledFile.LastModified,
|
||||
PhysicalPath = precompiledFile.RelativePath
|
||||
};
|
||||
fileSystem.AddFile(precompiledFile.RelativePath, testFile);
|
||||
fileProvider.AddFile(precompiledFile.RelativePath, testFile);
|
||||
var relativeFile = new RelativeFileInfo(testFile, testFile.PhysicalPath);
|
||||
|
||||
// Act 1
|
||||
|
|
@ -257,7 +257,7 @@ namespace Microsoft.AspNet.Mvc.Razor
|
|||
Assert.Equal(typeof(PreCompile), actual1.CompiledType);
|
||||
|
||||
// Act 2
|
||||
fileSystem.AddFile("Views\\_ViewStart.cshtml", "");
|
||||
fileProvider.AddFile("Views\\_ViewStart.cshtml", "");
|
||||
var actual2 = cache.GetOrAdd(relativeFile,
|
||||
compile: _ => CompilationResult.Successful(expectedType));
|
||||
|
||||
|
|
@ -271,7 +271,7 @@ namespace Microsoft.AspNet.Mvc.Razor
|
|||
// Arrange
|
||||
var expectedType = typeof(RuntimeCompileDifferent);
|
||||
var lastModified = DateTime.UtcNow;
|
||||
var fileSystem = new TestFileSystem();
|
||||
var fileProvider = new TestFileProvider();
|
||||
|
||||
var viewCollection = new ViewCollection();
|
||||
var precompiledView = viewCollection.FileInfos[0];
|
||||
|
|
@ -282,7 +282,7 @@ namespace Microsoft.AspNet.Mvc.Razor
|
|||
LastModified = precompiledView.LastModified,
|
||||
PhysicalPath = precompiledView.RelativePath
|
||||
};
|
||||
fileSystem.AddFile(viewFileInfo.PhysicalPath, viewFileInfo);
|
||||
fileProvider.AddFile(viewFileInfo.PhysicalPath, viewFileInfo);
|
||||
|
||||
var viewStartFileInfo = new TestFileInfo
|
||||
{
|
||||
|
|
@ -298,10 +298,10 @@ namespace Microsoft.AspNet.Mvc.Razor
|
|||
Hash = RazorFileHash.GetHash(viewStartFileInfo),
|
||||
Length = viewStartFileInfo.Length
|
||||
};
|
||||
fileSystem.AddFile(viewStartFileInfo.PhysicalPath, viewStartFileInfo);
|
||||
fileProvider.AddFile(viewStartFileInfo.PhysicalPath, viewStartFileInfo);
|
||||
|
||||
viewCollection.Add(viewStart);
|
||||
var cache = new CompilerCache(new[] { viewCollection }, fileSystem);
|
||||
var cache = new CompilerCache(new[] { viewCollection }, fileProvider);
|
||||
var fileInfo = new RelativeFileInfo(viewFileInfo, viewFileInfo.PhysicalPath);
|
||||
|
||||
// Act 1
|
||||
|
|
@ -312,7 +312,7 @@ namespace Microsoft.AspNet.Mvc.Razor
|
|||
Assert.Equal(typeof(PreCompile), actual1.CompiledType);
|
||||
|
||||
// Act 2
|
||||
fileSystem.DeleteFile(viewStartFileInfo.PhysicalPath);
|
||||
fileProvider.DeleteFile(viewStartFileInfo.PhysicalPath);
|
||||
var actual2 = cache.GetOrAdd(fileInfo,
|
||||
compile: _ => CompilationResult.Successful(expectedType));
|
||||
|
||||
|
|
@ -387,10 +387,10 @@ namespace Microsoft.AspNet.Mvc.Razor
|
|||
RelativePath = fileInfo.PhysicalPath,
|
||||
};
|
||||
|
||||
var fileSystem = new TestFileSystem();
|
||||
fileSystem.AddFile(viewStartRazorFileInfo.RelativePath, viewStartFileInfo);
|
||||
var fileProvider = new TestFileProvider();
|
||||
fileProvider.AddFile(viewStartRazorFileInfo.RelativePath, viewStartFileInfo);
|
||||
var viewCollection = new ViewCollection();
|
||||
var cache = new CompilerCache(new[] { viewCollection }, fileSystem);
|
||||
var cache = new CompilerCache(new[] { viewCollection }, fileProvider);
|
||||
|
||||
// Act
|
||||
var actual = cache.GetOrAdd(runtimeFileInfo,
|
||||
|
|
@ -405,7 +405,7 @@ namespace Microsoft.AspNet.Mvc.Razor
|
|||
{
|
||||
// Arrange
|
||||
var lastModified = DateTime.UtcNow;
|
||||
var cache = new CompilerCache(Enumerable.Empty<RazorFileInfoCollection>(), new TestFileSystem());
|
||||
var cache = new CompilerCache(Enumerable.Empty<RazorFileInfoCollection>(), new TestFileProvider());
|
||||
var fileInfo = new TestFileInfo
|
||||
{
|
||||
PhysicalPath = "test",
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNet.FileSystems;
|
||||
using Microsoft.AspNet.FileProviders;
|
||||
using Microsoft.Framework.OptionsModel;
|
||||
using Microsoft.Framework.Expiration.Interfaces;
|
||||
using Moq;
|
||||
|
|
@ -11,11 +11,11 @@ using Xunit;
|
|||
|
||||
namespace Microsoft.AspNet.Mvc.Razor
|
||||
{
|
||||
public class DefaultRazorFileSystemCacheTest
|
||||
public class DefaultRazorFileProviderCacheTest
|
||||
{
|
||||
private const string FileName = "myView.cshtml";
|
||||
|
||||
public DummyFileSystem TestFileSystem { get; } = new DummyFileSystem();
|
||||
public DummyFileProvider TestFileProvider { get; } = new DummyFileProvider();
|
||||
|
||||
public IOptions<RazorViewEngineOptions> OptionsAccessor
|
||||
{
|
||||
|
|
@ -23,7 +23,7 @@ namespace Microsoft.AspNet.Mvc.Razor
|
|||
{
|
||||
var options = new RazorViewEngineOptions
|
||||
{
|
||||
FileSystem = TestFileSystem
|
||||
FileProvider = TestFileProvider
|
||||
};
|
||||
|
||||
var mock = new Mock<IOptions<RazorViewEngineOptions>>(MockBehavior.Strict);
|
||||
|
|
@ -46,7 +46,7 @@ namespace Microsoft.AspNet.Mvc.Razor
|
|||
LastModified = DateTime.Now,
|
||||
};
|
||||
|
||||
TestFileSystem.AddFile(fileInfo);
|
||||
TestFileProvider.AddFile(fileInfo);
|
||||
}
|
||||
|
||||
public void Sleep(ControllableExpiringFileInfoCache cache, int offsetMilliseconds)
|
||||
|
|
@ -309,33 +309,33 @@ namespace Microsoft.AspNet.Mvc.Razor
|
|||
}
|
||||
|
||||
[Fact]
|
||||
public void GetDirectoryInfo_PassesThroughToUnderlyingFileSystem()
|
||||
public void GetDirectoryInfo_PassesThroughToUnderlyingFileProvider()
|
||||
{
|
||||
// Arrange
|
||||
var fileSystem = new Mock<IFileSystem>();
|
||||
var fileProvider = new Mock<IFileProvider>();
|
||||
var expected = Mock.Of<IDirectoryContents>();
|
||||
fileSystem.Setup(f => f.GetDirectoryContents("/test-path"))
|
||||
fileProvider.Setup(f => f.GetDirectoryContents("/test-path"))
|
||||
.Returns(expected)
|
||||
.Verifiable();
|
||||
var options = new RazorViewEngineOptions
|
||||
{
|
||||
FileSystem = fileSystem.Object
|
||||
FileProvider = fileProvider.Object
|
||||
};
|
||||
var accessor = new Mock<IOptions<RazorViewEngineOptions>>();
|
||||
accessor.SetupGet(a => a.Options)
|
||||
.Returns(options);
|
||||
|
||||
var cachedFileSystem = new DefaultRazorFileSystemCache(accessor.Object);
|
||||
var cachedFileProvider = new DefaultRazorFileProviderCache(accessor.Object);
|
||||
|
||||
// Act
|
||||
var result = cachedFileSystem.GetDirectoryContents("/test-path");
|
||||
var result = cachedFileProvider.GetDirectoryContents("/test-path");
|
||||
|
||||
// Assert
|
||||
Assert.Same(expected, result);
|
||||
fileSystem.Verify();
|
||||
fileProvider.Verify();
|
||||
}
|
||||
|
||||
public class ControllableExpiringFileInfoCache : DefaultRazorFileSystemCache
|
||||
public class ControllableExpiringFileInfoCache : DefaultRazorFileProviderCache
|
||||
{
|
||||
public ControllableExpiringFileInfoCache(IOptions<RazorViewEngineOptions> optionsAccessor)
|
||||
: base(optionsAccessor)
|
||||
|
|
@ -367,7 +367,7 @@ namespace Microsoft.AspNet.Mvc.Razor
|
|||
_internalUtcNow = UtcNow.AddMilliseconds(milliSeconds);
|
||||
}
|
||||
}
|
||||
public class DummyFileSystem : IFileSystem
|
||||
public class DummyFileProvider : IFileProvider
|
||||
{
|
||||
private Dictionary<string, IFileInfo> _fileInfos = new Dictionary<string, IFileInfo>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Microsoft.AspNet.FileSystems;
|
||||
using Microsoft.AspNet.FileProviders;
|
||||
using Microsoft.AspNet.Razor;
|
||||
using Microsoft.AspNet.Razor.Generator.Compiler;
|
||||
using Microsoft.AspNet.Razor.Parser;
|
||||
|
|
|
|||
|
|
@ -9,13 +9,13 @@ namespace Microsoft.AspNet.Mvc.Razor
|
|||
public class RazorViewEngineOptionsTest
|
||||
{
|
||||
[Fact]
|
||||
public void FileSystemThrows_IfNullIsAsseigned()
|
||||
public void FileProviderThrows_IfNullIsAsseigned()
|
||||
{
|
||||
// Arrange
|
||||
var options = new RazorViewEngineOptions();
|
||||
|
||||
// Act and Assert
|
||||
var ex = Assert.Throws<ArgumentNullException>(() => options.FileSystem = null);
|
||||
var ex = Assert.Throws<ArgumentNullException>(() => options.FileProvider = null);
|
||||
Assert.Equal("value", ex.ParamName);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"code": [
|
||||
"**/*.cs",
|
||||
"../Microsoft.AspNet.Mvc.Razor.Host.Test/TestFileSystem.cs",
|
||||
"../Microsoft.AspNet.Mvc.Razor.Host.Test/TestFileProvider.cs",
|
||||
"../Microsoft.AspNet.Mvc.Razor.Host.Test/TestFileInfo.cs"
|
||||
],
|
||||
"dependencies": {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System.IO;
|
||||
using Microsoft.AspNet.FileSystems;
|
||||
using Microsoft.AspNet.FileProviders;
|
||||
using Microsoft.AspNet.Mvc.Razor;
|
||||
using Microsoft.Framework.Runtime;
|
||||
using Moq;
|
||||
|
|
@ -13,7 +13,7 @@ namespace Microsoft.AspNet.Mvc
|
|||
public class RazorViewEngineOptionsSetupTest
|
||||
{
|
||||
[Fact]
|
||||
public void RazorViewEngineOptionsSetup_SetsUpFileSystem()
|
||||
public void RazorViewEngineOptionsSetup_SetsUpFileProvider()
|
||||
{
|
||||
// Arrange
|
||||
var options = new RazorViewEngineOptions();
|
||||
|
|
@ -26,8 +26,8 @@ namespace Microsoft.AspNet.Mvc
|
|||
optionsSetup.Configure(options);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(options.FileSystem);
|
||||
Assert.IsType<PhysicalFileSystem>(options.FileSystem);
|
||||
Assert.NotNull(options.FileProvider);
|
||||
Assert.IsType<PhysicalFileProvider>(options.FileProvider);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
using System.IO;
|
||||
using System.Reflection;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.FileSystems;
|
||||
using Microsoft.AspNet.FileProviders;
|
||||
using Microsoft.AspNet.Mvc.Razor;
|
||||
using Microsoft.Framework.DependencyInjection;
|
||||
using Microsoft.AspNet.Routing;
|
||||
|
|
@ -23,7 +23,7 @@ namespace RazorViewEngineOptionsWebsite
|
|||
|
||||
services.Configure<RazorViewEngineOptions>(options =>
|
||||
{
|
||||
options.FileSystem = new EmbeddedResourceFileSystem(GetType().GetTypeInfo().Assembly, "EmbeddedResources");
|
||||
options.FileProvider = new EmbeddedFileProvider(GetType().GetTypeInfo().Assembly, "EmbeddedResources");
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
RazorViewEngineOptionsWebSite
|
||||
===
|
||||
|
||||
This web site illustrates use cases for `RazorViewEngineOptions.FileSystem`.
|
||||
This web site illustrates use cases for `RazorViewEngineOptions.FileProvider`.
|
||||
Loading…
Reference in New Issue