void VisitAddOrDeleteMethodCall(MethodCallExpression node, ChildChangeType changeType) { var instance = node.Object as MemberExpression ?? throw new NotSupportedException($"{changeType.ToString()} method is only supported when called on an object child property, eg. object.ChildProperty.{changeType.ToString()}(...)."); var value = ValueVisitor.ExtractValue(node.Arguments[0]) as IMetadataObject ?? throw new NotSupportedException("The parameter provided for the Add method call could not be extracted as a non-nullable instance."); var changes = GetChildChangeList(instance.Member.Name); changes.Add(new ChildChange(value, changeType)); }
/// <summary> /// Initializes a new instance of the <see cref="ChildChange" /> class. /// </summary> /// <param name="child">The child.</param> /// <param name="type">The type.</param> public ChildChange(IMetadataObject child, ChildChangeType type) { Type = type; Child = child ?? throw new ArgumentNullException(nameof(child)); }