public static Never Raise(Type registerType, string method, string messageFormat = null, Exception innerException = null)
        {
            var message = String.Format(messageFormat ?? CONVERT_ERROR_FORMAT, registerType?.FullName, method);

            IoCRegistrationException ex;

            if (innerException != null)
            {
                ex = new IoCRegistrationException(registerType, message, innerException);
            }
            else
            {
                ex = new IoCRegistrationException(registerType, message);
            }
            throw ex;
        }
        public static Never Raise(Type registerType, Type implementationType, string messageFormat = null, Exception innerException = null)
        {
            var message = String.Format(messageFormat ?? INVALID_REGISTRATION_FORMAt, registerType?.FullName, implementationType?.FullName);

            IoCRegistrationException ex;

            if (innerException != null)
            {
                ex = new IoCRegistrationException(registerType, message, innerException);
            }
            else
            {
                ex = new IoCRegistrationException(registerType, message);
            }
            throw ex;
        }
Beispiel #3
0
        void RegisterInternal(string regisrationName, Type registerType, Type implementationType, IoCFactory factory)
        {
            if (registerType == null || implementationType == null || implementationType.IsAbstract() || implementationType.IsInterface())
            {
                IoCRegistrationException.Raise(registerType, implementationType);
            }

            if (!IsValidAssignment(registerType, implementationType))
            {
                IoCRegistrationException.Raise(registerType, implementationType);
            }

            var typeRegistration = new TypeRegistration(registerType, regisrationName);

            registry[typeRegistration] = factory;
        }