public void Resolver(IResolverContext context, IDependencyResolver resolver)
 {
     context.Resolved = Expression.Lambda<Func<IDependencyResolver, object[], object>>(
             Expression.New(context.IsDynamicProxy()
             ? DynamicTypeCacheManager.GetCache(context.Dependency.ImplementationType)
             : context.Dependency.ImplementationType),
             Expression.Parameter(typeof (IDependencyResolver)),
             Expression.Parameter(typeof (object[])));
 }
 public void Resolver(IResolverContext context, IDependencyResolver resolver)
 {
     context.Resolved = Expression.Lambda <Func <IDependencyResolver, object[], object> >(
         Expression.New(context.IsDynamicProxy()
             ? DynamicTypeCacheManager.GetCache(context.Dependency.ImplementationType)
             : context.Dependency.ImplementationType),
         Expression.Parameter(typeof(IDependencyResolver)),
         Expression.Parameter(typeof(object[])));
 }
        public void Resolver(IResolverContext context, IDependencyResolver resolver)
        {
            var implType = context.IsDynamicProxy()
                ? DynamicTypeCacheManager.GetCache(context.Dependency.ImplementationType)
                : context.Dependency.ImplementationType;

            var constructor = ResolverHelper.GetBastConstructor(implType, resolver);

            if (constructor == null) throw new InvalidOperationException($"{implType.FullName}不存在公共构造方法。");

            var parameter = Expression.Parameter(typeof (object[]), "args");

            context.Resolved = Expression.
                Lambda<Func<IDependencyResolver, object[], object>>(
                    Expression.New(constructor,
                        GetConstructorParameters(constructor, parameter)),
                    Expression.Parameter(typeof (IDependencyResolver)),
                    parameter);
        }
        public void Resolver(IResolverContext context, IDependencyResolver resolver)
        {
            var implType = context.IsDynamicProxy()
                ? DynamicTypeCacheManager.GetCache(context.Dependency.ImplementationType)
                : context.Dependency.ImplementationType;

            var constructor = ResolverHelper.GetBastConstructor(implType, resolver);

            if (constructor == null)
            {
                throw new InvalidOperationException($"{implType.FullName}不存在公共构造方法。");
            }

            var parameter = Expression.Parameter(typeof(object[]), "args");

            context.Resolved = Expression.
                               Lambda <Func <IDependencyResolver, object[], object> >(
                Expression.New(constructor,
                               GetConstructorParameters(constructor, parameter)),
                Expression.Parameter(typeof(IDependencyResolver)),
                parameter);
        }