From fec5591bcb6d1fefa0ad5912ecc56bcf785bc1d0 Mon Sep 17 00:00:00 2001 From: Adrien Allard Date: Fri, 2 Aug 2019 09:06:14 +0200 Subject: [PATCH] Add possibility to define a default value in registry. --- Application/FileConverter/Registry.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Application/FileConverter/Registry.cs b/Application/FileConverter/Registry.cs index 85d4a64..9ec7958 100644 --- a/Application/FileConverter/Registry.cs +++ b/Application/FileConverter/Registry.cs @@ -80,14 +80,13 @@ namespace FileConverter } } - public static T GetValue(string key) + public static T GetValue(string key, T defaultValue = default(T)) { Registry registry = Registry.Instance; - string stringValue; - if (!registry.registryEntries.TryGetValue(key, out stringValue)) + if (!registry.registryEntries.TryGetValue(key, out string stringValue)) { - return default(T); + return defaultValue; } try @@ -100,7 +99,7 @@ namespace FileConverter Diagnostics.Debug.LogError("Can't convert registry value: {0}.", exception.Message); } - return default(T); + return defaultValue; } public static void SetValue(string key, T value)