Ejemplo n.º 1
0
        private LinkedBuilderContext SwapParent(LinkedBuilderContext newParent)
        {
            if (this.parent == null)
                this.parser.DropContext(this);
            else
                this.parent.childs.Remove(this);

            this.parent = newParent;
            newParent.Add(this);

            return newParent;
        }
Ejemplo n.º 2
0
 private LinkedListNode<LinkedBuilderContext> AddByCommand(InsertCommand command, 
     LinkedBuilderContext context)
 {
     return command == InsertCommand.First ? this.childs.AddFirst(context) : this.childs.AddLast(context);
 }
Ejemplo n.º 3
0
 private LinkedListNode<LinkedBuilderContext> AddByNode(LinkedListNode<LinkedBuilderContext> node,
     LinkedBuilderContext context)
 {
     return this.childs.AddAfter(node, context);
 }
Ejemplo n.º 4
0
        public INodeBuilderContext WrapContext(INodeBuilder wrapper)
        {
            this.TranslateOut();
            var preParent = this.parser.ActiveContext;
            var wrapperContext = new LinkedBuilderContext(parser, preParent, wrapper);
            preParent.Add(wrapperContext);

            return this.SwapParent(wrapperContext);
        }
Ejemplo n.º 5
0
        private LinkedBuilderContext Add(LinkedBuilderContext context)
        {
            this.preSiblingPointer =
                this.insertCommand.HasValue
                    ? this.AddByCommand(this.insertCommand.Value, context)
                    : this.AddByNode(preSiblingPointer, context);

            return context;
        }
Ejemplo n.º 6
0
        public INodeBuilderContext ChildContext(INodeBuilder child)
        {
            var context = new LinkedBuilderContext(parser, this, child);
            this.parser.SetActiveContext(context);

            return this.Add(context);
        }
Ejemplo n.º 7
0
        public INodeBuilderContext SiblingContext(INodeBuilder sibling)
        {
            var context = new LinkedBuilderContext(parser, this.parent, sibling);
            if (this.parent != null)
                this.parent.Add(context);
            else
                this.parser.AddActiveContext(context);

            return context;
        }
Ejemplo n.º 8
0
        public LinkedBuilderContext(NodeTreeParser parser, LinkedBuilderContext parent, INodeBuilder builder)
        {
            this.parser = parser;
            this.parent = parent;
            this.builder = builder;
            this.childs = new LinkedList<LinkedBuilderContext>();

            this.insertCommand = InsertCommand.Last;

            this.contextId = _lastId++;
        }
Ejemplo n.º 9
0
 internal void SetActiveContext(LinkedBuilderContext context, bool contextless)
 {
     this.activeContext =
         context ??
         (contextless ? this.AddNewContext() : this.NewContext());
 }
Ejemplo n.º 10
0
 internal void SetActiveContext(LinkedBuilderContext context)
 {
     SetActiveContext(context, false);
 }
Ejemplo n.º 11
0
 internal void DropContext(LinkedBuilderContext context)
 {
     this.contexts.Remove(context);
 }
Ejemplo n.º 12
0
 internal void AddActiveContext(LinkedBuilderContext context)
 {
     lock (contexts)
     {
         this.SetActiveContext(context);
         this.contexts.Add(activeContext);
     }
 }