using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Configuration;
namespace CO2Utility
{
public class ConfigRead
{
/// <summary>
/// コンストラクタ定義[configファイル名]
/// </summary>
private string configFilename = string.Empty;
public ConfigRead(string configFilename)
{
this.configFilename = configFilename;
}
/// <summary>
/// configファイルよりキーで値を取得する関数
/// </summary>
/// <param name="nodeKey"></param>
/// <returns></returns>
public string GetValueFromConfig(string nodeKey)
{
try
{
string retValue = string.Empty;
ExeConfigurationFileMap exeConfigurationFileMap = new ExeConfigurationFileMap();
exeConfigurationFileMap.ExeConfigFilename = configFilename;
Configuration configuration = ConfigurationManager.OpenMappedExeConfiguration(exeConfigurationFileMap, ConfigurationUserLevel.None);
AppSettingsSection appSettingsSection = (AppSettingsSection)configuration.GetSection("appSettings");
retValue = appSettingsSection.Settings[nodeKey].Value;
return retValue;
}
catch (Exception e)
{
throw e;
}
}
}
}