Пример #1
0
        public static IConnectorLinker <T> Conditional <T>(this IConnectorLinker <T> parent, Predicate <T> predicate, Action <IConnectorLinker <T> > buildChain)
        {
            var connector = new ConditionalSubChainConnector <T>(predicate, buildChain, parent.Context);

            parent.Link(connector);
            return(connector);
        }
Пример #2
0
        internal static IConnectorLinker <T> TestDelay <T>(
            this IConnectorLinker <T> parent,
            int millisecondsDelay)
        {
            var next = new DelayConnector <T>(millisecondsDelay, parent.Context);

            return(parent.Link(next));
        }
Пример #3
0
        public static IConnectorLinker <TOutput> Map <T, TOutput>(this IConnectorLinker <T> parent,
                                                                  MapperDelegate <T, TOutput> mapper)
        {
            var connector = new MappingConnector <T, TOutput>(mapper, parent.Context);

            parent.Link(connector);
            return(connector);
        }
Пример #4
0
 public override void ConfigureRootConnector(IConnectorLinker <Signal> root)
 {
     root.Link <GetLoanInquiry, LoanInquiry>()
     .Link <CreateLoanApplication, LoanApplication>()
     .Conditional(CreditScoreIsBad, builder => builder
                  .Link <DenyLoan, Signal>()
                  .Complete("Denied")
                  )
     .Link <CreateLoanContract, LoanContract>()
     .Link <ApproveLoan, Signal>();
 }
Пример #5
0
 public override void ConfigureRootConnector(IConnectorLinker <Signal> root)
 {
     root.Link <GetLoanInquiry, LoanInquiry>()
     .Link <CreateLoanApplication, LoanApplication>()
     .If(application => !CreditScoreIsValid(application), then => then
         .Link <DenyLoan, Signal>()
         )
     .If(CreditScoreIsValid, then => then
         .Link <CreateLoanContract, LoanContract>()
         .Link <ApproveLoan, Signal>()
         );
 }
Пример #6
0
        internal static IConnectorLinker <T> TestInspect <T>(
            this IConnectorLinker <T> parent,
            InitAction?onInit           = null,
            ProcessAction <T>?onProcess = null,
            DisposeAction?onDispose     = null)
        {
            var next = new TestInspectConnector <T>(onInit, parent.Context)
            {
                ProcessAction = onProcess,
                DisposeAction = onDispose
            };

            return(parent.Link(next));
        }
Пример #7
0
 public override void ConfigureRootConnector(IConnectorLinker <string> root)
 {
     root.SubChain(subChain => subChain
                   .Link <GenerateArray, int[]>("GenerateArray")
                   .Each(each => each
                         .If(IsDivisibleBy3, then => then
                             .Map(_ => "Fizz")
                             .Link <LogInformation <string>, string>()
                             )
                         .If(IsDivisibleBy5, then => then
                             .Map(_ => "Buzz")
                             .Link <LogInformation <string>, string>()
                             )
                         .If(i => !IsDivisibleBy3(i) && !IsDivisibleBy5(i), then => then
                             .Link <LogInformation <int>, int>()
                             )))
     .Link <StringToDateTime, DateTime>()
     .Link <LogDateTime, DateTime>();
 }
Пример #8
0
 public override void ConfigureRootConnector(IConnectorLinker <string> root)
 {
     root.Conditional(string.IsNullOrEmpty, _ => _
                      .Complete("Payload is empty"))
     .SubChain(subChain => subChain
               .Link <GenerateArray, int[]>("GenerateArray")
               .Each(each => each
                     .Conditional(IsDivisibleBy3, then => then
                                  .Map(_ => "Fizz")
                                  .Link <LogInformation <string>, string>()
                                  )
                     .Conditional(IsDivisibleBy5, then => then
                                  .Map(_ => "Buzz")
                                  .Link <LogInformation <string>, string>()
                                  )
                     .Conditional(i => !IsDivisibleBy3(i) && !IsDivisibleBy5(i), then => then
                                  .Link <LogInformation <int>, int>()
                                  )))
     .Link <StringToDateTime, DateTime>()
     .Link <LogDateTime, DateTime>();
 }
Пример #9
0
        public static IConnectorLinker <IReadOnlyList <T> > Each <T>(this IConnectorLinker <IReadOnlyList <T> > parent, Action <IConnectorLinker <T> > buildChain)
        {
            var connector = new EnumerationConnector <T>(buildChain, parent.Context);

            return(parent.Link(connector));
        }
Пример #10
0
        public static void Complete <T>(this IConnectorLinker <T> parent, string reason)
        {
            var connector = new CompletionConnector <T>(reason, parent.Context);

            parent.Link(connector);
        }
Пример #11
0
        public static IConnectorLinker <T> SubChain <T>(this IConnectorLinker <T> parent, Action <IConnectorLinker <T> > buildChain)
        {
            var connector = new SubChainConnector <T>(buildChain, parent.Context);

            return(parent.Link(connector));
        }
Пример #12
0
 public override void ConfigureRootConnector(IConnectorLinker <Order> root)
 {
     root.Link <PrintOrderToConsole, Order>();
 }
Пример #13
0
 public override void ConfigureRootConnector(IConnectorLinker <T> root)
 {
     ConfigureRootAction?.Invoke(root);
 }
Пример #14
0
 public abstract void ConfigureRootConnector(IConnectorLinker <T> root);
Пример #15
0
 public override void ConfigureRootConnector(IConnectorLinker <HttpTestPayload> root)
 {
     root.Map(x => x);
 }