Esempio n. 1
0
        private static Delegate DelegateActivator <TArg0, TResult, TDelegate>(IComponentContext context, object target, ParameterMapping mapping)
        {
            ILifetimeScope        ls   = context.Resolve <ILifetimeScope>();
            Func <TArg0, TResult> func = a0 => Resolve <TResult>(target, ls, mapping.GetParameterCollection <TDelegate>(new object[] { a0 }));

            return(Delegate.CreateDelegate(typeof(TDelegate), func.Target, func.Method));
        }
Esempio n. 2
0
        static Delegate DelegateActivator <TArg0, TArg1, TArg2, TArg3, TResult, TDelegate>(IComponentContext context, object target, ParameterMapping mapping)
        {
            var ls = context.Resolve <ILifetimeScope>();
            Func <TArg0, TArg1, TArg2, TArg3, TResult> delegateClosure = (a0, a1, a2, a3) =>
            {
                var parameterCollection = mapping.GetParameterCollection <TDelegate>(a0, a1, a2, a3);
                return(Resolve <TResult>(target, ls, parameterCollection));
            };

            return(Delegate.CreateDelegate(typeof(TDelegate), delegateClosure.Target, delegateClosure.Method));
        }
Esempio n. 3
0
        static Delegate DelegateActivator <TArg0, TArg1, TResult, TDelegate>(IComponentContext context, object target, ParameterMapping mapping)
        {
            var ls = context.Resolve <ILifetimeScope>();
            Func <TArg0, TArg1, TResult> delegateClosure = (a0, a1) =>
            {
                Debug.WriteLine("Invoking Delegate Func<TArg0, TArg1, TResult>");
                var parameterCollection = mapping.GetParameterCollection <TDelegate>(a0, a1);
                return(Resolve <TResult>(target, ls, parameterCollection));
            };

            return(Delegate.CreateDelegate(typeof(TDelegate), delegateClosure.Target, delegateClosure.Method, true));
        }