예제 #1
0
        private void LoadDefaultFileRegConfig(ClientDependencySection section)
        {
            if (section.FileRegistrationElement.Providers.Count == 0)
            {
                //create new providers
                var php = new PageHeaderProvider();
                php.Initialize(PageHeaderProvider.DefaultName, null);
                FileRegistrationProviderCollection.Add(php);

                var csrp = new LazyLoadProvider();
                csrp.Initialize(LazyLoadProvider.DefaultName, null);
                FileRegistrationProviderCollection.Add(csrp);

                var lcp = new LoaderControlProvider();
                lcp.Initialize(LoaderControlProvider.DefaultName, null);
                FileRegistrationProviderCollection.Add(lcp);

                var plhp = new PlaceHolderProvider();
                plhp.Initialize(PlaceHolderProvider.DefaultName, null);
                FileRegistrationProviderCollection.Add(plhp);
            }
            else
            {
                ProvidersHelper.InstantiateProviders(section.FileRegistrationElement.Providers, FileRegistrationProviderCollection, typeof(BaseFileRegistrationProvider));
            }
        }
예제 #2
0
        /// <summary>
        /// Generally for unit testing when not using the singleton instance
        /// </summary>
        /// <param name="section"></param>
        /// <param name="ctx"></param>
        internal ClientDependencySettings(ClientDependencySection section, HttpContextBase ctx)
        {
            ConfigSection = section;

            _loadProviders = () =>
                             LoadProviders(ctx);

            _loadProviders();
        }
        /// <summary>
        /// Generally for unit testing when not using the singleton instance
        /// </summary>
        /// <param name="section"></param>
        /// <param name="ctx"></param>
        internal ClientDependencySettings(ClientDependencySection section, HttpContextBase ctx)
        {
            ConfigSection = section;

            _loadProviders = () =>
                LoadProviders(ctx);

            _loadProviders();
        }
예제 #4
0
 private void LoadDefaultMvcFileConfig(ClientDependencySection section)
 {
     if (section.MvcElement.Renderers.Count == 0)
     {
         var mvc = new StandardRenderer();
         mvc.Initialize(StandardRenderer.DefaultName, null);
         MvcRendererCollection.Add(mvc);
     }
     else
     {
         ProvidersHelper.InstantiateProviders(section.MvcElement.Renderers, MvcRendererCollection, typeof(BaseRenderer));
     }
 }
예제 #5
0
 private void LoadDefaultCompositeFileConfig(ClientDependencySection section, HttpContextBase http)
 {
     if (section.CompositeFileElement.FileProcessingProviders.Count == 0)
     {
         var cfpp = new CompositeFileProcessingProvider();
         cfpp.Initialize(CompositeFileProcessingProvider.DefaultName, null);
         cfpp.Initialize(http);
         CompositeFileProcessingProviderCollection.Add(cfpp);
     }
     else
     {
         ProvidersHelper.InstantiateProviders(section.CompositeFileElement.FileProcessingProviders, CompositeFileProcessingProviderCollection, typeof(BaseCompositeFileProcessingProvider));
         //since the BaseCompositeFileProcessingProvider is an IHttpProvider, we need to do the http init
         foreach (var p in CompositeFileProcessingProviderCollection.Cast <BaseCompositeFileProcessingProvider>())
         {
             p.Initialize(http);
         }
     }
 }
예제 #6
0
 private void LoadDefaultFileMapConfig(ClientDependencySection section, HttpContextBase http)
 {
     if (section.CompositeFileElement.FileMapProviders.Count == 0)
     {
         //if not specified, create default
         var fmp = new XmlFileMapper();
         fmp.Initialize(XmlFileMapper.DefaultName, null);
         fmp.Initialize(http);
         FileMapProviderCollection.Add(fmp);
     }
     else
     {
         ProvidersHelper.InstantiateProviders(section.CompositeFileElement.FileMapProviders, FileMapProviderCollection, typeof(BaseFileMapProvider));
         //since the BaseFileMapProvider is an IHttpProvider, we need to do the http init
         foreach (var p in FileMapProviderCollection.Cast <BaseFileMapProvider>())
         {
             p.Initialize(http);
         }
     }
 }
