public BundleTagHelper(IHostingEnvironment hostingEnvironment, IMemoryCache cache, HtmlEncoder htmlEncoder, IUrlHelperFactory urlHelperFactory, BundleOptions options = null, IBundleProvider bundleProvider = null) { if (hostingEnvironment == null) { throw new ArgumentNullException(nameof(hostingEnvironment)); } if (cache == null) { throw new ArgumentNullException(nameof(cache)); } if (htmlEncoder == null) { throw new ArgumentNullException(nameof(htmlEncoder)); } if (urlHelperFactory == null) { throw new ArgumentNullException(nameof(urlHelperFactory)); } if (options == null) { options = new BundleOptions(); options.Configure(hostingEnvironment); } _bundleProvider = bundleProvider ?? new BundleProvider(hostingEnvironment); _options = options; _hostingEnvironment = hostingEnvironment; _cache = cache; _htmlEncoder = htmlEncoder; _urlHelperFactory = urlHelperFactory; }
public static void SetupBundler(IBundleProvider bundleProvider) { var scriptBundleBuilder = bundleProvider.CreateScriptBundle(async: false); var styleBundleBuilder = bundleProvider.CreateLessBundle(); // Scripts scriptBundleBuilder .AddFile("~/Scripts/jquery-1.10.2.js") .AddFile("~/Scripts/jquery.validate.js") .AddFile("~/Scripts/modernizr-2.6.2.js") .AddFile("~/Scripts/bootstrap.js") .AddFile("~/Scripts/respond.js"); // Styles styleBundleBuilder .AddFile("~/Content/bootstrap.css") .AddFile("~/Content/site.css"); // Create bundles ScriptBundle = scriptBundleBuilder.Create(); StyleBundle = styleBundleBuilder.Create(); // Add bundles to bundle provider if (!bundleProvider.Add(ApplicationScriptsBundleKey, ScriptBundle)) { throw new Exception("Can't setup script bundle."); } if (!bundleProvider.Add(ApplicationStylesBundleKey, StyleBundle)) { throw new Exception("Can't setup style bundle."); } }
public BundleTagHelper(IHostingEnvironment hostingEnvironment, IMemoryCache cache, HtmlEncoder htmlEncoder, IUrlHelperFactory urlHelperFactory, BundleOptions options = null, IBundleProvider bundleProvider = null) { _bundleProvider = bundleProvider ?? new BundleProvider(); _options = options ?? new BundleOptions(hostingEnvironment); _hostingEnvironment = hostingEnvironment ?? throw new ArgumentNullException(nameof(hostingEnvironment)); _cache = cache ?? throw new ArgumentNullException(nameof(cache)); _htmlEncoder = htmlEncoder ?? throw new ArgumentNullException(nameof(htmlEncoder)); _urlHelperFactory = urlHelperFactory ?? throw new ArgumentNullException(nameof(urlHelperFactory)); }
private static void TryRemapHandler(HttpApplication app, IBundleProvider provider) { IBundleContentResponse bundleResponse; string requestVersion; if (provider.GetResponse(app.Request.Url, out bundleResponse, out requestVersion)) { app.Context.RemapHandler(new AspNetBundlerHandler(provider.Context, bundleResponse, requestVersion)); } }
/// <summary> /// Set BundleProvider for request handling /// </summary> /// <param name="bundleProvider"></param> public static void Initialize(IBundleProvider bundleProvider) { if (bundleProvider == null) { throw new ArgumentNullException(nameof(bundleProvider)); } lock (WriteLock) { Interlocked.Exchange(ref _currentBundleProvider, bundleProvider); IsInitialized = true; } }
public static BundleBuilder CreateCssBundle(this IBundleProvider bundleProvider, params IBundleContentTransformer[] additionalContentTransformers) { return(new BundleBuilder(bundleProvider.Context, CssRenderer.Instance).AddContentTransformer(new CssBundleContentTransformer())); }
public BundleManager(IBundleProvider provider, RequestContext requestContext) { Provider = provider; _requestContext = requestContext; }
public static BundleBuilder CreateLessBundle(this IBundleProvider bundleProvider) { return(new BundleBuilder(bundleProvider.Context, LessRenderer.Instance).AddContentTransformer(new LessBundleContentTransformer())); }
public static BundleBuilder CreateScriptBundle(this IBundleProvider bundleProvider, bool async = false) { return(new BundleBuilder(bundleProvider.Context, async ? JavaScriptRenderer.InstanceAsync : JavaScriptRenderer.Instance).AddContentTransformer(new JavaScriptBundleContentTransformer())); }
public static Bundle CreateBundle(this IBundleProvider bundleProvider, IBundleRenderer bundleRenderer, params IBundleContentTransformer[] transformers) { return(new Bundle(bundleProvider.Context, bundleRenderer, transformers)); }