Example #1
0
        public InstanceFactory(Type registerType, Type registerImplementation, object instance)
        {
            if (!DependencyContainer.IsValidAssignment(registerType, registerImplementation))
            {
                throw new DependencyContainerRegistrationException(registerImplementation, "InstanceFactory", true);
            }

            _registerType           = registerType;
            _registerImplementation = registerImplementation;
            _instance = instance;
        }
Example #2
0
        public SingletonFactory(Type registerType, Type registerImplementation)
        {
            if (registerImplementation.IsAbstract() || registerImplementation.IsInterface())
            {
                throw new DependencyContainerRegistrationException(registerImplementation, nameof(SingletonFactory), true);
            }

            if (!DependencyContainer.IsValidAssignment(registerType, registerImplementation))
            {
                throw new DependencyContainerRegistrationException(registerImplementation, nameof(SingletonFactory), true);
            }

            _registerType           = registerType;
            _registerImplementation = registerImplementation;
        }
Example #3
0
        public MultiInstanceFactory(Type registerType, Type registerImplementation)
        {
            if (registerImplementation.IsAbstract() || registerImplementation.IsInterface())
            {
                throw new DependencyContainerRegistrationException(registerImplementation,
                                                                   "MultiInstanceFactory",
                                                                   true);
            }

            if (!DependencyContainer.IsValidAssignment(registerType, registerImplementation))
            {
                throw new DependencyContainerRegistrationException(registerImplementation,
                                                                   "MultiInstanceFactory",
                                                                   true);
            }

            _registerType           = registerType;
            _registerImplementation = registerImplementation;
        }