コード例 #1
0
        private void AssignCollection(NodeAssignment assignment)
        {
            var firstNode   = assignment.Assignment.Values.First();
            var mutableUnit = new MutablePipelineUnit(firstNode, firstNode.Instance);

            pipeline.Handle(assignment.Instance, assignment.Assignment.Member, mutableUnit, null, null);

            if (mutableUnit.Handled)
            {
                return;
            }

            var parent = assignment.Assignment.Member.GetValue(assignment.Instance);

            IEnumerable <object> children;
            var mutableValue = mutableUnit.Value as IEnumerable <object>;

            if (mutableValue != null)
            {
                children = mutableValue;
            }
            else
            {
                children = from n in assignment.Assignment.Values select n.Instance;
            }

            foreach (var child in children)
            {
                Collection.UniversalAdd(parent, child);
            }
        }
コード例 #2
0
ファイル: NodeAssembler.cs プロジェクト: walac/NUIPreview
 protected void ApplyAssignments(ConstructionNode node, INodeToObjectBuilder builder, BuilderContext context)
 {
     foreach (var assignment in node.Assignments)
     {
         var nodeAssignment = new NodeAssignment(assignment, node.Instance);
         AssigmentApplier.ExecuteAssignment(nodeAssignment, builder, context);
     }
 }
コード例 #3
0
 public void ExecuteAssignment(NodeAssignment assignment, INodeToObjectBuilder builder, BuilderContext context)
 {
     if (!assignment.Assignment.Member.MemberType.IsCollection())
     {
         AssignSingleValue(assignment, builder, context);
     }
     else
     {
         AssignCollection(assignment);
     }
 }
コード例 #4
0
        private void AssignSingleValue(NodeAssignment assignment, INodeToObjectBuilder builder, BuilderContext context)
        {
            var children = assignment.Assignment.Values.ToList();

            if (children.Count > 1)
            {
                throw new InvalidOperationException($"Cannot assign multiple values to a the property {assignment}");
            }

            var nodeBeingAssigned = children.First();

            var value = nodeBeingAssigned.Instance;

            var assign = new Assignment(assignment.Instance, assignment.Assignment.Member, value);

            SetMember(assign, nodeBeingAssigned, builder, context);
        }