Services - JsonJason/Darker.Common GitHub Wiki
Services
Services are a number of project components that usually require mocking or injecting.
In most projects you would like to be able to control things like Dates and Culture at a high level.
You may need to manage timezones, utc vs localized time, currency formats etc. with each service interface there is also a provided standard singleton that defers usage to what it would have been in the most common hard coded case.
In the case of time
IDateService date = UtcDateService.Instance;
calling date.CurrentDate
will return the same as DateTime.UtcNow
but give you the freedom of mocking and providing alternate implementations.
similarly with culture
ICultureService culture = CultureService.Instance;
calling culture.CurrentCulture
will return the same as CultureInfo.CurrentCulture
.
For most services there is also a Constant service implementation provided in case you would like to hard code the value to a statically provided one you control.
For Dates e.g:
IDateService date = new ConstantDateService(new DateTime(2015,10,21));
calling date.CurrentDate
will return the above date regardless of what date your delorean is set to.