public object Invoke(Basics.Context.Request.HttpMethod httpMethod, string[] classNames, string functionName, object[] functionParams, bool instanceExecute, ExecuterTypes executerType) { if (string.IsNullOrEmpty(functionName)) { throw new ArgumentNullException(nameof(functionName)); } functionParams ??= new object[] { }; string executionId = Guid.NewGuid().ToString(); object result = null; DomainExecutable domainInstance = this.LoadDomainExecutable(out Exception exception); if (exception != null) { return(exception); } try { Type assemblyObject = classNames != null ? this._AssemblyDll.GetType($"Xeora.Domain.{string.Join("+", classNames)}", true, true) : domainInstance.GetType(); MethodInfo assemblyMethod = this.GetAssemblyMethod(ref assemblyObject, httpMethod, functionName, ref functionParams, executerType); if (assemblyMethod == null) { return(this.GetMethodException(httpMethod, classNames, functionName, functionParams)); } ApplicationContext.InvokePreExecution(domainInstance, executionId, assemblyMethod); result = this.InvokeMethod(instanceExecute, assemblyObject, assemblyMethod, functionParams); } catch (Exception ex) { return(this.GetExecutionError(classNames, functionName, functionParams, ex)); } finally { ApplicationContext.InvokePostExecution(domainInstance, executionId, ref result); } return(result); }
private static void InvokePostExecution(DomainExecutable domainInstance, string executionId, ref object result) { try { domainInstance.PostExecute(executionId, ref result); } catch (Exception ex) { if (ex.InnerException != null) { ex = ex.InnerException; } Basics.Console.Push( "Execution Exception...", ex.Message, ex.ToString(), false, true, type: Basics.Console.Type.Error); } }
private static void InvokePreExecution(DomainExecutable domainInstance, string executionId, MethodInfo assemblyMethod) { try { domainInstance.PreExecute(executionId, assemblyMethod); } catch (Exception ex) { if (ex.InnerException != null) { ex = ex.InnerException; } Basics.Console.Push( "Execution Exception...", ex.Message, ex.ToString(), false, true, type: Basics.Console.Type.Error); } }