Catel.IoC.ServiceLocator.CreateServiceInstance C# (CSharp) Method

CreateServiceInstance() private method

Creates the service instance.
private CreateServiceInstance ( Catel.IoC.ServiceLocatorRegistration registration ) : object
registration Catel.IoC.ServiceLocatorRegistration The registration.
return object
        private object CreateServiceInstance(ServiceLocatorRegistration registration)
        {
            object instance = _typeFactory.CreateInstance(registration.ImplementingType);
            if (instance == null)
            {
                ThrowTypeNotRegisteredException(registration.DeclaringType, "Failed to instantiate the type using the TypeFactory. Check if the required dependencies are registered as well or that the type has a valid constructor that can be used.");
            }

            var handler = TypeInstantiated;
            if (handler != null)
            {
                handler(this, new TypeInstantiatedEventArgs(registration.DeclaringType, registration.ImplementingType,
                    registration.Tag, registration.RegistrationType));
            }

            return instance;
        }