Esempio n. 1
0
        public bool Add(string[] stack, object accepts)
        {
            if (IsBaked)
            {
                throw new Exception("Cannot mould a baked tree");
            }

            if (stack.Length == 0)
            {
                return(false);
            }

            ObjectTree parent = this;

            int counter = 0;

            do
            {
                ObjectTree i = parent.MatchKey(stack[counter++]);
                if (null == i)
                {
                    return(AddStackToObjectTree(stack, null, parent, --counter, accepts));
                }
                if (null == i.child && counter < stack.Length)
                {
                    return(AddStackToObjectTree(stack, i, null, counter, accepts));
                }
                if (counter == stack.Length)
                {
                    return(AddStackToObjectTree(stack, i, null, counter, accepts));
                }
                parent = i.child;
            }while (true);
        }
Esempio n. 2
0
        ObjectTree GetObjectTreeAt(string[] stack)
        {
            if (stack == null)
            {
                return(null);
            }

            if (stack.Length == 0)
            {
                return(this);
            }

            ObjectTree parent  = this;
            int        counter = 0;

            do
            {
                ObjectTree i = parent.MatchKey(stack[counter++]);
                if (null == i)
                {
                    return(null);
                }
                if (null == i.child && counter < stack.Length)
                {
                    return(null);
                }
                if (counter == stack.Length)
                {
                    return(i);
                }
                parent = i.child;
            }while (true);
        }