Skip to content

Latest commit

 

History

History
42 lines (34 loc) · 1.15 KB

EXTENSIBILITY.md

File metadata and controls

42 lines (34 loc) · 1.15 KB

Persistence

Persistence engine can be extended by implementing ISapherDataRepository

MyRepositoryImplementation : ISapherDataRepository

and providing the implementation with AddPersistence.

this.serviceCollection
    .AddSapher(sapherConfig = sapherConfig
        .AddPersistenceMyRepositoryImplementation());

// or

var myRepository = new MyRepositoryImplementation();
this.serviceCollection
    .AddSapher(sapherConfig = sapherConfig
        .AddPersistence(myRepository));

Notes: ISapherDataRepository is used as a singleton. Also, if an implementation is not defined, Sapher will use in-memory persistence.

Logging

Logging engine can also be extended by implementing ILogger

MyLogger : ILogger

and providing the implementation with AddLogger

this.serviceCollection
    .AddSapher(sapherConfig = sapherConfig
        .AddLoggerMyLogger());
        
// or 

var myLogger = new MyLogger();
this.serviceCollection
    .AddSapher(sapherConfig = sapherConfig
        .AddLogger(myLogger));

Notes: ILogger is used as a singleton. Also, if an implementation is not defined, Sapher will not log anything.