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); }
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);
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)); } }
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); }
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)); }