private void InflateChildren(IEnumerable <ConstructionNode> children, object parent, BuildContext buildContext) { foreach (var constructionNode in children) { var child = InflateCore(constructionNode, buildContext); var association = new ChildAssociation(parent, new KeyedInstance(child, constructionNode.Key)); Associate(association, buildContext); } }
private void ApplyMultiAssignment(MemberAssignment assignment, object instance, BuildContext buildContext, Member property) { foreach (var constructionNode in assignment.Children) { var originalValue = InflateCore(constructionNode, buildContext); var child = MakeCompatible(instance, new ConversionRequest(property, originalValue), buildContext); var parent = property.GetValue(instance); var pendingAdd = new ChildAssociation(parent, new KeyedInstance(child, constructionNode.Key)); Associate(pendingAdd, buildContext); } }
protected virtual void PerformAssigment(Assignment assignment, BuildContext buildContext) { if (assignment.Member.MemberType.IsCollection()) { var parent = assignment.Member.GetValue(assignment.Target.Instance); var child = assignment.Value; var pendingAdd = new ChildAssociation(parent, new KeyedInstance(child, assignment.Target.Key)); Associate(pendingAdd, buildContext); } else { assignment.ExecuteAssignment(); OnAssigmentExecuted(assignment, buildContext); } }
protected void Associate(ChildAssociation childAssociation, BuildContext buildContext) { var childInstance = childAssociation.Child.Instance; var childKey = childAssociation.Child.Key; var parent = childAssociation.Parent; if (childKey == null) { Collection.UniversalAdd(parent, childInstance); } else { Collection.UniversalAddToDictionary(parent, childInstance, childKey); } OnInstanceAssociated(buildContext, childInstance); }