Supports .Net Standard 2.0.
docker-compose up
db.Configurations.insert({"Name": "SiteName", "Type":"string", "IsActive": true,"ApplicationName": "ServiceA","Value":"boyner.com.tr"})
C# Type. | ConfigType |
---|---|
int | integer |
string | string |
DateTime | datetime |
bool | boolean |
float | float |
decimal | decimal |
TimeSpan | timespan |
Guid | guid |
private static IContainer _container;
_container = DependencyService.Instance.CurrentResolver;
IConfigurationReader _configurationReader = _container.Resolve<IConfigurationReader>();
Config settings for Application service name, connection string and refreshtime If you leave the ConnectionString field blank it use 'localhost' as default
ConfigSettings.ApplicationName = "ServiceA";
ConfigSettings.ConnectionString = "mongodb://localhost:27017";
ConfigSettings.RefreshTimerIntervalInMs = 5000;
After theese configuration if you add to you mongo db some config data you can call you data value
string siteName = _configurationReader.GetValue<string>("SiteName");
Console.WriteLine("Sitename: " + siteName);
bool isBasketEnabled = _configurationReader.GetValue<bool>("IsBasketEnabled");
Console.WriteLine("IsBasketEnabled" + isBasketEnabled);
You can install DynamicConfiguration from the package manager console:
PM> Install-Package DynamicConfiguration
Developed with ❤️ at Fatih Mert.