Esempio n. 1
0
 public Sample QueryParent(Sample parent)
 {
     return this.QueryParent(parent.Parent);
 }
Esempio n. 2
0
 public IEnumerable<Sample> QueryChildren(Sample parent)
 {
     return QueryChildren(parent.Parent);
 }
Esempio n. 3
0
 public bool RemoveChild(Sample child)
 {
     child.Parent = "";
     return child.Update();
 }
Esempio n. 4
0
 public bool AddChild(Sample child)
 {
     child.Parent = this.Parent + "." +  this.Name;
     return child.Update();
 }
Esempio n. 5
0
        public void ParseTemp(String filename)
        {
            LinkedList<string>  current_parent = new LinkedList<string>();
            int level = 0;
            Dictionary<string, List<string>> parents = new Dictionary<string, List<string>>();
            List<Sample> samples = new List<Sample>();
            Sample  s = null;
            bool new_level = false;
            using (FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read ))
            {
                using (BufferedStream bs = new BufferedStream(fs))
                {
                    using(StreamReader sr = new StreamReader(bs))
                    {
                        String line = sr.ReadLine();
                        while(line != null){
                            if(line.StartsWith("4-"))
                            {
                                if(s != null)
                                {
                                    samples.Add(s);
                                }
                                s = new Sample();
                                //Is Tree Parent

                                line = sr.ReadLine();
                                if(line.StartsWith("3-"))
                                {
                                    line =  line.Replace("3- ", "");
                                    if(String.IsNullOrWhiteSpace(line))
                                    {
                                        //First of tree pivot
                                        line = sr.ReadLine();
                                        line =  line.Replace("3- ", "");
                                        s.Name = line;
                                        s.Text = line;
                                        s.Description = line;
                                        if(current_parent.Count > 0){
                                            //s.Parent = current_parent.First.Value;
                                            s.Parent = Parents( current_parent);
                                        }else{
                                            s.Parent = "";
                                        }
                                        samples.Add(s);
                                        s = null;
                                        current_parent.AddFirst(line);
                                    }else{
                                        current_parent.RemoveFirst();
                                        s.Name = line;
                                        s.Text = line;
                                        s.Description = line;
                                        //s.Parent = Parents( current_parent.First.Value;
                                        s.Parent = Parents( current_parent);
                                        samples.Add(s);
                                        s = null;
                                        current_parent.AddFirst(line);
                                    }
                                }
                            }
                            else if(line.StartsWith("3-") )
                            {
                                if(s != null)
                                {
                                    samples.Add(s);
                                }
                                s = new Sample();
                                line =  line.Replace("3- ", "");
                                if(String.IsNullOrWhiteSpace(line))
                                {
                                    //First of tree pivot
                                    line = sr.ReadLine();
                                    while(!String.IsNullOrWhiteSpace(line))
                                    {
                                        if(line.StartsWith("3-"))
                                        {
                                            line = line.Replace("3-", "");
                                            break;
                                        }
                                        if(line.StartsWith("2-"))
                                        {
                                            line = line.Replace("2-", "");
                                            break;
                                        }
                                        line = sr.ReadLine();
                                    }
                                }
                                line = line.Trim();
                                s.Name = line;
                                s.Description = line;
                                //s.Parent = current_parent.First.Value;
                                s.Parent = Parents( current_parent);
                                sr.ReadLine();
                                sr.ReadLine();
                                sr.ReadLine();
                                sr.ReadLine();
                            }
                            else if(line.StartsWith("2-"))
                            {
                                if(s != null)
                                {
                                    samples.Add(s);
                                }
                                s = new Sample();
                                line =  line.Replace("2- ", "");
                                if(String.IsNullOrWhiteSpace(line))
                                {
                                    //First of tree pivot
                                    line = sr.ReadLine();
                                    while(!String.IsNullOrWhiteSpace(line))
                                    {
                                        if(line.StartsWith("3-"))
                                        {
                                            line = line.Replace("3-", "");
                                            break;
                                        }
                                        if(line.StartsWith("2-"))
                                        {
                                            line = line.Replace("2-", "");
                                            break;
                                        }
                                        line = sr.ReadLine();
                                    }
                                }
                                line = line.Trim();
                                s.Name = line;
                                s.Description = line;
                                //s.Parent = current_parent.First.Value;
                                s.Parent = Parents( current_parent);
                                sr.ReadLine();
                                sr.ReadLine();
                                sr.ReadLine();
                                sr.ReadLine();

                            }else{
                                if(s != null)
                                {
                                    s.Text += line;
                                    s.Text += System.Environment.NewLine;
                                }
                            }
                            line = sr.ReadLine();
                        }
                    }
                }
            }
            if(s != null)
            {
                samples.Add(s);
            }
            foreach(Sample ss in samples)
            {
                ss.Update(true);
            }
            parents.ToString();
        }
Esempio n. 6
0
 public bool AddChild(Sample child)
 {
     child.Parent = this.Parent + "." + this.Name;
     return(child.Update());
 }