protected override object ExecuteService(List <MethodParameter> methodParameters, int update, out ErrorResultTO errors, IOutputFormatter formater = null) { errors = new ErrorResultTO(); var args = new PluginInvokeArgs { AssemblyLocation = Source.AssemblyLocation, AssemblyName = Source.AssemblyName, Fullname = Service.Namespace, Method = Service.Method.Name, Parameters = Service.Method.Parameters, OutputFormatter = formater }; object result = null; try { result = PluginServiceExecutionFactory.InvokePlugin(args); } catch (Exception e) { errors.AddError(e.Message); } return(result); }
void RegularMethodExecution(Isolated <PluginRuntimeHandler> appDomain, PluginExecutionDto pluginExecutionDto, IDev2MethodInfo dev2MethodInfo, int i, int update, IDSFDataObject dataObject) { var start = DateTime.Now; pluginExecutionDto.ObjectString = ObjectResult; var result = PluginServiceExecutionFactory.InvokePlugin(appDomain, pluginExecutionDto, dev2MethodInfo, out string objString); pluginExecutionDto.ObjectString = objString; ObjectResult = objString; var pluginAction = MethodsToRun[i]; pluginAction.MethodResult = result.MethodResult; pluginAction.HasError = result.HasError; pluginAction.ErrorMessage = result.ErrorMessage; dev2MethodInfo.HasError = result.HasError; dev2MethodInfo.ErrorMessage = result.ErrorMessage; if (result.HasError) { DispatchDebugStateForMethod(pluginAction, dataObject, update, false, start); return; } AssignMethodResult(pluginAction, update, dataObject, start); if (!string.IsNullOrEmpty(ObjectName) && !pluginExecutionDto.IsStatic) { var jToken = JToken.Parse(ObjectResult) as JContainer ?? ObjectResult.DeserializeToObject(); dataObject.Environment.AddToJsonObjects(ObjectName, jToken); } }
public void PluginRuntimeHandler_InvokePlugin_WhenValidDll_ExpectValidResults() { //------------Setup for test-------------------------- var source = CreatePluginSource(); var svc = CreatePluginService(); //------------Execute Test--------------------------- using (Isolated <PluginRuntimeHandler> isolated = new Isolated <PluginRuntimeHandler>()) { var args = new PluginInvokeArgs { AssemblyLocation = source.AssemblyLocation , AssemblyName = "Foo" , Fullname = svc.Namespace , Method = svc.Method.Name , Parameters = svc.Method.Parameters }; var result = PluginServiceExecutionFactory.InvokePlugin(args); //------------Assert Results------------------------- var castResult = JsonConvert.DeserializeObject(result.ToString()) as dynamic; if (castResult != null) { StringAssert.Contains(castResult.Name.ToString(), "test data"); } else { Assert.Fail("Failed Conversion for Assert"); } } }
protected void ExecuteService(int update, out ErrorResultTO errors, IPluginAction method, INamespaceItem namespaceItem, IDSFDataObject dataObject) { errors = new ErrorResultTO(); var itrs = new List<IWarewolfIterator>(5); IWarewolfListIterator itrCollection = new WarewolfListIterator(); var methodParameters = Inputs.Select(a => new MethodParameter { EmptyToNull = a.EmptyIsNull, IsRequired = a.RequiredField, Name = a.Name, Value = a.Value, TypeName = a.TypeName }).ToList(); BuildParameterIterators(update, methodParameters.ToList(), itrCollection, itrs, dataObject); var args = new PluginInvokeArgs { AssemblyLocation = Namespace.AssemblyLocation, AssemblyName = Namespace.AssemblyName, Fullname = namespaceItem.FullName, Method = method.Method, Parameters = methodParameters }; try { while (itrCollection.HasMoreData()) { int pos = 0; foreach (var itr in itrs) { string injectVal = itrCollection.FetchNextValue(itr); var param = methodParameters.ToList()[pos]; param.Value = param.EmptyToNull && (injectVal == null || string.Compare(injectVal, string.Empty, StringComparison.InvariantCultureIgnoreCase) == 0) ? null : injectVal; pos++; } if (!IsObject) { int i = 0; foreach (var serviceOutputMapping in Outputs) { OutputDescription.DataSourceShapes[0].Paths[i].OutputExpression = DataListUtil.AddBracketsToValueIfNotExist(serviceOutputMapping.MappedTo); i++; } var outputFormatter = OutputFormatterFactory.CreateOutputFormatter(OutputDescription); args.OutputFormatter = outputFormatter; } var result = PluginServiceExecutionFactory.InvokePlugin(args).ToString(); ResponseManager = new ResponseManager { OutputDescription = OutputDescription, Outputs = Outputs, IsObject = IsObject, ObjectName = ObjectName }; ResponseManager.PushResponseIntoEnvironment(result, update, dataObject,false); } } catch (Exception e) { errors.AddError(e.Message); } }
public void PluginRuntimeHandler_InvokePlugin_WhenValidDll_ExpectValidResults() { //------------Setup for test-------------------------- var source = CreatePluginSource(); var svc = CreatePluginService(); PluginInvokeArgs args = new PluginInvokeArgs { AssemblyLocation = source.AssemblyLocation, AssemblyName = "Foo", Fullname = svc.Namespace, Method = svc.Method.Name, Parameters = svc.Method.Parameters }; //------------Execute Test--------------------------- var result = PluginServiceExecutionFactory.InvokePlugin(args); var castResult = result as DummyClassForPluginTest; //------------Assert Results------------------------- if (castResult != null) { StringAssert.Contains(castResult.Name, "test data"); } else { Assert.Fail("Failed Conversion for Assert"); } }
private void TryExecute(int update, IDSFDataObject dataObject, List <IWarewolfIterator> itrs, IWarewolfListIterator itrCollection, List <MethodParameter> methodParameters, PluginInvokeArgs args) { while (itrCollection.HasMoreData()) { var pos = 0; foreach (var itr in itrs) { var injectVal = itrCollection.FetchNextValue(itr); var param = methodParameters.ToList()[pos]; param.Value = param.EmptyToNull && (injectVal == null || string.Compare(injectVal, string.Empty, StringComparison.InvariantCultureIgnoreCase) == 0) ? null : injectVal; pos++; } if (!IsObject) { var i = 0; foreach (var serviceOutputMapping in Outputs) { OutputDescription.DataSourceShapes[0].Paths[i].OutputExpression = DataListUtil.AddBracketsToValueIfNotExist(serviceOutputMapping.MappedTo); i++; } var outputFormatter = OutputFormatterFactory.CreateOutputFormatter(OutputDescription); args.OutputFormatter = outputFormatter; } var result = PluginServiceExecutionFactory.InvokePlugin(args).ToString(); ResponseManager = new ResponseManager { OutputDescription = OutputDescription, Outputs = Outputs, IsObject = IsObject, ObjectName = ObjectName }; ResponseManager.PushResponseIntoEnvironment(result, update, dataObject, false); } }