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); } } }
private static bool IsLeading(Instruction current) { return current.InstructionType == InstructionType.StartMember || current.InstructionType == InstructionType.StartObject || current.InstructionType == InstructionType.GetObject; }
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); }
public bool Equals(Instruction other) { return instructionType == other.instructionType && Equals(data, other.data) && internalNodeType == other.internalNodeType; }