/// <summary> /// 创建并获取指定泛型类型的对象的动态代理实例,该实例在切向捕捉对象控制范围内 /// </summary> /// <param name="FullClassName"></param> /// <param name="AssemblyPath"></param> /// <param name="Parameters">参数</param> /// <returns></returns> public static T GetInstance <T>(string AssemblyPath, string FullClassName, params object[] Parameters) { T result = default(T); ClassDrive cdiv = new ClassDrive(); try { if (LemonEnvironment.GetInstance().UseProxy) { result = cdiv.ProxyInstance <T>(FullClassName, AssemblyPath, Parameters); } else { result = cdiv.Instance <T>(AssemblyPath, FullClassName, Parameters); } } catch { string str = "创建对象实例失败。 AssemblyPath:" + AssemblyPath + " FullClassName:" + FullClassName; MessageObject newmsg = new MessageObject(MessageType.Error); newmsg.Message = str; MessageFactory.GetMegBus().Send(newmsg); } return(result); }
/// <summary> /// 实例化 /// </summary> /// <param name="FullClassName"></param> /// <param name="AssemblyName"></param> /// <param name="MenuForm"></param> /// <returns></returns> public virtual object Instance(string FullClassName, string AssemblyName, IMainForm MenuForm) { string assemblyfile = System.IO.Directory.GetCurrentDirectory() + "\\Module\\" + AssemblyName + "\\" + AssemblyName + ".dll"; ClassDrive ci = new ClassDrive(); object obj = ci.Instance <object>(assemblyfile, FullClassName); if (obj != null) { if (IsTargetInterface(obj)) { obj = SetCurrency((IModule)obj, MenuForm); obj = SetModule((IModule)obj, MenuForm); } else if (this.successor != null) { obj = this.successor.Instance(FullClassName, AssemblyName, MenuForm); } else { obj = null; } } return(obj); }
/// <summary> /// 创建并获取指定泛型类型的对象的动态代理实例,使该实例在切向捕捉对象控制范围内 /// </summary> /// <param name="InitType"></param> /// <param name="Parameters">参数</param> /// <returns></returns> public static T GetInstance <T>(Type InitType, params object[] Parameters) { T result = default(T); ClassDrive cdiv = new ClassDrive(); try { if (LemonEnvironment.GetInstance().UseProxy) { result = cdiv.ProxyInstance <T>(InitType, Parameters); } else { result = cdiv.Instance <T>(InitType, Parameters); } } catch { string str = "创建对象实例失败。 " + InitType.ToString(); MessageObject newmsg = new MessageObject(MessageType.Error); newmsg.Message = str; MessageFactory.GetMegBus().Send(newmsg); } return(result); }