public override DynamicMetaObject BindSetIndex(SetIndexBinder binder, DynamicMetaObject[] indexes, DynamicMetaObject value) { // // Demand Full Trust to proceed with the binding. // new PermissionSet(PermissionState.Unrestricted).Demand(); ComMethodDesc method; var target = _callable.DispatchComObject; var name = _callable.MemberName; bool holdsNull = value.Value == null && value.HasValue; if (target.TryGetPropertySetter(name, out method, value.LimitType, holdsNull) || target.TryGetPropertySetterExplicit(name, out method, value.LimitType, holdsNull)) { bool[] isByRef = ComBinderHelpers.ProcessArgumentsForCom(ref indexes); isByRef = isByRef.AddLast(false); var result = BindComInvoke(method, indexes.AddLast(value), binder.CallInfo, isByRef); // Make sure to return the value; some languages need it. return(new DynamicMetaObject( Expression.Block(result.Expression, Expression.Convert(value.Expression, typeof(object))), result.Restrictions )); } return(base.BindSetIndex(binder, indexes, value)); }
public override DynamicMetaObject BindInvoke(InvokeBinder binder, DynamicMetaObject[] args) { ContractUtils.RequiresNotNull(binder, "binder"); ComMethodDesc method; if (_self.TryGetGetItem(out method)) { bool[] isByRef = ComBinderHelpers.ProcessArgumentsForCom(ref args); return(BindComInvoke(args, method, binder.CallInfo, isByRef)); } return(base.BindInvoke(binder, args)); }
public override DynamicMetaObject BindGetIndex(GetIndexBinder binder, DynamicMetaObject[] indexes) { ContractUtils.RequiresNotNull(binder, "binder"); ComMethodDesc getItem; if (_self.TryGetGetItem(out getItem)) { bool[] isByRef = ComBinderHelpers.ProcessArgumentsForCom(ref indexes); return(BindComInvoke(indexes, getItem, binder.CallInfo, isByRef)); } return(base.BindGetIndex(binder, indexes)); }
private DynamicMetaObject BindGetOrInvoke(DynamicMetaObject[] args, CallInfo callInfo) { // // Demand Full Trust to proceed with the binding. // new PermissionSet(PermissionState.Unrestricted).Demand(); ComMethodDesc method; var target = _callable.DispatchComObject; var name = _callable.MemberName; if (target.TryGetMemberMethod(name, out method) || target.TryGetMemberMethodExplicit(name, out method)) { bool[] isByRef = ComBinderHelpers.ProcessArgumentsForCom(ref args); return(BindComInvoke(method, args, callInfo, isByRef)); } return(null); }
public override DynamicMetaObject BindSetIndex(SetIndexBinder binder, DynamicMetaObject[] indexes, DynamicMetaObject value) { ContractUtils.RequiresNotNull(binder, "binder"); ComMethodDesc setItem; if (_self.TryGetSetItem(out setItem)) { bool[] isByRef = ComBinderHelpers.ProcessArgumentsForCom(ref indexes); isByRef = isByRef.AddLast(false); var result = BindComInvoke(indexes.AddLast(value), setItem, binder.CallInfo, isByRef); // Make sure to return the value; some languages need it. return(new DynamicMetaObject( Expression.Block(result.Expression, Expression.Convert(value.Expression, typeof(object))), result.Restrictions )); } return(base.BindSetIndex(binder, indexes, value)); }