Exemplo n.º 1
0
        public static EditorConfiguration GetConfig()
        {
            EditorConfiguration editorConfig = null;

            if (
                (HttpRuntime.Cache["CEditorConfig"] != null) &&
                (HttpRuntime.Cache["CEditorConfig"] is EditorConfiguration)
                )
            {
                return((EditorConfiguration)HttpRuntime.Cache["CEditorConfig"]);
            }
            else
            {
                String configFileName = "CEditor.config";
                if (ConfigurationManager.AppSettings["CEditorConfigFileName"] != null)
                {
                    configFileName = ConfigurationManager.AppSettings["CEditorConfigFileName"];
                }

                if (!configFileName.StartsWith("~/"))
                {
                    configFileName = "~/" + configFileName;
                }

                String pathToConfigFile = HttpContext.Current.Server.MapPath(configFileName);

                XmlDocument configXml = new XmlDocument();
                configXml.Load(pathToConfigFile);
                editorConfig = new EditorConfiguration(configXml.DocumentElement);

                AggregateCacheDependency aggregateCacheDependency = new AggregateCacheDependency();
                aggregateCacheDependency.Add(new CacheDependency(pathToConfigFile));

                System.Web.HttpRuntime.Cache.Insert(
                    "CEditorConfig",
                    editorConfig,
                    aggregateCacheDependency,
                    DateTime.Now.AddYears(1),
                    TimeSpan.Zero,
                    System.Web.Caching.CacheItemPriority.Default,
                    null);

                return((EditorConfiguration)HttpRuntime.Cache["CEditorConfig"]);
            }

            //return editorConfig;
        }
Exemplo n.º 2
0
        private static void Initialize()
        {
            //try
            //{
            EditorConfiguration editorConfig = EditorConfiguration.GetConfig();

            if (
                (editorConfig.DefaultProvider == null) ||
                (editorConfig.Providers == null) ||
                (editorConfig.Providers.Count < 1)
                )
            {
                throw new ProviderException("You must specify a valid default provider.");
            }


            providerCollection = new EditorProviderCollection();

            ProvidersHelper.InstantiateProviders(
                editorConfig.Providers,
                providerCollection,
                typeof(EditorProvider));

            providerCollection.SetReadOnly();
            defaultProvider = providerCollection[editorConfig.DefaultProvider];

            //}
            //catch (Exception ex)
            //{
            //    initializationException = ex;
            //    isInitialized = true;
            //    throw ex;
            //}

            //isInitialized = true;
        }