public static IDurableTaskWorkerBuilder AddOrchestration <T>(
     this IDurableTaskWorkerBuilder builder,
     string name    = null,
     string version = null)
     where T : TaskOrchestration
 {
     return(builder.AddOrchestration(typeof(T), name, version));
 }
 public static IDurableTaskWorkerBuilder AddOrchestrationMethod(
     this IDurableTaskWorkerBuilder builder,
     Type type,
     MethodInfo methodInfo,
     string name    = null,
     string version = null)
 {
     return(builder.AddOrchestration(
                p => new MethodTaskOrchestration(ActivatorUtilities.GetServiceOrCreateInstance(p, type), methodInfo),
                name ?? NameVersionHelper.GetDefaultName(methodInfo),
                version ?? NameVersionHelper.GetDefaultVersion(methodInfo)));
 }
 protected virtual void ConigureWorker(IDurableTaskWorkerBuilder builder)
 {
     builder.AddOrchestration <EmptyOrchestration>(EmptyOrchestration.Name, EmptyOrchestration.Version);
     builder.AddOrchestration <TimerOrchestration>(TimerOrchestration.Name, TimerOrchestration.Version);
     builder.AddOrchestration <ContinueAsNewOrchestration>(ContinueAsNewOrchestration.Name, ContinueAsNewOrchestration.Version);
     builder.AddOrchestration <ContinueAsNewEmptyOrchestration>(ContinueAsNewEmptyOrchestration.Name, ContinueAsNewEmptyOrchestration.Version);
     builder.AddOrchestration <ParentOrchestration>(ParentOrchestration.Name, ParentOrchestration.Version);
     builder.AddOrchestration <ParallelTasksOrchestration>(ParallelTasksOrchestration.Name, ParallelTasksOrchestration.Version);
     builder.AddOrchestration <WaitForEventOrchestration>(WaitForEventOrchestration.Name, WaitForEventOrchestration.Version);
     builder.AddOrchestration <FibonacciRecursiveOrchestration>(FibonacciRecursiveOrchestration.Name, FibonacciRecursiveOrchestration.Version);
     builder.AddActivity <SumActivity>(SumActivity.Name, SumActivity.Version);
     builder.AddActivity <SubtractActivity>(SubtractActivity.Name, SubtractActivity.Version);
     builder.AddActivity <MeasuredDelayActivity>(MeasuredDelayActivity.Name, MeasuredDelayActivity.Version);
 }
        public static IDurableTaskWorkerBuilder AddOrchestration(
            this IDurableTaskWorkerBuilder builder,
            Type type,
            string name    = null,
            string version = null)
        {
            builder.Services.AddScoped(type, type);

            return(builder.AddOrchestration(
                       p => ActivatorUtilities.GetServiceOrCreateInstance(p, type) as TaskOrchestration,
                       name ?? NameVersionHelper.GetDefaultName(type),
                       version ?? NameVersionHelper.GetDefaultVersion(type)));
        }
        public static IDurableTaskWorkerBuilder AddOrchestrationsFromType(
            this IDurableTaskWorkerBuilder builder,
            Type type)
        {
            var typeOrchestrationAttribute = type.GetCustomAttribute <OrchestrationAttribute>();

            if (typeOrchestrationAttribute != null)
            {
                builder.AddOrchestration(type, typeOrchestrationAttribute.Name, typeOrchestrationAttribute.Version);
            }
            foreach (var methodInfo in type.GetMethods())
            {
                var orchestrationAttribute = methodInfo.GetCustomAttribute <OrchestrationAttribute>();
                if (orchestrationAttribute != null)
                {
                    builder.AddOrchestrationMethod(type, methodInfo, orchestrationAttribute.Name, orchestrationAttribute.Version);
                }
            }
            return(builder);
        }