Esempio n. 1
0
        public VyattaConfigObject AddObject(string Parent)
        {
            string[] Split = Parent.Split(new char[] { ':' }, 2);

            foreach (var ChildNode in Children)
            {
                if (ChildNode.GetAttributeString() == Split[0])
                {
                    if (Split.Length == 2)
                    {
                        return(ChildNode.AddObject(Split[1]));
                    }
                    else
                    {
                        return(ChildNode as VyattaConfigObject);
                    }
                }
            }

            var NewNode = new VyattaConfigObject(new VyattaConfigAttribute(Split[0]));

            Children.Add(NewNode);

            if (Split.Length == 2)
            {
                return(NewNode.AddObject(Split[1]));
            }
            else
            {
                return(NewNode);
            }
        }
Esempio n. 2
0
        public VyattaConfigAttribute AddAttribute(string Parent)
        {
            string[] Split = Parent.Split(new char[] { ':' }, 2);

            foreach (var ChildNode in Children)
            {
                if (ChildNode.GetAttributeString() == Split[0])
                {
                    return(ChildNode.AddAttribute(Split[1]));
                }
            }

            if (Split.Length == 2)
            {
                var NewNode = new VyattaConfigObject(new VyattaConfigAttribute(Split[0]));

                foreach (var Child in Children)
                {
                    //If we've already got that attribute
                    if (Child.GetName() == Split[1].Split(new char[] { ' ' }, 2)[0])
                    {
                        Children.Remove(Child);
                        break;
                    }
                }

                Children.Add(NewNode);
                return(NewNode.AddAttribute(Split[1]));
            }
            else
            {
                var NewNode = new VyattaConfigAttribute(Split[0]);

                foreach (var Child in Children)
                {
                    //If we've already got that attribute
                    if (Child.GetName() == Split[0].Split(new char[] { ' ' }, 2)[0])
                    {
                        Children.Remove(Child);
                        break;
                    }
                }

                Children.Add(NewNode);
                return(NewNode);
            }
        }
Esempio n. 3
0
        public void Delete(string Path)
        {
            string[] Split = Path.Split(new char[] { ':' }, 2);

            foreach (var ChildNode in Children)
            {
                if (ChildNode.GetAttributeString() == Split[0])
                {
                    if (Split.Length == 1)
                    {
                        Children.Remove(ChildNode);
                        return;
                    }

                    ChildNode.Delete(Split[1]);
                    return;
                }
            }
        }