public static object CreateInstance(IServiceProvider provider, Type objectType, Type[] argTypes, object[] args)
{
if (objectType == null)
{
throw new ArgumentNullException(nameof(objectType));
}
if (argTypes != null)
{
if (args == null)
{
throw new ArgumentNullException(nameof(args));
}
if (argTypes.Length != args.Length)
{
throw new ArgumentException(SR.TypeDescriptorArgsCountMismatch);
}
}
object instance = null;
// See if the provider wants to offer a TypeDescriptionProvider to delegate to. This allows
// a caller to have complete control over all object instantiation.
if (provider != null)
{
TypeDescriptionProvider p = provider.GetService(typeof(TypeDescriptionProvider)) as TypeDescriptionProvider;
if (p != null)
{
instance = p.CreateInstance(provider, objectType, argTypes, args);
}
}
if (instance == null)
{
instance = NodeFor(objectType).CreateInstance(provider, objectType, argTypes, args);
}
return instance;
}
/// <summary>