/// <summary> /// 读取入口点,执行入口点方法 /// </summary> private void StartFromCode() { if (EntryPoint != null) { EntryPoint.Start(Context); return; } string entryPointTypeName = PlugInInfo.PlugInData.EntryPoint.Type; int runtimeDllCount = PlugInInfo.PlugInData.Runtime.Assemblies.Count; for (int i = runtimeDllCount - 1; i >= 0; i--) { string runtimeAssemblyPath = PlugInInfo.PlugInData.Runtime.Assemblies[i].Path; System.Reflection.Assembly dllAssemblly = System.Reflection.Assembly.LoadFrom(runtimeAssemblyPath); Type type = dllAssemblly.GetType(entryPointTypeName); if (type != null) { object obj = Activator.CreateInstance(type); entryPoint = obj as IPlugInEntryPoint; if (EntryPoint != null) { PlugInContext context = new PlugInContext(); context.Framework = Framework.Inistace; context.PlugIn = this; this.Context = context; EntryPoint.Start(context); } //System.Reflection.MethodInfo method = type.GetMethod(ConstantString.EntryPointStartMethod); //if (method != null) //{ // PlugInContext context = new PlugInContext(); // context.Framework = Framework.Inistace; // context.PlugIn = this; // this.Context = context; // method.Invoke(obj, new object[] { context }); //} } } }
private void StopFromCode() { if (EntryPoint != null) { EntryPoint.Stop(Context); return; } string entryPointTypeName = PlugInInfo.PlugInData.EntryPoint.Type; int runtimeDllCount = PlugInInfo.PlugInData.Runtime.Assemblies.Count; for (int i = runtimeDllCount - 1; i >= 0; i--) { string runtimeAssemblyPath = PlugInInfo.PlugInData.Runtime.Assemblies[i].Path; System.Reflection.Assembly dllAssemblly = System.Reflection.Assembly.LoadFrom(runtimeAssemblyPath); Type type = dllAssemblly.GetType(entryPointTypeName); if (type != null) { object obj = Activator.CreateInstance(type); entryPoint = obj as IPlugInEntryPoint; if (EntryPoint != null) { PlugInContext context = new PlugInContext(); context.Framework = Framework.Inistace; context.PlugIn = this; this.Context = context; EntryPoint.Stop(Context); } //if (type != null) //{ // System.Reflection.MethodInfo method = type.GetMethod(ConstantString.EntryPointStopMethod); // if (method != null) // { // PlugInContext context = new PlugInContext(); // method.Invoke(obj, new object[] { context }); // } //} } } }