namespace ConsoleApplication38
{
class Program
{
static void Main(string[] args)
{
try
{
SectionToolV2 _sectionHelper = new SectionToolV2("module/appSettings");
(_sectionHelper.GetValue("Googlemap"));
(_sectionHelper.ContainKey("YanZhiwei"));
}
catch (Exception ex)
{
();
}
finally
{
();
}
}
}
class SectionToolV2
{
NameValueCollection ModulSettings = null;
/// <summary>
///Constructor
/// </summary>
/// <param name="sectionName">section name</param>
public SectionToolV2(string sectionName)
{
ModulSettings = (sectionName) as NameValueCollection;
}
/// <summary>
/// Whether to include this Section
/// </summary>
/// <returns></returns>
public bool ContainSection()
{
return !(ModulSettings == null);
}
/// <summary>
/// Whether Section contains Key
/// </summary>
/// <param name="key">key</param>
/// <returns>value</returns>
public bool ContainKey(string key)
{
if (ContainSection())
{
return !(ModulSettings[key] == null);
}
return false;
}
/// <summary>
/// Get the value according to the key
/// </summary>
/// <param name="Key">key</param>
/// <returns>When there is no key, return</returns>
public string GetValue(string Key)
{
string _value = ;
if (ContainKey(Key))
{
_value = ModulSettings[Key];
}
return _value;
}
}
}
{
class Program
{
static void Main(string[] args)
{
try
{
SectionToolV2 _sectionHelper = new SectionToolV2("module/appSettings");
(_sectionHelper.GetValue("Googlemap"));
(_sectionHelper.ContainKey("YanZhiwei"));
}
catch (Exception ex)
{
();
}
finally
{
();
}
}
}
class SectionToolV2
{
NameValueCollection ModulSettings = null;
/// <summary>
///Constructor
/// </summary>
/// <param name="sectionName">section name</param>
public SectionToolV2(string sectionName)
{
ModulSettings = (sectionName) as NameValueCollection;
}
/// <summary>
/// Whether to include this Section
/// </summary>
/// <returns></returns>
public bool ContainSection()
{
return !(ModulSettings == null);
}
/// <summary>
/// Whether Section contains Key
/// </summary>
/// <param name="key">key</param>
/// <returns>value</returns>
public bool ContainKey(string key)
{
if (ContainSection())
{
return !(ModulSettings[key] == null);
}
return false;
}
/// <summary>
/// Get the value according to the key
/// </summary>
/// <param name="Key">key</param>
/// <returns>When there is no key, return</returns>
public string GetValue(string Key)
{
string _value = ;
if (ContainKey(Key))
{
_value = ModulSettings[Key];
}
return _value;
}
}
}