internal static void InvokeMemberActionCallSite(object target, MemberInvocationMoniker name, object[] arguments,
                                                        string[] argumentNames, Type context, bool staticContext,
                                                        ref CallSite callSite)
        {
            LazyBinder binder     = null;
            Type       binderType = null;

            if (callSite == null)
            {
                binder = () =>
                {
                    var argumentBindingList = GetBindingArgumentList(arguments, argumentNames,
                                                                     staticContext);

                    var flag = CSharpBinderFlags.ResultDiscarded;
                    if (name.IsNameSpecial)
                    {
                        flag |= CSharpBinderFlags.InvokeSpecialName;
                    }

                    return(Binder.InvokeMember(flag, name.Name, name.GenericArguments,
                                               context, argumentBindingList));
                };
                binderType = typeof(InvokeMemberBinder);
            }

            MemberActionInvoke(ref callSite, binderType, binder, name, staticContext, context, argumentNames, target,
                               arguments);
        }
        internal static CallSite <T> CreateCallSite <T>(
            Type specificBinderType,
            LazyBinder binder,
            MemberInvocationMoniker name,
            Type context,
            string[] argumentNames = null,
            bool staticContext     = false,
            bool isEvent           = false)
            where T : class
        {
            var hashCode = BinderHashGenerator <T> .Create(name, context, argumentNames, specificBinderType, staticContext,
                                                           isEvent);

            lock (_binderCacheLock)
            {
                CallSite callSite;
                if (!_binderCache.TryGetValue(hashCode, out callSite))
                {
                    callSite = CallSite <T> .Create(binder());

                    _binderCache[hashCode] = callSite;
                }
                return((CallSite <T>)callSite);
            }
        }
 internal static TReturn InvokeMember <TReturn>(ref CallSite callsite, Type binderType, LazyBinder binder,
                                                MemberInvocationMoniker name,
                                                bool staticContext,
                                                Type context,
                                                string[] argumentNames,
                                                object target, params object[] arguments)
 {
     return(MemberTargetTypeInvoke <object, TReturn>(ref callsite, binderType, binder, name, staticContext,
                                                     context, argumentNames, target, arguments));
 }
Пример #4
0
 protected BinderHashGenerator(Type delegateType, MemberInvocationMoniker name, Type context,
                               string[] argumentNames, Type binderType, bool staticContext, bool isEvent)
 {
     BinderType    = binderType;
     StaticContext = staticContext;
     DelegateType  = delegateType;
     Name          = name;
     Context       = context;
     ArgumentNames = argumentNames;
     IsEvent       = isEvent;
 }
Пример #5
0
        public static InvocationCacheCompatible CreateCall(
            InvocationKind kind,
            MemberInvocationMoniker name = null,
            CallInfo callinfo            = null,
            object context = null)
        {
            var argumentCount = callinfo != null ? callinfo.ArgumentCount : 0;
            var argumentNames = callinfo != null?callinfo.ArgumentNames.ToArray() : null;

            return(new InvocationCacheCompatible(kind, name, argumentCount, argumentNames, context));
        }
Пример #6
0
 public static CallSite <T> CreateCallSite <T>(
     CallSiteBinder binder,
     MemberInvocationMoniker name,
     Type context,
     string[] argumentNames = null,
     bool staticContext     = false,
     bool isEvent           = false) where T : class
 {
     return(InvocationMapping.CreateCallSite <T>(binder.GetType(), () => binder, name, context, argumentNames,
                                                 staticContext,
                                                 isEvent));
 }
Пример #7
0
 public static CallSite CreateCallSite(
     Type delegateType,
     CallSiteBinder binder,
     MemberInvocationMoniker name,
     Type context,
     string[] argumentNames = null,
     bool staticContext     = false,
     bool isEvent           = false)
 {
     return(InvocationMapping.CreateCallSite(delegateType, binder.GetType(), () => binder, name, context,
                                             argumentNames, staticContext,
                                             isEvent));
 }
Пример #8
0
        public static void InvokeMemberAction(object target, MemberInvocationMoniker name, params object[] arguments)
        {
            string[] argumentNames;
            Type     context;
            bool     staticContext;

            target    = target.GetInvocationContext(out context, out staticContext);
            arguments = TypeFactorization.ExtractArgumentNamesAndValues(arguments, out argumentNames);

            CallSite theCallSite = null;

            InvocationMapping.InvokeMemberActionCallSite(target, name, arguments, argumentNames, context, staticContext,
                                                         ref theCallSite);
        }
Пример #9
0
        public InvocationCacheCompatible(InvocationKind kind,
                                         MemberInvocationMoniker name = null,
                                         int argCount        = 0,
                                         string[] argNames   = null,
                                         object context      = null,
                                         Type convertType    = null,
                                         bool convertExplict = false,
                                         object[] storedArgs = null)
            : base(kind, name, storedArgs)
        {
            _convertType    = convertType;
            _convertExplict = convertExplict;

            ExtractArguments(argNames, storedArgs);

            DecideArgumentCountBasedOnType(kind, argCount, convertType);

            SetArgumentNames();

            InitializeContext(context);
        }
Пример #10
0
        internal static CallSite CreateCallSite(
            Type delegateType,
            Type specificBinderType,
            LazyBinder binder,
            MemberInvocationMoniker name,
            Type context,
            string[] argumentNames = null,
            bool staticContext     = false,
            bool isEvent           = false)
        {
            var hash = BinderHashGenerator.Create(delegateType, name, context, argumentNames, specificBinderType,
                                                  staticContext, isEvent);

            lock (_binderCacheLock)
            {
                CallSite tOut;
                if (!_binderCache.TryGetValue(hash, out tOut))
                {
                    tOut = CallSite.Create(delegateType, binder());
                    _binderCache[hash] = tOut;
                }
                return(tOut);
            }
        }
Пример #11
0
 public static Invocation Create(InvocationKind kind, MemberInvocationMoniker name, params object[] storedArgs)
 {
     return(new Invocation(kind, name, storedArgs));
 }
Пример #12
0
 public Invocation(InvocationKind kind, MemberInvocationMoniker name, params object[] storedArgs)
 {
     Kind      = kind;
     Name      = name;
     Arguments = storedArgs;
 }
Пример #13
0
 public static BinderHashGenerator Create(Type delType, MemberInvocationMoniker name, Type context,
                                          string[] argumentNames, Type binderType, bool staticContext,
                                          bool isEvent)
 {
     return(new BinderHashGenerator(delType, name, context, argumentNames, binderType, staticContext, isEvent));
 }
Пример #14
0
 protected AbstractGenericBinderHashGenerator(Type delegateType, MemberInvocationMoniker name, Type context,
                                              string[] argumentNames, Type binderType, bool staticContext,
                                              bool isEvent)
     : base(delegateType, name, context, argumentNames, binderType, staticContext, isEvent)
 {
 }