Example #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);
        }
Example #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));
            }
        }
Example #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);
        }
Example #4
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);
Example #5
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));
            }
        }
Example #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);
        }
Example #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));
        }