public static void InvokeAction(object target, 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.InvokeDirectActionCallSite(target, arguments, argumentNames, context, staticContext,
                                                         ref theCallSite);
        }
        public static void InvokeSetIndex(object target, params object[] indexesThenValue)
        {
            string[] argNames;
            Type     context;
            bool     staticContext;

            target           = target.GetInvocationContext(out context, out staticContext);
            indexesThenValue = TypeFactorization.ExtractArgumentNamesAndValues(indexesThenValue, out argNames);

            CallSite theCallSite = null;

            InvocationMapping.InvokeSetIndexCallSite(target, indexesThenValue, argNames, context, staticContext,
                                                     ref theCallSite);
        }
Beispiel #3
0
        private void ExtractArguments(string[] argNames, object[] storedArgs)
        {
            _argumentNames = argNames ?? new string[] {};

            if (null != storedArgs)
            {
                _argumentCount = storedArgs.Length;
                string[] theArgumentNames;
                Arguments = TypeFactorization.ExtractArgumentNamesAndValues(storedArgs, out theArgumentNames);
                if (_argumentNames.Length < theArgumentNames.Length)
                {
                    _argumentNames = theArgumentNames;
                }
            }
        }
        public static dynamic InvokeMember(
            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;

            return(InvocationMapping.InvokeMemberCallSite(target, name, arguments, argumentNames, context, staticContext,
                                                          ref theCallSite));
        }
        public static dynamic CreateInstance(Type type, params object[] arguments)
        {
            string[] argumentNames;
            bool     isValue = type.IsValueType;

            if (isValue && arguments.Length == 0) //dynamic invocation doesn't see constructors of value types
            {
                return(Activator.CreateInstance(type));
            }

            arguments = TypeFactorization.ExtractArgumentNamesAndValues(arguments, out argumentNames);
            CallSite theCallSite = null;

            var context = type.MaybeDetectArrayContext();

            return(InvocationMapping.InvokeConstructorCallSite(type, isValue, arguments, argumentNames, context,
                                                               ref theCallSite));
        }
        public static void InvokeAddAssign(object target, string name, object value)
        {
            CallSite callSiteAdd     = null;
            CallSite callSiteGet     = null;
            CallSite callSiteSet     = null;
            CallSite callSiteIsEvent = null;

            Type context;
            bool staticContext;

            target = target.GetInvocationContext(out context, out staticContext);

            var args = new[] { value };

            string[] argNames;
            args = TypeFactorization.ExtractArgumentNamesAndValues(args, out argNames);

            InvocationMapping.InvokeAddAssignCallSite(target, name, args, argNames, context, staticContext,
                                                      ref callSiteIsEvent, ref callSiteAdd, ref callSiteGet,
                                                      ref callSiteSet);
        }