private void InflateChildren(IEnumerable <ConstructionNode> children, object parent, BuildContext buildContext) { foreach (var constructionNode in children) { var child = InflateCore(constructionNode, buildContext); var association = new PendingAssociation(parent, parent, new KeyedInstance(child, constructionNode.Key)); Associate(association, buildContext); } }
private void ApplyMultiAssignment(MemberAssignment assignment, object ownerInstance, BuildContext buildContext) { foreach (var constructionNode in assignment.Children) { var originalValue = InflateCore(constructionNode, buildContext); var child = MakeCompatible(ownerInstance, new ConversionRequest(assignment.Member, originalValue), buildContext); var parent = assignment.Member.GetValue(ownerInstance); var pendingAdd = new PendingAssociation(ownerInstance, 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 PendingAssociation(assignment.Target.Instance, parent, new KeyedInstance(child, assignment.Target.Key)); Associate(pendingAdd, buildContext); } else { assignment.ExecuteAssignment(); OnAssigmentExecuted(assignment, buildContext); } }
private void Associate(PendingAssociation pendingAssociation, BuildContext buildContext) { var childInstance = pendingAssociation.Child.Instance; var childKey = pendingAssociation.Child.Key; var parent = pendingAssociation.Parent; if (childKey == null) { Collection.UniversalAdd(parent, childInstance); } else { Collection.UniversalAddToDictionary(parent, childInstance, childKey); } buildContext.AddAssociation(new Association(pendingAssociation.Owner, childInstance)); OnInstanceAssociated(buildContext, childInstance); }