public object callFunction(EnterpriseFunction function, IInfoContext info, FunctionContext context) { #if DEBUG Stopwatch timeOperations = Stopwatch.StartNew(); #endif try { if (main.infoctx.DebugMode) { getLogger().Debug("Calling Regular function " + function.getName()); } return(function.execute(info, context)); } finally { #if DEBUG timeOperations.Stop(); getLogger().Debug("Called function " + function.getName() + " in " + timeOperations.ElapsedMilliseconds + "ms"); #endif } }
/// <summary> /// Chiama una funzione. /// </summary> /// <param name="function"> la funzione da chiamare. </param> /// <param name="worker"> il worker che sta eseguendo la sessione. </param> /// <param name="context"> il contesto della chiamata. /// /// @return il risultato della chiamata. /// </param> /// <exception cref="FunctionNotFoundException"> se la classe non � definita nel sistema. </exception> /// <exception cref="Exception"> se si verifica un errore. </exception> public Task <T> callFunctionAsync <T>(EnterpriseFunction function, IInfoContext info, FunctionContext context) { #if DEBUG Stopwatch timeOperations = Stopwatch.StartNew(); #endif try { if (function.isAsyncMethod() || function.isYieldMethod()) { if (main.infoctx.DebugMode) { getLogger().Debug("Calling Async function " + function.getName()); } return(function.executeGenericAsync <T>(info, context)); } else { if (main.infoctx.DebugMode) { getLogger().Debug("Calling Awaitable function " + function.getName()); } var t = Task.Run <T>(async() => { return(await function.executeGenericAsync <T>(info, context)); }); return(t); } } finally { #if DEBUG timeOperations.Stop(); getLogger().Debug("Called functionAsync " + function.getName() + " in " + timeOperations.ElapsedMilliseconds + "ms"); #endif } }
public virtual void removeFunction(EnterpriseFunction function) { string functionName = function.getName(); if (function is MessageHandler) { MessageHandler handler = (MessageHandler)function; string[] msgTypes = handler.getTargetTypes(); for (int i = 0; i < msgTypes.Length; i++) { string msgType = msgTypes[i]; defaultHandlersMap.Remove(msgType); } } defaultApplicationMap.Remove(functionName); }
protected virtual EnterpriseFunction addFunction(Type clazz, string applicationType, string functionName) { EnterpriseFunction function = Activator.CreateInstance(clazz) as EnterpriseFunction; if (functionName == null) { functionName = function.getName(); } if (IsSubclassOfRawGeneric(clazz, "AbstractEnterpriseAsync")) { function.setHasAsynMethod(IsAsyncMethod(clazz, "executeAsync")); } else { function.setHasAsynMethod(IsAsyncMethod(clazz, "executeGenericAsync")); } EnterpriseFunction functionloaded = LoadFunction(function, applicationType, functionName, null); return(functionloaded); }