/// <summary>
        /// Create an object of the type required.
        /// </summary>
        /// <param name="instanceType"></param>
        /// <returns></returns>
        public object CreateInstance(Type instanceType)
        {
            ConstructorInfo info = instanceType.FindMostSpecificConstructor();

            if (info == null)
            {
                var creator = new SimpleInstanceCreator();
                return(creator.CreateInstance(instanceType));
            }
            else
            {
                object[] args = CreateParametersFor(info);

                return(info.Invoke(args));
            }
        }
        private object CreateArgument(ParameterInfo pi)
        {
            object obj;

            Type parameterType = pi.ParameterType;

            var creator = new SimpleInstanceCreator();

            if (this._typeRegistry.Contains(parameterType))
            {
                Type concreteType = this._typeRegistry.Find(parameterType);
                obj = creator.CreateInstance(concreteType);
            }
            else
            {
                obj = creator.CreateInstance(parameterType);
            }

            return(obj);
        }