File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed
src/providers/WorkflowCore.Persistence.MongoDB Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change 1
1
using MongoDB . Driver ;
2
2
using System ;
3
- using System . Linq ;
4
3
using WorkflowCore . Interface ;
5
4
using WorkflowCore . Models ;
6
5
using WorkflowCore . Persistence . MongoDB . Services ;
@@ -33,5 +32,26 @@ public static WorkflowOptions UseMongoDB(
33
32
} ) ;
34
33
return options ;
35
34
}
35
+
36
+ public static WorkflowOptions UseMongoDB (
37
+ this WorkflowOptions options ,
38
+ Func < IServiceProvider , IMongoDatabase > createDatabase )
39
+ {
40
+ if ( options == null ) throw new ArgumentNullException ( nameof ( options ) ) ;
41
+ if ( createDatabase == null ) throw new ArgumentNullException ( nameof ( createDatabase ) ) ;
42
+
43
+ options . UsePersistence ( sp =>
44
+ {
45
+ var db = createDatabase ( sp ) ;
46
+ return new MongoPersistenceProvider ( db ) ;
47
+ } ) ;
48
+ options . Services . AddTransient < IWorkflowPurger > ( sp =>
49
+ {
50
+ var db = createDatabase ( sp ) ;
51
+ return new WorkflowPurger ( db ) ;
52
+ } ) ;
53
+
54
+ return options ;
55
+ }
36
56
}
37
57
}
You can’t perform that action at this time.
0 commit comments