public void Resolver(IResolverContext context, IDependencyResolver resolver)
        {
            var args = context.HasImplementationType() && context.HasPublicConstructor()
                ? ResolverHelper.GetConstructorParameters(
                    context.Dependency.GetImplementationType(), resolver)
                : ArrayExtends.Empty<object>();

            context.Resolved = CompileCacheManager.GetCache(context.Dependency, resolver, args);

            context.Handled = context.Resolved != null && !PropertyCacheManager.Any(context.Dependency);
        }
예제 #2
0
        public void Resolver(IResolverContext context, IDependencyResolver resolver)
        {
            var args = context.HasImplementationType() && context.HasPublicConstructor()
                ? ResolverHelper.GetConstructorParameters(
                context.Dependency.GetImplementationType(), resolver)
                : ArrayExtends.Empty <object>();

            context.Resolved = CompileCacheManager.GetCache(context.Dependency, resolver, args);

            context.Handled = context.Resolved != null && !PropertyCacheManager.Any(context.Dependency);
        }
        public void Resolver(IResolverContext context, IDependencyResolver resolver)
        {
            try
            {
                var args = context.HasImplementationType() && context.HasPublicConstructor()
                    ? ResolverHelper.GetConstructorParameters(
                    context.Dependency.GetImplementationType(), resolver)
                    : ArrayExtends.Empty <object>();

                context.Resolved = CompileCacheManager.GetOrSetCache(context.Dependency,
                                                                     () => CreateDelegate(context.Resolved as Expression)).
                                   Invoke(resolver, args);

                CacheResolved(context, resolver);
            }
            catch (Exception ex)
            {
                throw new InvalidOperationException($"未能创建类型\"{context.Dependency.ServiceType}\"的实例。", ex);
            }
        }
        public void Resolver(IResolverContext context, IDependencyResolver resolver)
        {
            try
            {
                var args = context.HasImplementationType() && context.HasPublicConstructor()
                    ? ResolverHelper.GetConstructorParameters(
                        context.Dependency.GetImplementationType(), resolver)
                    : ArrayExtends.Empty<object>();

                context.Resolved = CompileCacheManager.GetOrSetCache(context.Dependency,
                    () => CreateDelegate(context.Resolved as Expression)).
                    Invoke(resolver, args);

                CacheResolved(context, resolver);
            }
            catch (Exception ex)
            {
                throw new InvalidOperationException($"未能创建类型\"{context.Dependency.ServiceType}\"的实例。", ex);
            }
        }
예제 #5
0
 public bool PreResolver(IResolverContext context, IDependencyResolver resolver)
 {
     return(context.NotComplete() && context.HasImplementationType() && !context.HasPublicConstructor());
 }
 public bool Requires(IResolverContext context, IDependencyResolver resolver)
 {
     return context.NotResolved() && context.Resolved == null && context.HasImplementationType() &&
            !context.HasPublicConstructor();
 }
 public bool PreResolver(IResolverContext context, IDependencyResolver resolver)
 {
     return context.NotComplete() && context.HasImplementationType() && !context.HasPublicConstructor();
 }
 public bool Requires(IResolverContext context, IDependencyResolver resolver)
 {
     return(context.NotResolved() && context.Resolved == null && context.HasImplementationType() &&
            context.HasPublicConstructor());
 }