Skip to content

Instantly share code, notes, and snippets.

@FusRoDah061
Created February 22, 2019 18:10
Show Gist options
  • Save FusRoDah061/dcd73c5622ade50aa734a50534d6af80 to your computer and use it in GitHub Desktop.
Save FusRoDah061/dcd73c5622ade50aa734a50534d6af80 to your computer and use it in GitHub Desktop.
Gerenciador de configurações utilizando Sharp-Config 1.0.0
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