예제 #7
0
        internal void LoadProviders(HttpContextBase http)
        {
            // if there is no section found, then create one
            if (ConfigSection == null)
            {
                //create a new section with the default settings
                ConfigSection = new ClientDependencySection();
            }

            //Load in the path first
            var rootPath = HttpRuntime.AppDomainAppVirtualPath ?? "/";
            //need to check if it's an http path or a lambda path
            var path = ConfigSection.CompositeFileElement.CompositeFileHandlerPath;

            CompositeFileHandlerPath = path.StartsWith("~/")
                ? VirtualPathUtility.ToAbsolute(ConfigSection.CompositeFileElement.CompositeFileHandlerPath, rootPath)
                : ConfigSection.CompositeFileElement.CompositeFileHandlerPath;

            FileRegistrationProviderCollection        = new FileRegistrationProviderCollection();
            CompositeFileProcessingProviderCollection = new CompositeFileProcessingProviderCollection();
            MvcRendererCollection     = new RendererCollection();
            FileMapProviderCollection = new FileMapProviderCollection();

            //load the providers from the config, if there isn't config sections then add default providers
            // and then load the defaults.

            LoadDefaultCompositeFileConfig(ConfigSection, http);

            ////Here we need to detect legacy settings
            //if (ConfigSection.CompositeFileElement.DefaultFileProcessingProviderLegacy != "CompositeFileProcessor"
            //    && ConfigSection.CompositeFileElement.DefaultFileProcessingProvider == "CompositeFileProcessor")
            //{
            //    //if the legacy section is not the default and the non-legacy section IS the default, then use the legacy section
            //    DefaultCompositeFileProcessingProvider = CompositeFileProcessingProviderCollection[ConfigSection.CompositeFileElement.DefaultFileProcessingProviderLegacy];
            //}
            //else
            //{
            //    DefaultCompositeFileProcessingProvider = CompositeFileProcessingProviderCollection[ConfigSection.CompositeFileElement.DefaultFileProcessingProvider];
            //}
            DefaultCompositeFileProcessingProvider = CompositeFileProcessingProviderCollection[ConfigSection.CompositeFileElement.DefaultFileProcessingProvider];
            if (DefaultCompositeFileProcessingProvider == null)
            {
                throw new ProviderException("Unable to load default composite file provider");
            }

            LoadDefaultFileMapConfig(ConfigSection, http);

            DefaultFileMapProvider = FileMapProviderCollection[ConfigSection.CompositeFileElement.DefaultFileMapProvider];
            if (DefaultFileMapProvider == null)
            {
                throw new ProviderException("Unable to load default file map provider");
            }

            LoadDefaultMvcFileConfig(ConfigSection);

            DefaultMvcRenderer = MvcRendererCollection[ConfigSection.MvcElement.DefaultRenderer];
            if (DefaultMvcRenderer == null)
            {
                throw new ProviderException("Unable to load default mvc renderer");
            }

            LoadDefaultFileRegConfig(ConfigSection);

            DefaultFileRegistrationProvider = FileRegistrationProviderCollection[ConfigSection.FileRegistrationElement.DefaultProvider];
            if (DefaultFileRegistrationProvider == null)
            {
                throw new ProviderException("Unable to load default file registration provider");
            }

            if (string.IsNullOrEmpty(ConfigSection.LoggerType))
            {
                Logger = new TraceLogger();
            }
            else
            {
                var t = Type.GetType(ConfigSection.LoggerType);
                if (!typeof(ILogger).IsAssignableFrom(t))
                {
                    throw new ArgumentException("The loggerType '" + ConfigSection.LoggerType + "' does not inherit from ClientDependency.Core.Logging.ILogger");
                }

                Logger = (ILogger)Activator.CreateInstance(t);
            }
        }
        private void LoadDefaultFileRegConfig(ClientDependencySection section)
        {
            if (section.FileRegistrationElement.Providers.Count == 0)
            {
                //create new providers
                var php = new PageHeaderProvider();
                php.Initialize(PageHeaderProvider.DefaultName, null);
                FileRegistrationProviderCollection.Add(php);

                var csrp = new LazyLoadProvider();
                csrp.Initialize(LazyLoadProvider.DefaultName, null);
                FileRegistrationProviderCollection.Add(csrp);

                var lcp = new LoaderControlProvider();
                lcp.Initialize(LoaderControlProvider.DefaultName, null);
                FileRegistrationProviderCollection.Add(lcp);

                var plhp = new PlaceHolderProvider();
                plhp.Initialize(PlaceHolderProvider.DefaultName, null);
                FileRegistrationProviderCollection.Add(plhp);
            }
            else
            {
                ProvidersHelper.InstantiateProviders(section.FileRegistrationElement.Providers, FileRegistrationProviderCollection, typeof(BaseFileRegistrationProvider));
            }
        }
 private void LoadDefaultMvcFileConfig(ClientDependencySection section)
 {
     if (section.MvcElement.Renderers.Count == 0)
     {
         var mvc = new StandardRenderer();
         mvc.Initialize(StandardRenderer.DefaultName, null);
         MvcRendererCollection.Add(mvc);
     }
     else
     {
         ProvidersHelper.InstantiateProviders(section.MvcElement.Renderers, MvcRendererCollection, typeof(BaseRenderer));
     }
 }
 private void LoadDefaultFileMapConfig(ClientDependencySection section, HttpContextBase http)
 {
     if (section.CompositeFileElement.FileMapProviders.Count == 0)
     {
         //if not specified, create default
         var fmp = new XmlFileMapper();
         fmp.Initialize(XmlFileMapper.DefaultName, null);
         fmp.Initialize(http);
         FileMapProviderCollection.Add(fmp);
     }
     else
     {
         ProvidersHelper.InstantiateProviders(section.CompositeFileElement.FileMapProviders, FileMapProviderCollection, typeof(BaseFileMapProvider));
         //since the BaseFileMapProvider is an IHttpProvider, we need to do the http init
         foreach (var p in FileMapProviderCollection.Cast<BaseFileMapProvider>())
         {
             p.Initialize(http);
         }
     }
 }
 private void LoadDefaultCompositeFileConfig(ClientDependencySection section, HttpContextBase http)
 {
     if (section.CompositeFileElement.FileProcessingProviders.Count == 0)
     {
         var cfpp = new CompositeFileProcessingProvider();
         cfpp.Initialize(CompositeFileProcessingProvider.DefaultName, null);
         cfpp.Initialize(http);
         CompositeFileProcessingProviderCollection.Add(cfpp);
     }
     else
     {
         ProvidersHelper.InstantiateProviders(section.CompositeFileElement.FileProcessingProviders, CompositeFileProcessingProviderCollection, typeof(BaseCompositeFileProcessingProvider));
         //since the BaseCompositeFileProcessingProvider is an IHttpProvider, we need to do the http init
         foreach (var p in CompositeFileProcessingProviderCollection.Cast<BaseCompositeFileProcessingProvider>())
         {
             p.Initialize(http);
         }
     }
 }
        internal void LoadProviders(HttpContextBase http)
        {
            // if there is no section found, then create one
            if (ConfigSection == null)
            {
                //create a new section with the default settings
                ConfigSection = new ClientDependencySection();
            }

            FileRegistrationProviderCollection = new FileRegistrationProviderCollection();
            CompositeFileProcessingProviderCollection = new CompositeFileProcessingProviderCollection();
            MvcRendererCollection = new RendererCollection();
            FileMapProviderCollection = new FileMapProviderCollection();

            var rootPath = HttpRuntime.AppDomainAppVirtualPath ?? "/";

            //need to check if it's an http path or a lambda path
            var path = ConfigSection.CompositeFileElement.CompositeFileHandlerPath;
            CompositeFileHandlerPath = path.StartsWith("~/")
                ? VirtualPathUtility.ToAbsolute(ConfigSection.CompositeFileElement.CompositeFileHandlerPath, rootPath)
                : ConfigSection.CompositeFileElement.CompositeFileHandlerPath;

            //load the providers from the config, if there isn't config sections then add default providers
            // and then load the defaults.

            LoadDefaultCompositeFileConfig(ConfigSection, http);

            ////Here we need to detect legacy settings
            //if (ConfigSection.CompositeFileElement.DefaultFileProcessingProviderLegacy != "CompositeFileProcessor"
            //    && ConfigSection.CompositeFileElement.DefaultFileProcessingProvider == "CompositeFileProcessor")
            //{
            //    //if the legacy section is not the default and the non-legacy section IS the default, then use the legacy section
            //    DefaultCompositeFileProcessingProvider = CompositeFileProcessingProviderCollection[ConfigSection.CompositeFileElement.DefaultFileProcessingProviderLegacy];
            //}
            //else
            //{
            //    DefaultCompositeFileProcessingProvider = CompositeFileProcessingProviderCollection[ConfigSection.CompositeFileElement.DefaultFileProcessingProvider];
            //}
            DefaultCompositeFileProcessingProvider = CompositeFileProcessingProviderCollection[ConfigSection.CompositeFileElement.DefaultFileProcessingProvider];
            if (DefaultCompositeFileProcessingProvider == null)
                throw new ProviderException("Unable to load default composite file provider");

            LoadDefaultFileMapConfig(ConfigSection, http);

            DefaultFileMapProvider = FileMapProviderCollection[ConfigSection.CompositeFileElement.DefaultFileMapProvider];
            if (DefaultFileMapProvider == null)
                throw new ProviderException("Unable to load default file map provider");

            LoadDefaultMvcFileConfig(ConfigSection);

            DefaultMvcRenderer = MvcRendererCollection[ConfigSection.MvcElement.DefaultRenderer];
            if (DefaultMvcRenderer == null)
                throw new ProviderException("Unable to load default mvc renderer");

            LoadDefaultFileRegConfig(ConfigSection);

            DefaultFileRegistrationProvider = FileRegistrationProviderCollection[ConfigSection.FileRegistrationElement.DefaultProvider];
            if (DefaultFileRegistrationProvider == null)
                throw new ProviderException("Unable to load default file registration provider");

            if (string.IsNullOrEmpty(ConfigSection.LoggerType))
            {
                Logger = new TraceLogger();
            }
            else
            {
                var t = Type.GetType(ConfigSection.LoggerType);
                if (!typeof(ILogger).IsAssignableFrom(t))
                {
                    throw new ArgumentException("The loggerType '" + ConfigSection.LoggerType + "' does not inherit from ClientDependency.Core.Logging.ILogger");
                }

                Logger = (ILogger)Activator.CreateInstance(t);
            }
        }
예제 #13
0
        internal void LoadProviders(ClientDependencySection section, HttpContextBase http)
        {
            ConfigSection = section;

            FileRegistrationProviderCollection = new FileRegistrationProviderCollection();
            CompositeFileProcessingProviderCollection = new CompositeFileProcessingProviderCollection();
            MvcRendererCollection = new RendererCollection();

            // if there is no section found, then create one
            if (ConfigSection == null)
            {
                //create a new section with the default settings
                ConfigSection = new ClientDependencySection();
            }

            //load the providers from the config, if there isn't config sections then add default providers
            LoadDefaultCompositeFileConfig(ConfigSection, http);
            LoadDefaultMvcFileConfig(ConfigSection);
            LoadDefaultFileRegConfig(ConfigSection);

            //set the defaults

            DefaultFileRegistrationProvider = FileRegistrationProviderCollection[ConfigSection.FileRegistrationElement.DefaultProvider];
            if (DefaultFileRegistrationProvider == null)
                throw new ProviderException("Unable to load default file registration provider");

            DefaultCompositeFileProcessingProvider = CompositeFileProcessingProviderCollection[ConfigSection.CompositeFileElement.DefaultProvider];
            if (DefaultCompositeFileProcessingProvider == null)
                throw new ProviderException("Unable to load default composite file provider");

            DefaultMvcRenderer = MvcRendererCollection[ConfigSection.MvcElement.DefaultRenderer];
            if (DefaultMvcRenderer == null)
                throw new ProviderException("Unable to load default mvc renderer");

            //need to check if it's an http path or a lambda path
            var path = ConfigSection.CompositeFileElement.CompositeFileHandlerPath;
            CompositeFileHandlerPath = path.StartsWith("~")
                ? VirtualPathUtility.ToAbsolute(ConfigSection.CompositeFileElement.CompositeFileHandlerPath, http.Request.ApplicationPath)
                : ConfigSection.CompositeFileElement.CompositeFileHandlerPath;

            Version = ConfigSection.Version;

            FileBasedDependencyExtensionList = ConfigSection.FileBasedDependencyExtensionList.ToList();

            if (string.IsNullOrEmpty(ConfigSection.LoggerType))
            {
                Logger = new NullLogger();
            }
            else
            {
                var t = Type.GetType(ConfigSection.LoggerType);
                if (!typeof(ILogger).IsAssignableFrom(t))
                {
                    throw new ArgumentException("The loggerType '" + ConfigSection.LoggerType + "' does not inherit from ClientDependency.Core.Logging.ILogger");
                }

                Logger = (ILogger)Activator.CreateInstance(t);
            }
        }
