コード例 #1
0
 /// <summary>
 /// Invokes a constructor whose parameter types are inferred from <paramref name="parameters" /> and
 /// matching <paramref name="bindingFlags"/> on the given <paramref name="type"/>
 /// with <paramref name="parameters" /> being the arguments.
 /// Leave <paramref name="parameters"/> empty if the constructor has no argument.
 /// </summary>
 /// <remarks>
 /// All elements of <paramref name="parameters"/> must not be <c>null</c>.  Otherwise,
 /// <see cref="NullReferenceException"/> is thrown.  If you are not sure as to whether
 /// any element is <c>null</c> or not, use the overload that accepts <c>paramTypes</c> array.
 /// </remarks>
 /// <seealso cref="CreateInstance(System.Type,System.Type[],PA.Framework.Flags,object[])"/>
 public static object CreateInstance(this Type type, Flags bindingFlags, params object[] parameters)
 {
     return(DelegateForCreateInstance(type, bindingFlags, parameters.ToTypeArray())(parameters));
 }
コード例 #2
0
 /// <summary>
 /// Invokes a constructor whose parameter types are <paramref name="parameterTypes" /> and
 /// matching <paramref name="bindingFlags"/> on the given <paramref name="type"/>
 /// with <paramref name="parameters" /> being the arguments.
 /// </summary>
 public static object CreateInstance(this Type type, Type[] parameterTypes, Flags bindingFlags, params object[] parameters)
 {
     return(DelegateForCreateInstance(type, bindingFlags, parameterTypes)(parameters));
 }
コード例 #3
0
 /// <summary>
 /// Invokes a constructor whose parameter types are inferred from <paramref name="parameters" />
 /// on the given <paramref name="type"/> with <paramref name="parameters" /> being the arguments.
 /// </summary>
 /// <param name="type">The type of object to create.</param>
 /// <param name="parameters">An array of arguments that match in number, order, and type the parameters of the constructor to invoke.</param>
 /// <returns>A reference to the newly created object.</returns>
 public static object CreateInstance(Type type, params object[] parameters)
 {
     return(DelegateForCreateInstance(type, ReflectionUtils.ToTypeArray(parameters))(parameters));
 }