예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #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;
                }
            }
        }
예제 #4
0
        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));
        }
예제 #5
0
        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));
        }
예제 #6
0
        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);
        }