示例#1
0
        internal static void UseStaticWebAssetsCore(IWebHostEnvironment environment, Stream manifest, bool isJson)
        {
            if (isJson)
            {
                var staticWebAssetManifest = ManifestStaticWebAssetFileProvider.StaticWebAssetManifest.Parse(manifest);
                var provider = new ManifestStaticWebAssetFileProvider(
                    staticWebAssetManifest,
                    (contentRoot) => new PhysicalFileProvider(contentRoot));

                environment.WebRootFileProvider = new CompositeFileProvider(new[] { environment.WebRootFileProvider, provider });
                return;
            }

            var webRootFileProvider = environment.WebRootFileProvider;

            var additionalFiles = StaticWebAssetsReader.Parse(manifest)
                                  .Select(cr => new StaticWebAssetsFileProvider(cr.BasePath, cr.Path))
                                  .OfType <IFileProvider>() // Upcast so we can insert on the resulting list.
                                  .ToList();

            if (additionalFiles.Count == 0)
            {
                return;
            }
            else
            {
                additionalFiles.Insert(0, webRootFileProvider);
                environment.WebRootFileProvider = new CompositeFileProvider(additionalFiles);
            }
        }
示例#2
0
        internal static void UseStaticWebAssetsCore(IWebHostEnvironment environment, Stream manifest)
        {
            var staticWebAssetManifest = ManifestStaticWebAssetFileProvider.StaticWebAssetManifest.Parse(manifest);
            var provider = new ManifestStaticWebAssetFileProvider(
                staticWebAssetManifest,
                (contentRoot) => new PhysicalFileProvider(contentRoot));

            environment.WebRootFileProvider = new CompositeFileProvider(new[] { provider, environment.WebRootFileProvider });
        }