示例#1
0
        public CssBundleManager(IOptions <CssBundlingOptions> options, IDynamicScriptManager scriptManager, IWebHostEnvironment hostEnvironment,
                                IHttpContextAccessor contextAccessor = null, IExceptionLogger logger = null)
        {
            this.options         = (options ?? throw new ArgumentNullException(nameof(options))).Value;
            this.scriptManager   = scriptManager ?? throw new ArgumentNullException(nameof(scriptManager));
            this.hostEnvironment = hostEnvironment ?? throw new ArgumentNullException(nameof(hostEnvironment));
            this.contextAccessor = contextAccessor;
            this.logger          = logger;

            Reset();
            scriptManager.ScriptChanged += name =>
            {
                HashSet <string> bundleKeys;
                lock (sync)
                {
                    if (bundleKeysBySourceUrl == null ||
                        !bundleKeysBySourceUrl.TryGetValue("dynamic://" + name, out bundleKeys))
                    {
                        bundleKeys = null;
                    }
                    {
                    }
                }

                if (bundleKeys != null)
                {
                    foreach (var bundleKey in bundleKeys)
                    {
                        scriptManager.Changed("Bundle." + bundleKey);
                    }
                }
            };
        }