예제 #1
0
        public IService Find(IServiceList list, Type typeKey)
        {
            if (GenericParametersChecker.Check(typeKey))
            {
                return(GenericServiceFinder
                       .FindGenericServices(list, typeKey)
                       .FirstOrDefault());
            }

            bool isClass = TypeIsClassValidator.Validate(typeKey);

            return(isClass ? ByClassFinder.FindByClass(list, typeKey) : ByInterfaceFinder.FindByInterface(list, typeKey));
        }
        public IServiceGenericRegistration Generate(Type type)
        {
            ServiceGenericRegistrationBuilder builder = new ServiceGenericRegistrationBuilder();

            return(builder
                   .HasGenericParameters(TypeContainsGenericParametersChecker.Check(type))
                   .SetGenericParameters(ParametersProvider.ProvideGenericTypes(type)).Build());
        }
예제 #3
0
        public IInterface GenerateInterface(Type type)
        {
            IInterface @interface = new InterfaceBuilder()
                                    .AddType(type)
                                    .AddGenericParameters(GenericParametersProvider.ProvideGenericTypes(type))
                                    .HasGenericArguments(TypeContainsGenericParametersChecker.Check(type))
                                    .Build();

            return(@interface);
        }
예제 #4
0
        public bool Check(Type type)
        {
            if (ContainsGenericParametersChecker.Check(type))
            {
                Type enumerable = GenericGenerator.Generate(typeof(IEnumerable <>), GenericParametersProvider.ProvideGenericTypes(type).FirstOrDefault());

                return(enumerable.IsAssignableFrom(type));
            }

            return(false);
        }