Example #1
0
        public Task <T> callMessageHandlerAsync <T>(IInfoContext info, FunctionContext context)
        {
            MessageHandler messageHandler = getMessageHandler(info.TypeApplication, context.type);

            return(callFunctionAsync <T>(messageHandler, info, context));
        }
Example #2
0
 public static FunctionContext AddType(this FunctionContext fctx, Enum e)
 {
     fctx.type = e.ToString();
     return(fctx);
 }
Example #3
0
 /// <summary>
 /// FunctionContext copy
 /// </summary>
 /// <param name="context">	il contesto di esecuzione da copiare. </param>
 public FunctionContext(FunctionContext context)
 {
     this.msg       = context.msg;
     this.type      = context.type;
     this._mapIndex = new Dictionary <string, object>(context._mapIndex);
 }
Example #4
0
        public static FunctionContext NewFunctionContext(Enum e)
        {
            FunctionContext fctx = new FunctionContext(type: e.ToString());

            return(fctx);
        }
Example #5
0
        public static FunctionContext NewFunctionContext(Enum e, string msg)
        {
            FunctionContext fctx = new FunctionContext(type: e.ToString(), msg: msg);

            return(fctx);
        }
Example #6
0
 /// <summary>
 /// Call an Async Message Handler by FunctionContext.Type
 /// </summary>
 public virtual Task <T> CallMessageHandlerAsync <T>(FunctionContext context)
 {
     return(functionCaller.callMessageHandlerAsync <T>(this.infoctx, context));
 }
Example #7
0
 /// <summary>
 /// Call a Message Handler by FunctionContext.Type
 /// </summary>
 public virtual T CallMessageHandler <T>(FunctionContext context)
 {
     return((T)functionCaller.callMessageHandler(this.infoctx, context));
 }
Example #8
0
 public virtual void DispatchToScheduledExecution(FunctionContext context)
 {
     functionCaller.dispatchMessageToScheduledExecution(context);
 }
Example #9
0
 /// <summary>
 ///  Dispatch a message(FunctionContext) to listener by FunctionContext.Type
 /// </summary>
 public virtual Dictionary <string, object> DispatchToListeners(FunctionContext context)
 {
     return(functionCaller.dispatchMessageToListeners(context));
 }
Example #10
0
 public abstract Task <T2> addContextToAsyncQueue(FunctionContext fctx);
Example #11
0
 /// <summary>
 /// Async Dispatch a message(FunctionContext) to listener by FunctionContext.Type
 /// </summary>
 public virtual Dictionary <string, Task <object> > DispatchAsyncToListenersGetTasks(FunctionContext context)
 {
     return(functionCaller.dispatchMessageToAsyncListenersGetTasks(context));
 }
Example #12
0
 public abstract override object addContextToQueue(FunctionContext fctx);
Example #13
0
        public virtual Dictionary <string, Task <object> > dispatchMessageToAsyncListenersGetTasks(FunctionContext context)
        {
            Dictionary <string, Task <object> > tasksDict = new Dictionary <string, Task <object> >();

            if (listenerMapDataType.ContainsKey(context.type))
            {
                for (int i = 0; i < listenerMapDataType[context.type].Count; i++)
                {
#if DEBUG
                    Stopwatch timeOperations = Stopwatch.StartNew();
#endif
                    AbstractListener ablistworker = (AbstractListener)listenerMapDataType[context.type][i];
                    try
                    {
                        Task <object> task;
                        if (ablistworker.isAsyncMethod() || ablistworker.isYieldMethod())
                        {
                            if (main.infoctx.DebugMode)
                            {
                                getLogger().Debug("Calling Async dispatch " + ablistworker.getName());
                            }
                            task = ablistworker.addContextToGenericAsyncQueue(context);
                        }
                        else
                        {
                            if (main.infoctx.DebugMode)
                            {
                                getLogger().Debug("Calling Awaitable dispatch " + ablistworker.getName());
                            }
                            task = Task.Run <object>(async() =>
                            {
                                return(await ablistworker.addContextToGenericAsyncQueue(context));
                            });
                        }
                        tasksDict.Add(ablistworker.getName(), task);
                    }
                    finally
                    {
#if DEBUG
                        timeOperations.Stop();
                        getLogger().Debug("Dispatched MessageAsync to " + ablistworker.getName() + " in " + timeOperations.ElapsedMilliseconds + "ms");
#endif
                    }
                }
            }
            else
            {
                getLogger().Warning("Not Found listener for " + context.type);
            }

            return(tasksDict);
        }
