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 AddActivity <T>(
     this IDurableTaskWorkerBuilder builder,
     string name    = null,
     string version = null)
     where T : TaskActivity
 {
     return(builder.AddActivity(typeof(T), name, version));
 }
 public static IDurableTaskWorkerBuilder AddActivityMethod(
     this IDurableTaskWorkerBuilder builder,
     Type type,
     MethodInfo methodInfo,
     string name    = null,
     string version = null)
 {
     return(builder.AddActivity(
                p => new MethodTaskActivity(ActivatorUtilities.GetServiceOrCreateInstance(p, type), methodInfo),
                name ?? NameVersionHelper.GetDefaultName(methodInfo),
                version ?? NameVersionHelper.GetDefaultVersion(methodInfo)));
 }
        public static IDurableTaskWorkerBuilder AddActivity(
            this IDurableTaskWorkerBuilder builder,
            Type type,
            string name    = null,
            string version = null)
        {
            builder.Services.AddScoped(type, type);

            return(builder.AddActivity(
                       p => ActivatorUtilities.GetServiceOrCreateInstance(p, type) as TaskActivity,
                       name ?? NameVersionHelper.GetDefaultName(type),
                       version ?? NameVersionHelper.GetDefaultVersion(type)));
        }
        public static IDurableTaskWorkerBuilder AddActivitiesFromType(
            this IDurableTaskWorkerBuilder builder,
            Type type)
        {
            var typeActivityAttribute = type.GetCustomAttribute <ActivityAttribute>();

            if (typeActivityAttribute != null)
            {
                builder.AddActivity(type, typeActivityAttribute.Name, typeActivityAttribute.Version);
            }
            foreach (var methodInfo in type.GetMethods())
            {
                var methodActivityAttribute = methodInfo.GetCustomAttribute <ActivityAttribute>();
                if (methodActivityAttribute != null)
                {
                    builder.AddActivityMethod(type, methodInfo, methodActivityAttribute.Name, methodActivityAttribute.Version);
                }
            }
            return(builder);
        }