예제 #14
0
        internal void LoadProviders(ClientDependencySection section, HttpContextBase http)
        {
            ConfigSection = section;

            FileRegistrationProviderCollection        = new FileRegistrationProviderCollection();
            CompositeFileProcessingProviderCollection = new CompositeFileProcessingProviderCollection();
            MvcRendererCollection     = new RendererCollection();
            FileMapProviderCollection = new FileMapProviderCollection();

            // if there is no section found, then create one
            if (ConfigSection == null)
            {
                //create a new section with the default settings
                ConfigSection = new ClientDependencySection();
            }

            //need to check if it's an http path or a lambda path
            var path = ConfigSection.CompositeFileElement.CompositeFileHandlerPath;

            CompositeFileHandlerPath = path.StartsWith("~/")
                ? VirtualPathUtility.ToAbsolute(ConfigSection.CompositeFileElement.CompositeFileHandlerPath, http.Request.ApplicationPath)
                : ConfigSection.CompositeFileElement.CompositeFileHandlerPath;
            Version = ConfigSection.Version;
            FileBasedDependencyExtensionList = ConfigSection.FileBasedDependencyExtensionList.ToList();

            //load the providers from the config, if there isn't config sections then add default providers
            // and then load the defaults.

            LoadDefaultCompositeFileConfig(ConfigSection, http);

            DefaultCompositeFileProcessingProvider = CompositeFileProcessingProviderCollection[ConfigSection.CompositeFileElement.DefaultFileProcessingProvider];
            if (DefaultCompositeFileProcessingProvider == null)
            {
                throw new ProviderException("Unable to load default composite file provider");
            }

            LoadDefaultFileMapConfig(ConfigSection, http);

            DefaultFileMapProvider = FileMapProviderCollection[ConfigSection.CompositeFileElement.DefaultFileMapProvider];
            if (DefaultFileMapProvider == null)
            {
                throw new ProviderException("Unable to load default file map provider");
            }

            LoadDefaultMvcFileConfig(ConfigSection);

            DefaultMvcRenderer = MvcRendererCollection[ConfigSection.MvcElement.DefaultRenderer];
            if (DefaultMvcRenderer == null)
            {
                throw new ProviderException("Unable to load default mvc renderer");
            }

            LoadDefaultFileRegConfig(ConfigSection);

            DefaultFileRegistrationProvider = FileRegistrationProviderCollection[ConfigSection.FileRegistrationElement.DefaultProvider];
            if (DefaultFileRegistrationProvider == null)
            {
                throw new ProviderException("Unable to load default file registration provider");
            }

            if (string.IsNullOrEmpty(ConfigSection.LoggerType))
            {
                Logger = new NullLogger();
            }
            else
            {
                var t = Type.GetType(ConfigSection.LoggerType);
                if (!typeof(ILogger).IsAssignableFrom(t))
                {
                    throw new ArgumentException("The loggerType '" + ConfigSection.LoggerType + "' does not inherit from ClientDependency.Core.Logging.ILogger");
                }

                Logger = (ILogger)Activator.CreateInstance(t);
            }
        }