using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
namespace HandPickCrawlerDB.Extensions
{
public class AppHelper
{
private static string _appconfig = null;
public static string AppConfig
{
get
{
if (_appconfig == null)
{
Type t = typeof(System.Configuration.ConfigurationManager).Assembly.GetType("System.Configuration.ClientConfigurationHost");
object cfghst = Activator.CreateInstance(t, true);
PropertyInfo pi = t.GetProperty("ConfigPaths", BindingFlags.Instance | BindingFlags.NonPublic);
object cfgpath = pi.GetValue(cfghst, null);
Type t1 = typeof(System.Configuration.ConfigurationManager).Assembly.GetType("System.Configuration.ClientConfigPaths");
pi = t1.GetProperty("ApplicationConfigUri", BindingFlags.Instance | BindingFlags.NonPublic);
string path = (string)pi.GetValue(cfgpath, null);
public static void SetSettingToAppConfig(string key, string value)
{
if (string.IsNullOrEmpty(key))
{
throw new Exception("key not be null");
}
else
{
key = key.Trim();
}
if (string.IsNullOrEmpty(value))
value = "";
else
value = value.Trim();