Created
February 22, 2019 18:10
-
-
Save FusRoDah061/dcd73c5622ade50aa734a50534d6af80 to your computer and use it in GitHub Desktop.
Gerenciador de configurações utilizando Sharp-Config 1.0.0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using SharpConfig; | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace FolderScannerClassLibrary | |
{ | |
public class ConfigManager | |
{ | |
private const string CONFIG_NAMESPACE = "UncaFlowLibConfig"; | |
private static ConfigManager _instance = null; | |
private Config _cfg; | |
private ConfigManager() | |
{ | |
_cfg = new Config(CONFIG_NAMESPACE, false, true); | |
} | |
public static ConfigManager GetInstance() | |
{ | |
if (_instance == null) | |
_instance = new ConfigManager(); | |
return _instance; | |
} | |
public string DbConnectionString | |
{ | |
get | |
{ | |
string value = Convert.ToString(_getItem("DbConnectionString")); | |
if (String.IsNullOrEmpty(value)) | |
value = "Data Source=uncaflow.db"; | |
return value; | |
} | |
set | |
{ | |
_cfg["DbConnectionString"] = value; | |
} | |
} | |
private object _getItem(string key) | |
{ | |
object value = null; | |
try | |
{ | |
value = _cfg[key]; | |
} | |
catch { } | |
return value; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment