コード例 #1
0
ファイル: CommandOrchestrator.cs プロジェクト: 0xCM/Meta.Core
 /// <summary>
 /// Initializes a new orchestrator
 /// </summary>
 /// <param name="context">The orchestation context</param>
 public CommandOrchestrator(IApplicationContext context, ICommandExecutionService <TSpec, TPayload> CommandPattern, CommandOrchestrationSettings Settings)
     : base(context)
 {
     this.CommandPattern = CommandPattern;
     this.cts            = new CancellationTokenSource();
     this.ct             = cts.Token;
     this.Settings       = Settings;
 }
コード例 #2
0
 public void Start(Type SpecType, CommandOrchestrationSettings Settings)
 {
     try
     {
         Orchestrators.GetOrAdd(SpecType, t => GetOrchestrator(t, Settings ?? DefaultCommandSettings));
     }
     catch (Exception e)
     {
         Notify(OrchestrationStartError(SpecType, e));
     }
 }
コード例 #3
0
 public void Start(ICommandExecutionService pattern, CommandOrchestrationSettings Settings)
 {
     try
     {
         Orchestrators.GetOrAdd(pattern.SpecType, _ => GetOrchestrator(pattern, Settings ?? DefaultCommandSettings));
     }
     catch (Exception e)
     {
         Notify(OrchestrationStartError(pattern.SpecType, e));
     }
 }
コード例 #4
0
    ICommandOrchestrator GetOrchestrator(Type SpecType, CommandOrchestrationSettings Settings)
    {
        var orchestrator = C.CPS().Orchestrator(SpecType, true, Settings);

        return(orchestrator.Require());;
    }
コード例 #5
0
    ICommandOrchestrator GetOrchestrator(ICommandExecutionService pattern, CommandOrchestrationSettings Settings)
    {
        var orchestrator = C.CPS().Orchestrator(pattern, true, Settings);

        return(orchestrator.Require());;
    }
コード例 #6
0
 public CommandOrchestrationController(IApplicationContext context)
     : base(context)
 {
     DefaultCommandSettings = context.Settings <CommandOrchestrationSettings>();
 }
コード例 #7
0
 ICommandOrchestrator <TSpec, TPayload> CreateOrchestration <TSpec, TPayload>
     (ICommandExecutionService <TSpec, TPayload> pattern, CommandOrchestrationSettings settings)
     where TSpec : CommandSpec <TSpec, TPayload>, new()
 => new CommandOrchestrator <TSpec, TPayload>(Context, pattern, settings);
コード例 #8
0
 public Option <ICommandOrchestrator> Orchestrator(Type SpecType, bool start, CommandOrchestrationSettings settings)
 => from p in Pattern(SpecType)
 from o in Orchestrator(p, start, settings)
 select o;
コード例 #9
0
 public Option <ICommandOrchestrator> Orchestrator(ICommandExecutionService pattern, bool start, CommandOrchestrationSettings settings)
 => Try(() =>
 {
     var orcType = typeof(CommandOrchestrator <,>).MakeGenericType(pattern.SpecType, pattern.PayloadType);
     return(some((ICommandOrchestrator)Activator.CreateInstance(orcType, Context, pattern, settings)).OnSome(o =>
     {
         if (start)
         {
             o.Start();
         }
     }));
 });
コード例 #10
0
 Option <ICommandOrchestrator <TSpec, TPayload> > ICommandPatternSystem.Orchestrator <TSpec, TPayload>(bool start, CommandOrchestrationSettings settings)
 => Try(() =>
 {
     var orchestrator
                 = from p in Pattern <TSpec, TPayload>()
           let s = settings ?? Context.Settings <CommandOrchestrationSettings>()
                   let manager = CreateOrchestration(p, settings)
                                 select manager;
     return(start ?
            orchestrator.OnSome(o => o.Start()) : orchestrator);
 });