Ejemplo n.º 1
0
        PointAsyncArg <TEnum, TArg>(this  ISequencerUC sequencer,
                                    SeqPointTypeUC seqPointTypeUC,
                                    TEnum registration,
                                    Func <bool> condition,
                                    TArg arg,
                                    Action <object> injectContinuation = null)
            where TEnum : struct
        {
            SequencerRegisterUC register = sequencer as SequencerRegisterUC;

            if (register == null || condition == null || !condition())
            {
                return(CompletedAwaiter);
            }

            ISequencerExceptionRegister exceptionRegister = register.ExceptionRegister.TryReThrowException();
            ISequencerTaskRegister      taskRegister      = register.TaskRegister;

            ISequencerPointUC <TEnum> seqPoint = register.TryGet(registration);

            return
                (seqPoint?.ProductionPoint(taskRegister, exceptionRegister, seqPointTypeUC, arg, injectContinuation)
                 ?? CompletedAwaiter
                );
        }
Ejemplo n.º 2
0
        public static ISequencerUC Throw(this   ISequencerUC sequencer,
                                         Func <bool> condition,
                                         Exception innerException = null,
                                         string message           = null,
                                         int skipStackFrames      = 2,
                                         [CallerMemberName] string calllerName   = "",
                                         [CallerFilePath] string callerFileName  = "",
                                         [CallerLineNumber] int callerLineNumber = 0)
        {
            SequencerRegisterUC register = sequencer as SequencerRegisterUC;

            if (register == null || condition == null || !condition())
            {
                return(sequencer);
            }

            string msg = string.Empty;

            msg += $"[{nameof(ISequencerUC)}.{nameof(Throw)}]";
            msg += $"[msg: {message ?? string.Empty}]";
            msg += $"[MethodName:{calllerName}]";
            msg += $"[Line:{callerLineNumber}]";
            msg += $"[FileName:{callerFileName}]";

            Exception ex = innerException != null
                        ? new StackTraceExceptionUC(msg, skipStackFrames, innerException)
                        : new StackTraceExceptionUC(msg, skipStackFrames)
            ;

            register.ExceptionRegister.RegisterException(ex);

            return(sequencer);
        }
Ejemplo n.º 3
0
        public static ISequencerUC Run <TResult>(this ISequencerUC sequencer, Func <TResult> func)
        {
            SequencerRegisterUC register = sequencer as SequencerRegisterUC;

            if (register == null)
            {
                return(sequencer);
            }

            register.ExceptionRegister.TryReThrowException();
            ISequencerTaskRegister taskRegister = register.TaskRegister;

            taskRegister.Run(func);
            return(sequencer);
        }
Ejemplo n.º 4
0
        public static ISequencerUC Run(this ISequencerUC sequencer, object obj, Action <ISequencerUC, object> action)
        {
            SequencerRegisterUC register = sequencer as SequencerRegisterUC;

            if (register == null)
            {
                return(sequencer);
            }

            register.ExceptionRegister.TryReThrowException();
            ISequencerTaskRegister taskRegister = register.TaskRegister;

            taskRegister.Run(obj, action);
            return(sequencer);
        }
Ejemplo n.º 5
0
        ISequencerUC Run <TParameter>(this       ISequencerUC sequencer,
                                      TParameter parameter,
                                      Action <ISequencerUC, TParameter> action)
        {
            SequencerRegisterUC register = sequencer as SequencerRegisterUC;

            if (register == null)
            {
                return(sequencer);
            }

            register.ExceptionRegister.TryReThrowException();
            ISequencerTaskRegister taskRegister = register.TaskRegister;

            taskRegister.Run(parameter, action);
            return(sequencer);
        }