private object GetInternal(ICherryServiceLocatorAndRegistry originalLocator, Type serviceKey,
            params InjectionParameter[] parameters)
        {
            if (ReferenceEquals(serviceKey, null))
            {
                throw new ArgumentNullException("serviceKey", "The serviceKey must not be null");
            }

            object factoryMethod;
            if (ServiceLocatorFactoryMethodSupportExtensions.GetFactoryMethod(this, serviceKey, out factoryMethod))
            {
                return factoryMethod;
            }

            if (serviceKey.IsClass && !serviceKey.IsAbstract && !IsRegisteredRecursively(serviceKey))
            {
                var perResolveResolver = new PerResolveResolver(serviceKey);
                var instance = perResolveResolver.Get(originalLocator, this, parameters);
                return instance;
            }

            IResolver resolver;
            if (!_registrations.TryGetValue(serviceKey, out resolver))
            {
                if (_parent != null)
                {
                    return _parent.GetInternal(originalLocator, serviceKey);
                }
                throw new ArgumentException(string.Format("The type {0} could not be resolved.", serviceKey), "serviceKey");
            }
            return resolver.Get(originalLocator, this, parameters);
        }
        public void Register(Type serviceKey, Type serviceType, bool singleton)
        {
            if (ReferenceEquals(serviceKey, null))
            {
                throw new ArgumentNullException("serviceKey", "The serviceKey must not be null");
            }
            if (ReferenceEquals(serviceType, null))
            {
                throw new ArgumentNullException("serviceType", "The serviceType must not be null");
            }
            if (!serviceType.IsClass || serviceType.IsAbstract)
            {
                throw new ArgumentException("The serviceType must be a non-abstract class type", "serviceType");
            }
            if (!serviceKey.IsAssignableFrom(serviceType))
            {
                throw new ArgumentException("The serviceType must be convertible to the type specified as serviceKey", "serviceType");
            }

            IResolver resolver;
            if (singleton)
            {
                resolver = new SingletonResolver(serviceType);
            }
            else
            {
                resolver = new PerResolveResolver(serviceType);
            }
            _registrations.Add(serviceKey, resolver);
        }