Example #14
0
        public object callMessageHandler(IInfoContext info, FunctionContext context)
        {
            MessageHandler messageHandler = getMessageHandler(info.TypeApplication, context.type);

            return(callFunction(messageHandler, info, context));
        }
Example #15
0
        /// <summary>
        /// Starts the Task, scheduling it for execution to the current TaskScheduler.
        /// </summary>
        /// <param name="functionName">	Function Name. </param>
        /// <param name="context">	Params that can be passed to the function using FunctionContext. </param>
        /// <param name="info">    Class that implements IInfoContext. </param>
        public virtual void CallSynchronizedTaskFunction(string functionName, IInfoContext info, FunctionContext context)
        {
            WorkerTask asyncWorker = new WorkerTask(this, info, functionName, context);

            asyncWorker.init();
            Task runner = new Task(asyncWorker.run);

            runner.Start();
            //return runner;
            //return Task.Run(() => asyncWorker.run());
        }
Example #16
0
 public virtual Task <object> DispatchAsyncToSingleListener(FunctionContext ctx, string functionName)
 {
     return(functionCaller.dispatchMessageToAsyncSingleListener(ctx, functionName));
 }
Example #17
0
 /// <summary>
 /// Starts the Task, scheduling it for execution to the current TaskScheduler.
 /// <seealso cref="callThreadFunction( functionName,  info,  context)"/>
 /// </summary>
 public virtual void CallSynchronizedTaskFunction(string functionName, FunctionContext context)
 {
     CallSynchronizedTaskFunction(functionName, this.infoctx, context);
 }
Example #18
0
 public virtual void DispatchToScheduledExecution(FunctionContext ctx, string functionName)
 {
     functionCaller.dispatchMessageToSingleScheduledExecution(ctx, functionName);
 }
Example #19
0
 /// <summary>
 /// Call a Message Handler by FunctionContext.Type
 /// </summary>
 public virtual object CallMessageHandler(FunctionContext context)
 {
     return(functionCaller.callMessageHandler(this.infoctx, context));
 }
Example #20
0
 public virtual object DispatchToSingleListener(FunctionContext ctx, string functionName)
 {
     return(functionCaller.dispatchMessageToSingleListener(ctx, functionName));
 }
Example #21
0
        public static FunctionContext NewFunctionContext()
        {
            FunctionContext fctx = new FunctionContext();

            return(fctx);
        }
Example #22
0
 /// <summary>
 /// Call A Function in Async
 /// </summary>
 /// <param name="functionName">	Function Name. </param>
 /// <param name="context">	Params that can be passed to the function using FunctionContext. </param>
 /// <param name="info">    Class that implements IInfoContext. </param>
 public virtual Task <T> CallFunctionAsync <T>(string functionName, IInfoContext info, FunctionContext context)
 {
     return(functionCaller.callFunctionAsync <T>(functionName, info, context));
 }
Example #23
0
        public static FunctionContext NewFunctionContext(string type, string msg)
        {
            FunctionContext fctx = new FunctionContext(type: type, msg: msg);

            return(fctx);
        }
Example #24
0
 /// <summary>
 /// Call a Regular Function
 /// <seealso cref="callFunction(functionName,info,context)"/>
 /// </summary>
 public virtual T CallFunction <T>(string functionName, FunctionContext context)
 {
     return(CallFunction <T>(functionName, this.infoctx, context));
 }
Example #25
0
 public static FunctionContext AddType(this FunctionContext fctx, string newtype)
 {
     fctx.type = newtype;
     return(fctx);
 }
Example #26
0
 /// <summary>
 /// Call a Regular Function
 /// </summary>
 /// <param name="functionName">	Function Name. </param>
 /// <param name="context">	Params that can be passed to the function using FunctionContext. </param>
 /// <param name="info">    Class that implements IInfoContext. </param>
 /// <returns>Return an object result</returns>
 public virtual object CallFunction(string functionName, IInfoContext info, FunctionContext context)
 {
     return(functionCaller.callFunction(functionName, info, context));
 }
Example #27
0
 public static FunctionContext AddParam(this FunctionContext fctx, string sindex, object param)
 {
     fctx.setParam(sindex, param);
     return(fctx);
 }
Example #28
0
 /// <summary>
 /// Call a Regular Function
 /// <seealso cref="callFunction(functionName,info,context)"/>
 /// </summary>
 public virtual object CallFunction(string functionName, FunctionContext context)
 {
     return(CallFunction(functionName, this.infoctx, context));
 }
 /// <summary>
 /// add async at abstract function
 /// </summary>
 public abstract override Task <T> executeGenericAsync <T>(IInfoContext info, FunctionContext context);
Example #30
0
        /// <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
            }
        }