Пример #1
0
        public void RegisterObject(object instance, Type targetType)
        {
            AssemblyRegistrar.RegisterIfNotExist(Storage.Assemblies, targetType);
            IEnumerable <IService> services = ServicesGenerator.GenerateServices(targetType, Storage.Assemblies, null, null, instance);

            ServiceRegistrar.Register(Storage.Services, services);
        }
Пример #2
0
        public void RegisterAssembly(Assembly assembly)
        {
            AssemblyRegistrar.RegisterIfNotExist(Storage.Assemblies, assembly);

            foreach (Type type in assembly.GetTypes())
            {
                ServiceRegistrar.Register(Storage.Services, ServicesGenerator.GenerateServices(type, Storage.Assemblies, null));
            }
        }
Пример #3
0
        public void RegisterObject <TKey>(object instance)
        {
            Type type = TypeGetter.GetType(instance);

            AssemblyRegistrar.RegisterIfNotExist(Storage.Assemblies, type);

            IEnumerable <IService> services = ServicesGenerator.GenerateServices(type, Storage.Assemblies, null, null, instance);

            ServiceRegistrar.Register(Storage.Services, services);
        }
Пример #4
0
        public void RegisterAssembly <T>()
        {
            Type tType = TypeGetter.GetType <T>();

            AssemblyRegistrar.RegisterIfNotExist(Storage.Assemblies, tType);

            foreach (Type type in tType.Assembly.GetTypes())
            {
                ServiceRegistrar.Register(Storage.Services, ServicesGenerator.GenerateServices(type, Storage.Assemblies, null));
            }
        }
Пример #5
0
        public void Register <T>()
        {
            IEnumerable <IService> services = ServicesGenerator.GenerateServices(typeof(T), Storage.Assemblies, null);

            foreach (IService service in services)
            {
                if (ServiceIsAutoValueChecker.Check(service))
                {
                    ServiceInitializer.Initialize(service, this);
                }
            }

            ServiceRegistrar.Register(Storage.Services, services);
        }
Пример #6
0
        public void Register(Type type)
        {
            AssemblyRegistrar.RegisterIfNotExist(Storage.Assemblies, type);

            IEnumerable <IService> services = ServicesGenerator.GenerateServices(type, Storage.Assemblies, null);

            foreach (IService service in services)
            {
                if (ServiceIsAutoValueChecker.Check(service))
                {
                    ServiceInitializer.Initialize(service, this);
                }
            }

            ServiceRegistrar.Register(Storage.Services, services);
        }
Пример #7
0
        public object ResolveOrAuto(Type type)
        {
            AssemblyRegistrar.RegisterIfNotExist(Storage.Assemblies, type);
            IService service = ServiceFinder.Find(Storage.Services, type);

            if (service == null)
            {
                IEnumerable <IService> services = ServicesGenerator.GenerateServices(type, Storage.Assemblies, this);

                ServiceRegistrar.Register(Storage.Services, services);

                return(ServiceInstanceResolver.ResolveInstance(ServiceFinder.Find(Storage.Services, type), this));
            }

            return(ServiceInstanceResolver.ResolveInstance(service, this));
        }
Пример #8
0
        public void Register <T>(params object[] parameters)
        {
            Type type = TypeGetter.GetType <T>();
            IConstructorParameters constructorParameters = ConstructorParametersByObjectsGenerator.GenerateParameters(parameters);

            IEnumerable <IService> services = ServicesGenerator.GenerateServices(type, Storage.Assemblies, this, constructorParameters);

            foreach (IService service in services)
            {
                if (ServiceIsAutoValueChecker.Check(service))
                {
                    ServiceInitializer.Initialize(service, this);
                }
            }

            ServiceRegistrar.Register(Storage.Services, services);
        }