Ridavei.Settings
4.0.0
See the version list below for details.
dotnet add package Ridavei.Settings --version 4.0.0
NuGet\Install-Package Ridavei.Settings -Version 4.0.0
<PackageReference Include="Ridavei.Settings" Version="4.0.0" />
paket add Ridavei.Settings --version 4.0.0
#r "nuget: Ridavei.Settings, 4.0.0"
// Install Ridavei.Settings as a Cake Addin #addin nuget:?package=Ridavei.Settings&version=4.0.0 // Install Ridavei.Settings as a Cake Tool #tool nuget:?package=Ridavei.Settings&version=4.0.0
Ridavei.Settings
Latest release
What is Settings?
Ridavei.Settings is a cross-platform library created to ease getting and setting values in settings manager.
The settings class implement the IDisposable interface to dispose objects that are created by the extensions.
Examples in using Settings
Get settings and then change and retrieve its values.
using Ridavei.Settings;
using Ridavei.Settings.Base;
namespace TestProgram
{
class Program
{
public static void Main(string[] args)
{
SettingsBuilder settingsBuilder = SettingsBuilder
.CreateBuilder()
.SetManager(YOUR_MANAGER_CLASS);
using (ASettings settings = settingsBuilder.GetSettings("DictionaryName")
/*you can use the GetOrCreateSettings method if you are not sure if the settings dictionary exists*/)
{
//You can use settings.Get("ExampleKey", "DefaultValue") if you want to retrieve the default value if the key doesn't exists.
string value = settings.Get("ExampleKey");
settings.Set("AnotherKey", "NewValue");
}
}
}
}
Get all keys with their values from settings.
using System.Collections.Generic;
using Ridavei.Settings;
using Ridavei.Settings.Base;
namespace TestProgram
{
class Program
{
public static void Main(string[] args)
{
SettingsBuilder settingsBuilder = SettingsBuilder
.CreateBuilder()
.SetManager(YOUR_MANAGER_CLASS);
using (ASettings settings = settingsBuilder.GetSettings("DictionaryName")
/*you can use the GetOrCreateSettings method if you are not sure if the settings dictionary exists*/)
{
//Returns the IReadOnlyDictionary to prevent from value changing.
IReadOnlyDictionary<string, string> dict = settings.GetAll();
}
}
}
}
Changing a set of keys.
using System.Collections.Generic;
using Ridavei.Settings;
using Ridavei.Settings.Base;
namespace TestProgram
{
class Program
{
public static void Main(string[] args)
{
Dictionary<string, string> newValues = new Dictionary<string, string>();
newValues.Add("NewKey1", "NewValue1");
SettingsBuilder settingsBuilder = SettingsBuilder
.CreateBuilder()
.SetManager(YOUR_MANAGER_CLASS);
using (ASettings settings = settingsBuilder.GetSettings("DictionaryName")
/*you can use the GetOrCreateSettings method if you are not sure if the settings dictionary exists*/)
{
settings.Set(newValues);
}
}
}
}
Caching
For caching it uses IDistributedCache.
To use the cache for storing the settings values you can use the SetDistributedCache
method.
builder.SetDistributedCache(IDistributedCache distributedCache, int cacheTimeout);
Example of creating extensions
using System.Collections.Generic;
using Ridavei.Settings;
using Ridavei.Settings.Base;
namespace TestProgram
{
public class Program
{
public static void Main(string[] args)
{
SettingsBuilder settingsBuilder = SettingsBuilder
.CreateBuilder()
.UseExampleManager();
using (ASettings settings = settingsBuilder.GetSettings("ExampleDictionary"))
{
//Operations on the settings
}
}
}
public static class Ext
{
public static SettingsBuilder UseExampleManager(this SettingsBuilder builder)
{
return builder.SetManager(new ExampleManager());
}
}
public class ExampleManager : AManager
{
protected override ASettings CreateSettingsObject(string dictionaryName)
{
return new ExampleSettings(dictionaryName);
}
protected override bool TryGetSettingsObject(string dictionaryName, out ASettings settings)
{
settings = new ExampleSettings(dictionaryName);
return true;
}
}
public class ExampleSettings : ASettings
{
public ExampleSettings(string dictionaryName) : base(dictionaryName) { }
protected override IReadOnlyDictionary<string, string> GetAllValues()
{
return new Dictionary<string, string>();
}
protected override bool TryGetValue(string key, out string value)
{
value = "Example";
return true;
}
protected override void SetValue(string key, string value) { }
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.Extensions.Caching.Abstractions (>= 7.0.0)
- System.Text.Json (>= 7.0.2)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on Ridavei.Settings:
Package | Downloads |
---|---|
Ridavei.Settings.InMemory
Builder extension to store settings keys and values in a Dictionary. |
|
Ridavei.Settings.Registry
Builder extension to store settings keys and values in Windows Registry. |
|
Ridavei.Settings.DbAbstractions
Abstract classes for manager and settings retriever used to connect to the database. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
4.0.0.2 | 85 | 10/9/2024 |
4.0.0.1 | 119 | 9/6/2024 |
4.0.0 | 285 | 4/17/2023 |
3.0.1 | 300 | 4/7/2023 |
3.0.0 | 306 | 4/1/2023 |
2.0.0.3 | 544 | 1/5/2023 |
2.0.0.2 | 329 | 11/22/2022 |
2.0.0.1 | 882 | 11/19/2022 |
2.0.0 | 327 | 11/18/2022 |
1.0.1.3 | 852 | 7/8/2022 |
1.0.1.2 | 828 | 7/6/2022 |
1.0.1.1 | 431 | 7/6/2022 |
1.0.1 | 436 | 7/6/2022 |