public void Process(Instruction instruction)
        {
            if (recording)
            {
                if (instruction.InstructionType == InstructionType.StartMember)
                {
                    depth++;
                }

                if (instruction.InstructionType == InstructionType.EndMember)
                {
                    depth--;
                    if (depth == 0)
                    {
                        recording = false;
                        var loaded = assembler.Load(new ReadOnlyCollection<Instruction>(nodeList), this.objectAssembler.TypeSource);
                        objectAssembler.OverrideInstance(loaded);
                        objectAssembler.Process(instruction);
                    }
                }

                if (depth > 0)
                {
                    nodeList.Add(instruction);
                }
            }
            else
            {
                if (instruction.InstructionType == InstructionType.StartMember && !instruction.Member.IsDirective)
                {
                    var hasAssembler = TryGetDeferredAssembler((MutableMember) instruction.Member, out assembler);
                    if (hasAssembler)
                    {
                        recording = true;
                        nodeList = new Collection<Instruction>();
                        depth++;
                        objectAssembler.Process(instruction);
                    }
                }

                if (!recording)
                {
                    objectAssembler.Process(instruction);
                }
            }
        }
Ejemplo n.º 2
0
 private static bool IsLeading(Instruction current)
 {
     return current.InstructionType == InstructionType.StartMember || current.InstructionType == InstructionType.StartObject ||
            current.InstructionType == InstructionType.GetObject;
 }
Ejemplo n.º 3
0
 private static bool IsTrailing(Instruction instruction)
 {
     return instruction.InstructionType == InstructionType.EndMember || instruction.InstructionType == InstructionType.EndObject;
 }
        private static NodeType GetNodeType(Instruction current)
        {
            switch (current.InstructionType)
            {
                case InstructionType.StartMember:
                case InstructionType.EndMember:
                    return NodeType.Member;

                case InstructionType.StartObject:
                case InstructionType.EndObject:
                    return NodeType.Object;

                case InstructionType.GetObject:
                    return NodeType.GetObject;

                case InstructionType.NamespaceDeclaration:
                    return NodeType.NamespaceDeclaration;

                case InstructionType.Value:
                    return NodeType.Value;

                case InstructionType.None:
                    return NodeType.Root;
            }

            throw new InvalidOperationException("Cannot translate the type");
        }
 public void Process(Instruction node)
 {
     objectAssembler.Process(node);
 }
Ejemplo n.º 6
0
 public bool Equals(Instruction other)
 {
     return instructionType == other.instructionType && Equals(data, other.data) && internalNodeType == other.internalNodeType;
 }