public IDev2MethodInfo Run(IDev2MethodInfo dev2MethodInfo, PluginExecutionDto dto, out string objectString) { try { var args = dto.Args; var tryLoadAssembly = _assemblyLoader.TryLoadAssembly(args.AssemblyLocation, args.AssemblyName, out Assembly loadedAssembly); if (!tryLoadAssembly) { throw new Exception(args.AssemblyName + "Not found"); } ExecutePlugin(dto, args, loadedAssembly, dev2MethodInfo); objectString = dto.ObjectString; return(dev2MethodInfo); } catch (Exception e) { if (e.InnerException != null) { dev2MethodInfo.HasError = true; dev2MethodInfo.ErrorMessage = e.InnerException.Message; Dev2Logger.Error(e, GlobalConstants.WarewolfError); objectString = dto.ObjectString; return(dev2MethodInfo); } dev2MethodInfo.HasError = true; dev2MethodInfo.ErrorMessage = e.Message; Dev2Logger.Error(e, GlobalConstants.WarewolfError); throw; } }
public PluginExecutionDto ExecuteConstructor(PluginExecutionDto dto) { if (!dto.Args.PluginConstructor.IsExistingObject) { dto = CreateInstance(dto.Args); } return(dto); }
void ExecutePlugin(PluginExecutionDto objectToRun, PluginInvokeArgs setupInfo, Assembly loadedAssembly, IDev2MethodInfo dev2MethodInfo) { VerifyArgument.IsNotNull("objectToRun", objectToRun); VerifyArgument.IsNotNull("loadedAssembly", loadedAssembly); VerifyArgument.IsNotNull("setupInfo", setupInfo); var type = loadedAssembly.GetType(setupInfo.Fullname); var knownBinder = new KnownTypesBinder(); loadedAssembly.ExportedTypes.ForEach(t => knownBinder.KnownTypes.Add(t)); if (objectToRun.IsStatic) { ExecuteSingleMethod(type, null, InvokeMethodsAction, loadedAssembly, dev2MethodInfo); return; } var instance = objectToRun.ObjectString.DeserializeToObject(type, knownBinder); ExecuteSingleMethod(type, instance, InvokeMethodsAction, loadedAssembly, dev2MethodInfo); objectToRun.ObjectString = instance.SerializeToJsonString(knownBinder);// }
public static PluginExecutionDto ExecuteConstructor(Isolated <PluginRuntimeHandler> appDomain, PluginExecutionDto dto) => appDomain.Value.ExecuteConstructor(dto);
public static IDev2MethodInfo InvokePlugin(Isolated <PluginRuntimeHandler> appDomain, PluginExecutionDto dto, IDev2MethodInfo dev2MethodInfo, out string objString) { var invokePlugin = appDomain.Value.Run(dev2MethodInfo, dto, out string objectString); objString = objectString; return(invokePlugin); }