コード例 #1
0
        private ClassComponent(ClassComponent parent, Type type, IEnumerable <IBinderAttribute> binders, Type scope, WeldComponentManager manager, GenericUtils.Resolution typeResolution)
            : base(new ComponentIdentifier(parent.Id.Key, type), type, binders, scope, manager,
                   parent.PostConstructs.Select(x => GenericUtils.TranslateMethodGenericArguments(x, typeResolution.GenericParameterTranslations)).ToArray())
        {
            parent.TransferInjectionPointsTo(this, typeResolution);
            _lazyMixins = new Lazy <Mixin[]>(() => Manager.GetMixins(this));

            _lazyInterceptors = new Lazy <Interceptor[]>(() => new Interceptor[0]);
            //_lazyInterceptors = new Lazy<Interceptor[]>(() => Manager.GetInterceptors(this));
            //_interceptedMethods = InitInterceptedMethods();
        }
コード例 #2
0
        public override IWeldComponent Resolve(Type requestedType)
        {
            if (!ContainsGenericParameters)
            {
                return(requestedType.IsAssignableFrom(Type)? this: null);
            }

            var resolution = GenericUtils.ResolveGenericType(Type, requestedType);

            if (resolution == null || resolution.ResolvedType == null || resolution.ResolvedType.ContainsGenericParameters)
            {
                return(null);
            }

            var component = new ClassComponent(this,
                                               resolution.ResolvedType,
                                               Binders,
                                               Scope, Manager, resolution);

            return(component);
        }
コード例 #3
0
ファイル: ClassComponent.cs プロジェクト: worldspawn/cormo
        public override IWeldComponent Resolve(Type requestedType)
        {
            ClassComponent component;

            if (IsConcrete)
            {
                component = (ClassComponent)base.Resolve(requestedType);
            }

            else
            {
                var resolution = GenericResolver.ImplementerResolver.ResolveType(Type, requestedType);
                if (resolution == null || resolution.ResolvedType == null || resolution.ResolvedType.ContainsGenericParameters)
                {
                    return(null);
                }
                component = new ClassComponent(AnnotatedType.Resolve(resolution.ResolvedType), Manager);
            }
            if (component != null)
            {
                RuntimeHelpers.RunClassConstructor(component.Type.TypeHandle);
            }
            return(component);
        }