Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        public T ResolveOrDefault <T>()
        {
            Type type = TypeGetter.GetType <T>();

            AssemblyRegistrar.RegisterIfNotExist(Storage.Assemblies, type);
            IService service = ServiceFinder.Find(Storage.Services, type);

            if (service == null)
            {
                return(default);
Exemplo n.º 3
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));
            }
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
0
        public T ResolveOrAuto <T>()
        {
            Type type = TypeGetter.GetType <T>();

            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((T)ServiceInstanceResolver.ResolveInstance(ServiceFinder.Find(Storage.Services, type), this));
            }

            return((T)ServiceInstanceResolver.ResolveInstance(service, this));
        }