Пример #1
0
        /// <summary>
        /// Add a new column module type to the app cache, should only be called from the CacheInitializer function.
        /// </summary>
        /// <param name="context"></param>
        public static void AddNew(HttpContextBase context, ColumnModuleType columnModuleType)
        {
            if (context.Application[APP_CACHE_KEY] == null)
            {
                context.Application[APP_CACHE_KEY] = new List <ColumnModuleType>();
            }

            ((List <ColumnModuleType>)context.Application[APP_CACHE_KEY]).Add(columnModuleType);
        }
Пример #2
0
        /// <summary>
        /// Create a new column module type based on the
        /// </summary>
        /// <param name="context"></param>
        /// <param name="developmentName"></param>
        public ColumnModuleType(ControllerContext controllerContext, HttpContextBase context, string developmentName) : this()
        {
            List <ColumnModuleType> ColumnModuleTypeList = GetList(controllerContext, context);

            ColumnModuleType ColumnModuleType = ColumnModuleTypeList.Where(e => e.ColumnModuleModel.ColumnModule.ModuleTypeName.Equals(developmentName)).FirstOrDefault();

            DisplayName        = ColumnModuleType.DisplayDescription;
            DisplayDescription = ColumnModuleType.DisplayDescription;
            Categories         = ColumnModuleType.Categories;
            ColumnModuleModel  = ColumnModuleType.ColumnModuleModel;
        }
