示例#1
0
        public static ValidationResult Validate(string value, ValidationContext vc)
        {
            string error = string.Empty;
            List <ControllerAction> caList = ControllerHelper.GetAllControllersActions();

            foreach (ControllerAction ca in caList)
            {
                if (value.Split(new string[] { ca.ControllerActionID }, System.StringSplitOptions.None).Length > 2)
                {
                    error += ca.ControllerActionID + ", ";
                }
            }
            error = error.TrimEnd(' ').TrimEnd(',');
            if (error.IsEmptyOrWhiteSpace())
            {
                return(ValidationResult.Success);
            }
            else
            {
                return(new ValidationResult(Resources.Strings.ModulesInsertedMoreThanOnce + " " + error));
            }
        }
示例#2
0
        public static List <SelectListItem> GetCmsModules(bool includeContentModule)
        {
            List <SelectListItem> result = new List <SelectListItem>();

            //Adds all the modules defined in ModuleConnectors
            //These modules are dynamically built and their behaviour is editable at runtime.
            //E.g. Shared contents or Media Galleries
            foreach (IModuleConnector moduleConnector in ModuleConnectorsHelper.GetModuleConnectors())
            {
                result.AddRange(moduleConnector.GetSelectItemList());
            }

            //Adds the FrontEnd modules
            //These modules are pre-built and their behaviour is not editable at runtime
            //E.g. FrontEndContactController or FrontEndBreadCrumbsController
            SelectListItem sli;

            foreach (ControllerAction ca in ControllerHelper.GetAllControllersActions())
            {
                sli       = new SelectListItem();
                sli.Text  = ca.ControllerActionName;
                sli.Value = ca.ControllerActionID;
                result.Add(sli);
            }

            //Adds the content module only if requested
            if (includeContentModule)
            {
                result.Insert(0, (new SelectListItem {
                    Text = "Content", Value = "{$Content}"
                }));
            }

            //Returns the result in alphabetical order
            return(result.OrderBy(i => i.Text).ToList());
        }