Ejemplo n.º 1
0
        public Checklist(string input) : this()
        {
            Stack <ContainerRow> containers = new Stack <ContainerRow>();

            containers.Push(m_rootContainer = new RootContainer());
            using (StringReader sr = new StringReader(input))
            {
                string szItem = null;
                while ((szItem = sr.ReadLine()) != null)
                {
                    if (String.IsNullOrWhiteSpace(szItem))
                    {
                        continue;
                    }

                    ChecklistRow checklistRow = ChecklistRow.ParseRowType(szItem);

                    if (checklistRow == null)
                    {
                        continue;
                    }

                    if (checklistRow is SkinRow)
                    {
                        // TODO: apply the skin, no actual content in a skin row.
                        continue;
                    }

                    if (checklistRow is RootContainer)
                    {
                        throw new InvalidDataException("Can only have one root container in Checklist");
                    }


                    ContainerRow container = checklistRow as ContainerRow;
                    if (container != null)
                    {
                        int level = container.Level;

                        while (containers.Count > 0 && containers.Peek().Level >= level)
                        {
                            containers.Pop();
                        }

                        if (containers.Count == 0)
                        {
                            throw new InvalidDataException("No root container found in checklist");
                        }

                        containers.Peek().AddItem(container);
                        containers.Push(container);
                    }
                    else
                    {
                        containers.Peek().AddItem(checklistRow);
                    }
                }
            }
        }
Ejemplo n.º 2
0
 public void AddItem(ChecklistRow ckl)
 {
     m_containedItems.Add(ckl);
 }