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 11using MongoDB . Driver ;
22using System ;
3- using System . Linq ;
43using WorkflowCore . Interface ;
54using WorkflowCore . Models ;
65using WorkflowCore . Persistence . MongoDB . Services ;
@@ -33,5 +32,26 @@ public static WorkflowOptions UseMongoDB(
3332 } ) ;
3433 return options ;
3534 }
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+ }
3656 }
3757}
You can’t perform that action at this time.
0 commit comments