All Downloads are FREE. Search and download functionalities are using the official Maven repository.

Alachisoft.NCache.Common.ReflectionUtil Maven / Gradle / Ivy

There is a newer version: 5.3.3
Show newest version
package Alachisoft.NCache.Common;


/**
 * class to assist with common system and .NET operations.
 */
public class ReflectionUtil {
    /**
     * Creates an instance of the type whose name is specified, using the named
     * assembly and the default constructor.
     *
     * @param assembly  The name of the assembly where the type named typeName
     *                  is sought. If assemblyName is a null reference,
     *                  the executing assembly is searched.
     * @param classname The name of the preferred type.
     * @return A reference to the newly created instance.
     */
    public static Object CreateObject(String assembly, String classname) {
        return CreateObject(assembly, classname, null);
    }

    /**
     * Creates an instance of the type whose name is specified, using the named
     * assembly and the constructor that best matches the specified parameters.
     *
     * @param assembly  The name of the assembly where the type named typeName
     *                  is sought. If assemblyName is a null reference,
     *                  the executing assembly is searched.
     * @param classname The name of the preferred type.
     * @param args      An array of arguments that match in number, order, and
     *                  type the parameters of the constructor to invoke.
     * @return A reference to the newly created instance.
     */
    public static Object CreateObject(String assembly, String classname, Object[] args) {
        //Mansoor: will be replace by Activator version of java. Development of Activator in java is in progress
            /*
		ObjectHandle objHandle = null;
                
		try {
			objHandle = Activator.CreateInstance(assembly, classname, false, BindingFlags.Default, null, args, null, null, null); // default security policy -  default activation attributes -  default culture -  arguments to constructor, -  use default binder -  no binding attributes -  class name is case-sensitive -  fully qualified class name -  name of assembly
			if (objHandle != null) {
				return objHandle.Unwrap();
			}
		} catch (RuntimeException e) {
			Trace.error("Common.CreateObject()", e.toString());
			throw e;
		}*/
        return null;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy