コード例 #1
0
        private List <IFileProvider> GetAllFileProviders(
            IHostingEnvironment hostingEnvironment,
            IEnumerable <IEmbeddedResourceRouteRegistration> embeddedResourceRouteRegistrations,
            IEmbeddedFileProviderFactory embeddedFileProviderFactory
            )
        {
            var allFileProviders = new List <IFileProvider>();

            allFileProviders.Add(hostingEnvironment.WebRootFileProvider);

            var assemblyRoutes = EnumerableHelper
                                 .Enumerate(embeddedResourceRouteRegistrations)
                                 .SelectMany(r => r.GetEmbeddedResourcePaths())
                                 .GroupBy(r => r.Assembly)
                                 .ToList();

            foreach (var assemblyRoute in assemblyRoutes)
            {
                var fileProvider = embeddedFileProviderFactory.Create(assemblyRoute.Key);
                foreach (var route in assemblyRoute)
                {
                    var filteredFileProvider = new FilteredEmbeddedFileProvider(
                        fileProvider,
                        route.Path,
                        route.RewriteFrom,
                        hostingEnvironment.ContentRootFileProvider
                        );
                    allFileProviders.Add(filteredFileProvider);
                }
            }

            return(allFileProviders);
        }
コード例 #2
0
 private static IEnumerable <IFileProvider> CreateAssemblyProviders(
     IEnumerable <IAssemblyResourceRegistration> assemblyResourceRegistrations,
     IEmbeddedFileProviderFactory embeddedFileProviderFactory
     )
 {
     return(assemblyResourceRegistrations
            .Select(r => r.GetType().GetTypeInfo().Assembly)
            .Distinct()
            .Select(a => embeddedFileProviderFactory.Create(a)));
 }