Ejemplo n.º 1
0
        private ConfigEntry TraverseParents(Queue <string> keyqueue)
        {
            //ToDo: Check function for correctness
            if (keyqueue.Count == 0)
            {
                return(this);
            }

            //Check current childrens for given key
            var key = keyqueue.Dequeue();

            foreach (var it in this.Children)
            {
                if (it.Name == key)
                {
                    var traverseResult = it.TraverseParents(keyqueue);
                    if (traverseResult != null)
                    {
                        //Return the traverse result as valid entry
                        return(traverseResult);
                    }
                    else
                    {
                        //we had our match ... we will not encounter another one in here
                        break;
                    }
                }
            }
            //Current children do not contain key so reenqueue current key
            keyqueue.Enqueue(key);


            //Check if this has a parent class
            if (this.Parent != null)
            {
                //Search for parent class
                var         cur    = this.ConfigEntryParent;
                ConfigEntry parent = null;
                do
                {
                    foreach (var it in cur.Children)
                    {
                        if (it.Name == this.Parent)
                        {
                            //Parent class was found
                            parent = it;
                            break;
                        }
                    }
                    if (parent != null)
                    {
                        break;
                    }
                    else
                    {
                        cur = cur.ConfigEntryParent;
                    }
                } while (cur != null);
                if (parent != null)
                {
                    //Correct parent was found, search in there for the key
                    return(parent.TraverseParents(keyqueue));
                }
            }
            //Field is unknown
            return(null);
        }
Ejemplo n.º 2
0
 public ConfigEntry(ConfigEntry parent)
 {
     this.Children = new ObservableCollection <ConfigEntry>();
     parent?.Children.Add(this);
     this._ConfigEntryParent = new WeakReference <ConfigEntry>(parent);
 }
Ejemplo n.º 3
0
        void FIELD(ConfigEntry parent)
        {
            ConfigEntry cur = Root == null ? null : new ConfigEntry(parent); if (Root != null)

            {
                cur.IsField = true;
            }

            Expect(5);
            if (Root != null)
            {
                cur.FullStart = cur.NameStart = doc.ContentStart.GetPointerFromCharOffset(t.charPos);
                cur.NameEnd   = doc.ContentStart.GetPointerFromCharOffset(t.charPos + t.val.Length);
            }

            if (la.kind == 11)
            {
                Get();
                Expect(12);
            }
            Expect(13);
            if (la.kind == 8)
            {
                ARRAY();
                if (Root != null)
                {
                    cur.ContentStart = doc.ContentStart.GetPointerFromCharOffset(t.charPos);
                    cur.ContentEnd   = doc.ContentStart.GetPointerFromCharOffset(t.charPos + t.val.Length);
                }
            }
            else if (la.kind == 1 || la.kind == 2)
            {
                SCALAR();
                if (Root != null)
                {
                    cur.ContentStart = doc.ContentStart.GetPointerFromCharOffset(t.charPos);
                    cur.ContentEnd   = doc.ContentStart.GetPointerFromCharOffset(t.charPos + t.val.Length);
                }
            }
            else if (la.kind == 3 || la.kind == 4)
            {
                STRING();
                if (Root != null)
                {
                    cur.ContentStart = doc.ContentStart.GetPointerFromCharOffset(t.charPos);
                    cur.ContentEnd   = doc.ContentStart.GetPointerFromCharOffset(t.charPos + t.val.Length);
                }
            }
            else if (la.kind == 14 || la.kind == 15)
            {
                BOOLEAN();
                if (Root != null)
                {
                    cur.ContentStart = doc.ContentStart.GetPointerFromCharOffset(t.charPos);
                    cur.ContentEnd   = doc.ContentStart.GetPointerFromCharOffset(t.charPos + t.val.Length);
                }
            }
            else if (StartOf(1))
            {
                Get();
                if (Root != null)
                {
                    cur.ContentStart = doc.ContentStart.GetPointerFromCharOffset(t.charPos);
                }
                while (StartOf(2))
                {
                    Get();
                }
                if (Root != null)
                {
                    cur.ContentEnd = doc.ContentStart.GetPointerFromCharOffset(t.charPos + t.val.Length);
                }
            }
            else
            {
                SynErr(18);
            }
            Expect(10);
            if (Root != null)
            {
                cur.FullEnd = doc.ContentStart.GetPointerFromCharOffset(t.charPos + t.val.Length);
            }
        }