private DynamicMetaObject DoBindSetMember(ExpressionContainer wrapper, Type returnType, string memberName, bool ignoreCase, DynamicMetaObject value) { var valueExpr = wrapper.Expression; var property = PrivateAccessor.ResolveProperty(valueExpr.Type, memberName, ignoreCase, new object[0], !wrapper.IsStatic, value.Value, getter: false); if (property == null) { ThrowMissingMemberException(valueExpr.Type, memberName); } var memberExpr = Expression.Assign(Expression.Property(!wrapper.IsStatic ? valueExpr : null, property), FromArg(value)); return(CreateRecorder(memberExpr, returnType)); }
private DynamicMetaObject DoBindGetMember(Type returnType, string memberName, bool ignoreCase) { var wrapper = this.Value as ExpressionContainer; var valueExpr = wrapper.Expression; var property = PrivateAccessor.ResolveProperty(valueExpr.Type, memberName, ignoreCase, new object[0], !wrapper.IsStatic); if (property == null) { ThrowMissingMemberException(valueExpr.Type, memberName); } var memberExpr = Expression.Property(!wrapper.IsStatic ? valueExpr : null, property); return(CreateRecorder(memberExpr, returnType)); }
public override DynamicMetaObject BindGetIndex(GetIndexBinder binder, DynamicMetaObject[] indexes) { var wrapper = this.Value as ExpressionContainer; var valueExpr = wrapper.Expression; var property = PrivateAccessor.ResolveProperty(valueExpr.Type, "Item", false, indexes.Select(i => i.Value).ToArray(), !wrapper.IsStatic); if (property == null) { ThrowMissingMemberException(valueExpr.Type, "Item"); } var memberExpr = Expression.MakeIndex(!wrapper.IsStatic ? valueExpr : null, property, indexes.Select(FromArg)); return(CreateRecorder(memberExpr, binder.ReturnType)); }