public static object InvokeSet(object target, string name, object value) { Type context; bool staticContext; target = target.GetInvocationContext(out context, out staticContext); context = context.MaybeDetectArrayContext(); CallSite theCallSite = null; return(InvocationMapping.InvokeSetCallSite(target, name, value, context, staticContext, ref theCallSite)); }
internal static void InvokeSubtractAssignCallSite(object target, string name, object[] arguments, string[] argumentNames, Type context, bool staticContext, ref CallSite callSiteIsEvent, ref CallSite callSiteRemove, ref CallSite callSiteGet, ref CallSite callSiteSet) { if (InvokeIsEventCallSite(target, name, context, ref callSiteIsEvent)) { InvokeMemberActionCallSite(target, InvokeMemberByName.CreateSpecialName("remove_" + name), arguments, argumentNames, context, staticContext, ref callSiteRemove); } else { dynamic tGet = InvokeGetCallSite(target, name, context, staticContext, ref callSiteGet); tGet -= (arguments[0]); InvocationMapping.InvokeSetCallSite(target, name, tGet, context, staticContext, ref callSiteSet); } }
public override object Invoke(object target, params object[] args) { var invocationContext = target as InvocationContext; if (invocationContext != null) { target = invocationContext.Target; } if (args == null) { args = new object[] { null }; } ValidateInvocationArguments(args); switch (Kind) { case InvocationKind.Constructor: var tTarget = (Type)target; return(InvocationMapping.InvokeConstructorCallSite(tTarget, tTarget.IsValueType, args, _argumentNames, _context, ref _callSite)); case InvocationKind.Convert: return(InvocationMapping.InvokeConvertCallSite(target, _convertExplict, _convertType, _context, ref _callSite)); case InvocationKind.Get: return(InvocationMapping.InvokeGetCallSite(target, Name.Name, _context, _staticContext, ref _callSite)); case InvocationKind.Set: InvocationMapping.InvokeSetCallSite(target, Name.Name, args[0], _context, _staticContext, ref _callSite); return(null); case InvocationKind.GetIndex: return(InvocationMapping.InvokeGetIndexCallSite(target, args, _argumentNames, _context, _staticContext, ref _callSite)); case InvocationKind.SetIndex: InvocationBinding.InvokeSetIndex(target, args); return(null); case InvocationKind.InvokeMember: return(InvocationMapping.InvokeMemberCallSite(target, Name, args, _argumentNames, _context, _staticContext, ref _callSite)); case InvocationKind.InvokeMemberAction: InvocationMapping.InvokeMemberActionCallSite(target, Name, args, _argumentNames, _context, _staticContext, ref _callSite); return(null); case InvocationKind.InvokeMemberUnknown: { try { var tObj = InvocationMapping.InvokeMemberCallSite(target, Name, args, _argumentNames, _context, _staticContext, ref _callSite); return(tObj); } catch (RuntimeBinderException) { InvocationMapping.InvokeMemberActionCallSite(target, Name, args, _argumentNames, _context, _staticContext, ref _callSite2); return(null); } } case InvocationKind.Invoke: return(InvocationMapping.InvokeDirectCallSite(target, args, _argumentNames, _context, _staticContext, ref _callSite)); case InvocationKind.InvokeAction: InvocationMapping.InvokeDirectActionCallSite(target, args, _argumentNames, _context, _staticContext, ref _callSite); return(null); case InvocationKind.InvokeUnknown: { try { var tObj = InvocationMapping.InvokeDirectCallSite(target, args, _argumentNames, _context, _staticContext, ref _callSite); return(tObj); } catch (RuntimeBinderException) { InvocationMapping.InvokeDirectActionCallSite(target, args, _argumentNames, _context, _staticContext, ref _callSite2); return(null); } } case InvocationKind.AddAssign: InvocationMapping.InvokeAddAssignCallSite(target, Name.Name, args, _argumentNames, _context, _staticContext, ref _callSite, ref _callSite2, ref _callSite3, ref _callSite4); return(null); case InvocationKind.SubtractAssign: InvocationMapping.InvokeSubtractAssignCallSite(target, Name.Name, args, _argumentNames, _context, _staticContext, ref _callSite, ref _callSite2, ref _callSite3, ref _callSite4); return(null); case InvocationKind.IsEvent: return(InvocationMapping.InvokeIsEventCallSite(target, Name.Name, _context, ref _callSite)); default: throw new InvalidOperationException("Unknown Invocation Kind: " + Kind); } }