Пример #3
0
        /// <summary>
        /// Initialize needed content into the application cache.
        /// </summary>
        /// <param name="context"></param>
        public static void InitializeEditorCache(ControllerContext controllerContext, HttpContextBase context)
        {
            Dictionary<string, string> DefaultTokenAppSettings = DefaultTokenValues.GetDictionary(controllerContext, context);

            HashSet<string> Categories = new HashSet<string>();

            //add template specific modules
            List<string> FilePaths = Directory.GetFiles(context.Server.MapPath(String.Format(@"~\Templates\{0}\Views\ModuleViews\", ChimeraTemplate.TemplateName))).ToList();

            //add common modules as well
            FilePaths.AddRange(Directory.GetFiles(context.Server.MapPath(@"~\Views\PartialViews\CommonModuleViews\")).ToList());

            foreach (var File in FilePaths)
            {
                ColumnModuleType ColumnModuleType = new ColumnModuleType();

                List<string> CategoryList = new List<string>();

                ColumnModuleType.ColumnModuleModel.ColumnModule.ModuleTypeName = System.IO.Path.GetFileNameWithoutExtension(File);

                System.IO.StreamReader sreader = new System.IO.StreamReader(File);

                string Line = string.Empty;

                while ((Line = sreader.ReadLine()) != null)
                {
                    Line.Trim();

                    foreach (var Token in DefaultTokenAppSettings)
                    {
                        Line = Line.Replace(Token.Key, Token.Value);
                    }

                    if (Line.Contains("[#Display_Name#]"))
                    {
                        ColumnModuleType.DisplayName = GetValueFromModuleViewLine(Line);
                    }
                    else if (Line.Contains("[#Display_Description#]"))
                    {
                        ColumnModuleType.DisplayDescription = GetValueFromModuleViewLine(Line);
                    }
                    else if (Line.Contains("[#Parent_Categories#]"))
                    {
                        ColumnModuleType.Categories = new HashSet<string>(GetValueFromModuleViewLine(Line).Split(',').Select(category => category.Trim()));
                    }
                    else if (Line.Contains("[#AdditionalClassNameList#]"))
                    {
                        ColumnModuleType.ColumnModuleModel.ColumnModule.AdditionalClassNames = GetValueFromModuleViewLine(Line);
                    }
                    else if (Line.Contains("[#Default_Value_"))
                    {
                        ColumnModuleType.ColumnModuleModel.ColumnModule.ChildrenValueDictionary.Add(GetDefaultValueKeyFromModuleViewLine(Line), new Chimera.Entities.Page.Module.ColumnModuleChild(GetValueFromModuleViewLine(Line)));
                    }
                    else if (Line.Contains("[#Default_Inactive_"))
                    {
                        ColumnModuleType.ColumnModuleModel.ColumnModule.ChildrenValueDictionary[GetInactiveKeyFromModuleViewLine(Line)].Active = false;
                    }
                }

                sreader.Close();

                foreach (var Category in ColumnModuleType.Categories)
                {
                    ColumnModuleTypeCategory.AddNew(context, Category);
                }

                ColumnModuleType.AddNew(context, ColumnModuleType);
            }
        }
Пример #4
0
        /// <summary>
        /// Add a new column module type to the app cache, should only be called from the CacheInitializer function.
        /// </summary>
        /// <param name="context"></param>
        public static void AddNew(HttpContextBase context, ColumnModuleType columnModuleType)
        {
            if (context.Application[APP_CACHE_KEY] == null)
            {
                context.Application[APP_CACHE_KEY] = new List<ColumnModuleType>();
            }

            ((List<ColumnModuleType>)context.Application[APP_CACHE_KEY]).Add(columnModuleType);
        }
Пример #5
0
        /// <summary>
        /// Initialize needed content into the application cache.
        /// </summary>
        /// <param name="context"></param>
        public static void InitializeEditorCache(ControllerContext controllerContext, HttpContextBase context)
        {
            Dictionary <string, string> DefaultTokenAppSettings = DefaultTokenValues.GetDictionary(controllerContext, context);

            HashSet <string> Categories = new HashSet <string>();

            //add template specific modules
            List <string> FilePaths = Directory.GetFiles(context.Server.MapPath(String.Format(@"~\Templates\{0}\Views\ModuleViews\", ChimeraTemplate.TemplateName))).ToList();

            //add common modules as well
            FilePaths.AddRange(Directory.GetFiles(context.Server.MapPath(@"~\Views\PartialViews\CommonModuleViews\")).ToList());

            foreach (var File in FilePaths)
            {
                ColumnModuleType ColumnModuleType = new ColumnModuleType();

                List <string> CategoryList = new List <string>();

                ColumnModuleType.ColumnModuleModel.ColumnModule.ModuleTypeName = System.IO.Path.GetFileNameWithoutExtension(File);

                System.IO.StreamReader sreader = new System.IO.StreamReader(File);

                string Line = string.Empty;

                while ((Line = sreader.ReadLine()) != null)
                {
                    Line.Trim();

                    foreach (var Token in DefaultTokenAppSettings)
                    {
                        Line = Line.Replace(Token.Key, Token.Value);
                    }

                    if (Line.Contains("[#Display_Name#]"))
                    {
                        ColumnModuleType.DisplayName = GetValueFromModuleViewLine(Line);
                    }
                    else if (Line.Contains("[#Display_Description#]"))
                    {
                        ColumnModuleType.DisplayDescription = GetValueFromModuleViewLine(Line);
                    }
                    else if (Line.Contains("[#Parent_Categories#]"))
                    {
                        ColumnModuleType.Categories = new HashSet <string>(GetValueFromModuleViewLine(Line).Split(',').Select(category => category.Trim()));
                    }
                    else if (Line.Contains("[#AdditionalClassNameList#]"))
                    {
                        ColumnModuleType.ColumnModuleModel.ColumnModule.AdditionalClassNames = GetValueFromModuleViewLine(Line);
                    }
                    else if (Line.Contains("[#Default_Value_"))
                    {
                        ColumnModuleType.ColumnModuleModel.ColumnModule.ChildrenValueDictionary.Add(GetDefaultValueKeyFromModuleViewLine(Line), new Chimera.Entities.Page.Module.ColumnModuleChild(GetValueFromModuleViewLine(Line)));
                    }
                    else if (Line.Contains("[#Default_Inactive_"))
                    {
                        ColumnModuleType.ColumnModuleModel.ColumnModule.ChildrenValueDictionary[GetInactiveKeyFromModuleViewLine(Line)].Active = false;
                    }
                }

                sreader.Close();

                foreach (var Category in ColumnModuleType.Categories)
                {
                    ColumnModuleTypeCategory.AddNew(context, Category);
                }

                ColumnModuleType.AddNew(context, ColumnModuleType);
            }
        }