Example #1
0
        private CalendarItem getCalendarItem(string clndr_data)
        {
            CalendarItem returnvalue;

            System.Collections.Generic.Stack <CalendarItem> stack1 = new System.Collections.Generic.Stack <CalendarItem>();


            long level = 0;

            long[] currentlevel       = new long[20];
            System.IO.StringReader sr = new System.IO.StringReader(clndr_data.Replace("(", "\n(").Replace(")", "\n)").Replace(" ", ""));
            string aline = sr.ReadLine();

            aline = sr.ReadLine();
            System.IO.StringWriter sw = new System.IO.StringWriter();
            System.Collections.Generic.List <CalendarItem> adam = new List <CalendarItem>();
            while (aline != null)
            {
                if (aline.StartsWith("("))
                {
                    string       name = aline.Replace("(", "");
                    CalendarItem pci  = stack1.Count > 0? stack1.Peek() as CalendarItem:null;
                    CalendarItem ci   = new CalendarItem(level++, name, pci);
                    adam.Add(ci);
                    if (stack1.Count > 0)
                    {
                        stack1.Peek().addItem(ci);
                    }
                    stack1.Push(ci);
                    sw.WriteLine(ci.Name + "," + level.ToString() + "," + aline);
                }
                else if (aline == ")")
                {
                    if (stack1.Count > 1)
                    {
                        stack1.Pop();
                    }
                }


                aline = sr.ReadLine();
            }
            returnvalue = stack1.Pop();
            returnvalue.Adam.AddRange(adam);
            return(returnvalue);
        }
Example #2
0
 public void addItem(CalendarItem item)
 {
     children.Add(item);
 }
Example #3
0
 public CalendarItem(long uniqueid, string name, CalendarItem parent)
 {
     this.name     = name;
     this.uniqueid = uniqueid;
     this.parent   = parent;
 }