public static CreateNewInstance ( System classType ) : |
||
classType | System | The Type of the new class instance to return. |
Результат |
public static FunctionUnit newDSFunction(string funName, Env env, CellExt1 cs, DataSet ds) { FunctionUnit unit3; try { if (ds == null) { throw new ReportError("数据集未产生,可能因为未连接数据库"); } Type classType = (Type)hashtable_1[funName.ToLower()]; FunctionUnit unit = (FunctionUnit)SupportClass.CreateNewInstance(classType); unit.env = env; unit.ds = ds; unit.cs = cs; unit3 = unit; } catch (UnauthorizedAccessException exception) { throw new SystemException(exception.Message); } catch (Exception exception2) { throw new SystemException(exception2.Message); } return(unit3); }
/// <summary> Load the class that implements the given command and execute it. /// /// </summary> /// <param name="interp">the current interpreter. /// </param> /// <param name="argv">command arguments. /// </param> /// <exception cref=""> TclException if error happens inside the real command proc. /// </exception> public TCL.CompletionCode cmdProc(Interp interp, TclObject[] argv) { Type cmdClass = null; Command cmd; try { cmdClass = System.Type.GetType(className, true); } catch (System.Exception e) { throw new TclException(interp, "ClassNotFoundException for class \"" + className + "\""); } try { cmd = (Command)SupportClass.CreateNewInstance(cmdClass); } catch (System.UnauthorizedAccessException e1) { throw new TclException(interp, "IllegalAccessException for class \"" + cmdClass.FullName + "\""); } catch (System.InvalidCastException e3) { throw new TclException(interp, "ClassCastException for class \"" + cmdClass.FullName + "\""); } catch (System.Exception e2) { throw new TclException(interp, "InstantiationException for class \"" + cmdClass.FullName + "\""); } interp.createCommand(argv[0].ToString(), cmd); cmd.cmdProc(interp, argv); return(TCL.CompletionCode.RETURN); }
private void initializeIntrospection() { string @string = this.GetString("runtime.introspector.uberspect"); if (@string == null || @string.Length <= 0) { string message = "It appears that no class was specified as the Uberspect. Please ensure that all configuration information is correct."; this.Error(message); throw new System.Exception(message); } object obj; try { obj = SupportClass.CreateNewInstance(Type.GetType(@string)); } catch (System.Exception) { string message = "The specified class for Uberspect (" + @string + ") does not exist (or is not accessible to the current classlaoder."; this.Error(message); throw new System.Exception(message); } if (!(obj is IUberspect)) { string message = "The specified class for Uberspect (" + @string + ") does not implement org.apache.velocity.util.introspector.Uberspect. Velocity not initialized correctly."; this.Error(message); throw new System.Exception(message); } this.uberSpect = (IUberspect)obj; if (this.uberSpect is UberspectLoggable) { ((UberspectLoggable)this.uberSpect).RuntimeLogger = this; } this.uberSpect.Init(); }
/// <summary> /// Gets the classname for the Uberspect introspection package and /// instantiates an instance. /// </summary> private void initializeIntrospection() { String rm = GetString(RuntimeConstants.UBERSPECT_CLASSNAME); if (rm != null && rm.Length > 0) { Object o; try { o = SupportClass.CreateNewInstance(Type.GetType(rm)); } catch (System.Exception) { String err = string.Format( "The specified class for Uberspect ({0}) does not exist (or is not accessible to the current classlaoder.", rm); Error(err); throw new System.Exception(err); } if (!(o is IUberspect)) { String err = string.Format( "The specified class for Uberspect ({0}) does not implement org.apache.velocity.util.introspector.Uberspect. Velocity not initialized correctly.", rm); Error(err); throw new System.Exception(err); } uberSpect = (IUberspect)o; if (uberSpect is UberspectLoggable) { ((UberspectLoggable)uberSpect).RuntimeLogger = this; } uberSpect.Init(); } else { // someone screwed up. Lets not fool around... String err = "It appears that no class was specified as the Uberspect. Please ensure that all configuration information is correct."; Error(err); throw new System.Exception(err); } }
/// <summary> Gets the classname for the Uberspect introspection package and /// instantiates an instance. /// </summary> private void initializeIntrospection() { String rm = getString(RuntimeConstants_Fields.UBERSPECT_CLASSNAME); if (rm != null && rm.Length > 0) { Object o = null; //UPGRADE_NOTE: Exception 'java.lang.ClassNotFoundException' was converted to 'System.Exception' which has different behavior. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1100"' try { //UPGRADE_TODO: Format of parameters of method 'java.lang.Class.forName' are different in the equivalent in .NET. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1092"' o = SupportClass.CreateNewInstance(Type.GetType(rm)); } catch (System.Exception) { String err = "The specified class for Uberspect (" + rm + ") does not exist (or is not accessible to the current classlaoder."; error(err); throw new System.Exception(err); } if (!(o is Uberspect)) { String err = "The specified class for Uberspect (" + rm + ") does not implement org.apache.velocity.util.introspector.Uberspect." + " Velocity not initialized correctly."; error(err); throw new System.Exception(err); } uberSpect = (Uberspect)o; if (uberSpect is UberspectLoggable) { ((UberspectLoggable)uberSpect).RuntimeLogger = this; } uberSpect.init(); } else { /* * someone screwed up. Lets not fool around... */ String err = "It appears that no class was specified as the" + " Uberspect. Please ensure that all configuration" + " information is correct."; error(err); throw new System.Exception(err); } }
/// <summary> /// Load the class that implements the given command and execute it. /// </summary> /// <param name="interp"> /// the current interpreter. /// </param> /// <param name="argv"> /// command arguments. /// </param> /// <exception cref=""> /// TclException if error happens inside the real command proc. /// </exception> public TCL.CompletionCode CmdProc(Interp interp, TclObject[] argv) { Type cmdClass = null; ICommand cmd; try { cmdClass = Type.GetType(className, true); } catch (Exception) { throw new TclException(interp, "ClassNotFoundException for class \"" + className + "\""); } try { cmd = (ICommand)SupportClass.CreateNewInstance(cmdClass); } catch (UnauthorizedAccessException) { throw new TclException(interp, "IllegalAccessException for class \"" + cmdClass.FullName + "\""); } catch (InvalidCastException) { throw new TclException(interp, "ClassCastException for class \"" + cmdClass.FullName + "\""); } catch (Exception) { throw new TclException(interp, "InstantiationException for class \"" + cmdClass.FullName + "\""); } interp.CreateCommand(argv[0].ToString(), cmd); TCL.CompletionCode rc = cmd.CmdProc(interp, argv); return(rc == TCL.CompletionCode.EXIT ? TCL.CompletionCode.EXIT : TCL.CompletionCode.RETURN); }
//UPGRADE_ISSUE: Class 'java.lang.ClassLoader' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javalangClassLoader"' /// <summary> Creates an instance of an AudioDevice implementation. /// </summary> /// <param name="loader The"><code>ClassLoader</code> to use to /// load the named class, or null to use the /// system class loader. /// </param> /// <param name="name The">name of the class to load. /// </param> /// <returns> A newly-created instance of the audio device class. /// /// </returns> protected internal virtual AudioDevice instantiate(ClassLoader loader, System.String name) { AudioDevice dev = null; System.Type cls = null; if (loader == null) { //UPGRADE_TODO: Format of parameters of method 'java.lang.Class.forName' are different in the equivalent in .NET. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1092"' cls = System.Type.GetType(name); } else { //UPGRADE_ISSUE: Method 'java.lang.ClassLoader.loadClass' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javalangClassLoader"' cls = loader.loadClass(name); } System.Object o = SupportClass.CreateNewInstance(cls); dev = (AudioDevice)o; return(dev); }
public static FunctionUnit newDSFunction(string funName, Env env, CellExt1 cs) { FunctionUnit unit3; try { Type classType = (Type)hashtable_1[funName.ToLower()]; FunctionUnit unit = (FunctionUnit)SupportClass.CreateNewInstance(classType); unit.env = env; unit.cs = cs; unit3 = unit; } catch (UnauthorizedAccessException exception) { throw new SystemException(exception.Message); } catch (Exception exception2) { throw new SystemException(exception2.Message); } return(unit3); }
public virtual DataSet getDataSet(Env env, Hashtable config) { DataSet set2; if (config == null) { throw new ReportError("config is null"); } string str = Convert.ToString(config["type"]); try { DataSetFactory factory = null; if ("normal".ToUpper().Equals(str.ToUpper())) { factory = new SQLDataSetFactory(); } else if (!"complex".ToUpper().Equals(str.ToUpper())) { if (!"self".ToUpper().Equals(str.ToUpper())) { throw new ReportError(new StringBuilder("数据集").Append(config["name"]).Append("具有无法识别的类型").Append(str).ToString().ToString()); } factory = (DataSetFactory)SupportClass.CreateNewInstance(Type.GetType(Convert.ToString(config["className"]))); } else { factory = new SQLDataSetFactory(); } factory.Properties = config; set2 = factory.getDataSet(env); } catch (Exception exception) { throw new ReportError("不能产生数据集" + config["name"].ToString().ToString(), exception); } return(set2); }
protected internal override System.Object CreateInstance(System.String name, System.Type type) { return(SupportClass.CreateNewInstance(type)); }