public static EditorConfiguration GetConfig()
        {
            EditorConfiguration editorConfig = null;

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

                }

                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(
                    "mojoEditorConfig",
                    editorConfig,
                    aggregateCacheDependency,
                    DateTime.Now.AddYears(1),
                    TimeSpan.Zero,
                    System.Web.Caching.CacheItemPriority.Default,
                    null);

                return (EditorConfiguration)HttpRuntime.Cache["mojoEditorConfig"];

            }

            //return editorConfig;
        }
        public static EditorConfiguration GetConfig()
        {
            EditorConfiguration editorConfig = null;

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

                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(
                    "mojoEditorConfig",
                    editorConfig,
                    aggregateCacheDependency,
                    DateTime.Now.AddYears(1),
                    TimeSpan.Zero,
                    System.Web.Caching.CacheItemPriority.Default,
                    null);

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

            //return editorConfig;
        }
Exemple #3
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;
        }