Пример #1
0
        private static RedirectConfig GetConfig()
        {
            RedirectConfig config = null;

            //if (useCache)
            //    try
            //    {
            //        config = DataCache.GetCache<RedirectConfig>(RedirectConfigCacheKey);
            //    }
            //    catch (Exception e)
            //    {
            //        /* do nothing */
            //    }

            // if there are no mappings, the use of this module is pointless
            // so we'll assume something went wrong reading the file in that case
            if (config == null || config.Mappings == null || config.Mappings.Count == 0)
            {
                lock (getConfigLockObject)
                {
                    var file = Common.RedirectConfigFile();
                    config = FromFile(file);
                    // set the id's if they're empty. This comes in handy for backwards compatibility
                    if (config.Mappings.Any(m => String.IsNullOrEmpty(m.Id)))
                    {
                        foreach (var mapping in config.Mappings.Where(m => String.IsNullOrEmpty(m.Id)))
                        {
                            mapping.Id = Guid.NewGuid().ToString();
                        }
                        config.ToFile(file);
                    }
                    //DataCache.SetCache(RedirectConfigCacheKey, config, new DNNCacheDependency(file));
                }
            }
            return(config);
        }
Пример #2
0
        public static void CreateFile(string filename)
        {
            var emptyConfig = new RedirectConfig();

            emptyConfig.ToFile(filename);
        }