using DocTools.Entity.Parameters;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace DocTools.Helper
{
///
/// This class will load a glabal server configuration
///
public class ConfigurationManager
{
private static IEnumerable _parameters;
static ConfigurationManager()
{
var configFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "AppSettings.json");
_parameters = ParameterSerializer.Deserialize(configFilePath);
}
///
/// Get parameter by specifed section name and parameter name
///
///
public static T GetParammeter(string sectionName, string paramName) where T : class
{
var parameter = _parameters.FirstOrDefault(x => x.Section == sectionName && x.Name == paramName) as T;
if (parameter != null)
{
return parameter;
}
throw new System.ArgumentException($"{sectionName} - {paramName} not set correct");
}
}
}