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)); }
protected override Expression VisitBinary(BinaryExpression node) { if (node == null) { throw new ArgumentNullException(nameof(node)); } switch (node.NodeType) { case ExpressionType.Equal: case ExpressionType.TypeEqual: var member = ExtractMember(node.Left); Values[member.Name] = ValueVisitor.ExtractValue(node.Right); return(node); case ExpressionType.And: case ExpressionType.AndAlso: return(base.VisitBinary(node)); } ThrowNotSupported(node.NodeType.ToString()); return(node); }