示例#1
0
        /// <summary>
        /// Parses the specified value.
        /// </summary>
        /// <param name="s">The value.</param>
        /// <returns>The checklist collection.</returns>
        public static ChecklistCollection Parse(string s)
        {
            var collection = new ChecklistCollection();

            var url = new UrlString(s);

            foreach (string parameter in url.Parameters)
            {
                if (!parameter.StartsWith(ParameterPrefix))
                {
                    continue;
                }

                var cl = new ChecklistDefinition {
                    Field = parameter.Replace(ParameterPrefix, string.Empty)
                };

                foreach (string value in new ListString(url.Parameters[parameter]))
                {
                    cl.Checkboxes.Add(new ChecklistItem {
                        Value = value
                    });
                }

                collection.Add(cl);
            }

            return(collection);
        }
示例#2
0
        /// <summary>
        /// Gets the checklists.
        /// </summary>
        /// <returns>Gets the checklist definitions.</returns>
        public virtual List <ChecklistDefinition> GetChecklistDefinitions()
        {
            var checklists = new ChecklistCollection();

            if (this.CatalogItem == null)
            {
                return(checklists);
            }

            var checklistsRoot = this.CatalogItem.Children["Checklists"];

            if (checklistsRoot == null || checklistsRoot.Children.Count <= 0)
            {
                return(checklists);
            }

            foreach (Item checklistItem in checklistsRoot.Children)
            {
                var checkboxes     = new Collection <ChecklistItem>();
                var checkboxesRoot = this.Database.GetItem(checklistItem["Root"]);
                if (checkboxesRoot != null)
                {
                    foreach (Item item in checkboxesRoot.Children)
                    {
                        checkboxes.Add(new ChecklistItem {
                            Text = item["Title"], Value = item.ID.ToString()
                        });
                    }
                }

                var checklist = new ChecklistDefinition {
                    Header = checklistItem["Title"], Field = checklistItem["Field"], Checkboxes = checkboxes
                };
                checklists.Add(checklist);
            }

            return(checklists);
        }