コード例 #1
0
        public static ElsaIndexingOptions UseElasticsearch(this ElsaIndexingOptions options, Action <ElsaElasticsearchOptions> configure)
        {
            options.Services.Configure(configure);

            options.Services
            .AddScoped <IWorkflowDefinitionSearch, WorkflowDefinitionSearch>()
            .AddScoped <IWorkflowInstanceSearch, WorkflowInstanceSearch>()
            .AddScoped <IWorkflowDefinitionIndexer, WorkflowDefinitionIndexer>()
            .AddScoped <IWorkflowInstanceIndexer, WorkflowInstanceIndexer>()
            .AddSingleton <ElasticsearchContext>()
            .AddScoped(services =>
            {
                var context   = services.GetRequiredService <ElasticsearchContext>();
                var indexName = services.GetRequiredService <IOptions <ElsaElasticsearchOptions> >().Value.WorkflowInstanceIndexName;

                return(new ElasticsearchStore <ElasticWorkflowInstance>(context, indexName));
            })
            .AddScoped(services =>
            {
                var context   = services.GetRequiredService <ElasticsearchContext>();
                var indexName = services.GetRequiredService <IOptions <ElsaElasticsearchOptions> >().Value.WorkflowDefinitionIndexName;

                return(new ElasticsearchStore <ElasticWorkflowDefinition>(context, indexName));
            })
            .AddAutoMapperProfile <ElasticsearchProfile>()
            .AddStartupTask <ElasticsearchInitializer>();

            return(options);
        }
コード例 #2
0
        public static ElsaOptionsBuilder UseIndexing(this ElsaOptionsBuilder options, Action <ElsaIndexingOptions> configure)
        {
            var indexingOptions = new ElsaIndexingOptions(options.Services);

            configure.Invoke(indexingOptions);

            ServiceRegistrar.AddMediatRClasses(options.Services, new[] { Assembly.GetExecutingAssembly() });

            return(options);
        }