Пример #1
0
        private static void AddDefaultWorkflowActivities(this WorkflowOptions options)
        {
            // Primitives
            options.AddActivity <CorrelateTask>()
            .AddActivity <LogTask>()
            .AddActivity <SetOutputTask>()
            .AddActivity <SetPropertyTask>();

            // Control Flow
            options.AddActivity <IfElseTask>()
            .AddActivity <ForEachTask>()
            .AddActivity <ForkTask>()
            .AddActivity <JoinTask>()
            .AddActivity <ScriptTask>()
            .AddActivity <SwitchTask>()
            .AddActivity <WhileLoopTask>();
        }
Пример #2
0
        public static IServiceCollection ConfigureWorkflows(this IServiceCollection services, Action <WorkflowOptions> setupAction = null)
        {
            WorkflowOptions options;

            if (services.Any(x => x.ServiceType == typeof(WorkflowOptions)))
            {
                var sp = services.BuildServiceProvider();
                options = sp.GetService <WorkflowOptions>();
                setupAction?.Invoke(options);
            }
            else
            {
                services.AddLogging();
                services.AddLocalization();

                services.ConfigureLiquid();
                services.ConfigureScripting();

                options = new WorkflowOptions(services);
                setupAction?.Invoke(options);
                options.AddDefaultWorkflowActivities();
                services.AddSingleton(options);

                services.AddTransient <IActivityLibrary, ActivityLibrary>();
                services.AddTransient <IWorkflowManager, WorkflowManager>();
                services.AddTransient <IDateTimeProvider, DateTimeProvider>();
                services.AddTransient <IWorkflowBuilder, WorkflowBuilder>();

                services.AddSingleton <IWorkflowTypeStore, MemoryWorkflowTypeStore>();
                services.AddSingleton <IWorkflowStore, MemoryWorkflowStore>();
                services.AddSingleton <ISecurityTokenService, SecurityTokenService>();
                services.AddSingleton <IWorkflowExpressionEvaluator, WorkflowExpressionEvaluator>();
                services.AddSingleton <IExpressionEvaluator, JavaScriptExpressionEvaluator>();
                services.AddSingleton <IExpressionEvaluator, LiquidExpressionEvaluator>();
                services.AddSingleton <IWorkflowTypeLoader, WorkflowTypeLoader>();

                services.RegisterWorkflowExecutionEventHandler <DefaultWorkflowExecutionEventHandler>();
            }

            return(services);
        }
Пример #3
0
        public ActivityLibrary(WorkflowOptions workflowOptions,
                               IServiceProvider serviceProvider,
                               ILogger <ActivityLibrary> logger)
        {
            _activityDictionary = new Lazy <IDictionary <string, IActivity> >(
                () => workflowOptions.ActivityTypes
                .Where(x => !x.IsAbstract)
                .Select(x => serviceProvider.CreateInstance <IActivity>(x))
                .OrderBy(x => x.TypeName)
                .ToDictionary(x => x.TypeName));

            _activityCategories = new Lazy <IList <LocalizedString> >(
                () => _activityDictionary.Value.Values
                .OrderBy(x => x.Category.Value)
                .Select(x => x.Category)
                .Distinct(new LocalizedStringComparer())
                .ToList());

            _serviceProvider = serviceProvider;
            _logger          = logger;
        }
 public static bool IsActivityRegistered <T>(this WorkflowOptions options) where T : IActivity
 {
     return(options.ActivityDictionary.ContainsKey(typeof(T)));
 }