public WePayService(ILog log, IWCHelper helper,IWCCommonService commonService ,DataSettings dataSettings) { _log = log; _helper= helper; _dataSettings = dataSettings; _commonService = commonService; }
/// <summary> /// 构建配置对象 /// </summary> /// <param name="settings">配置对象</param> /// <returns>配置文本</returns> protected virtual string ComposeSettings(DataSettings settings) { if (settings == null) return ""; return string.Format("DataProvider: {0}{2}DataConnectionString: {1}{2}", settings.DataProvider, settings.DataConnectionString, Environment.NewLine ); }
/// <summary> /// 解析配置文件 /// </summary> /// <param name="text">配置文本</param> /// <returns>DataSettings对象</returns> protected virtual DataSettings ParseSettings(string text) { var shellSettings = new DataSettings(); if (String.IsNullOrEmpty(text)) { return(shellSettings); } var settings = new List <string>(); using (var reader = new StringReader(text)) { string str; while ((str = reader.ReadLine()) != null) { settings.Add(str); } } foreach (var setting in settings) { var separatorIndex = setting.IndexOf(Separator); if (separatorIndex == -1) { continue; } string key = setting.Substring(0, separatorIndex).Trim(); string value = setting.Substring(separatorIndex + 1).Trim(); switch (key) { case "DataProvider": shellSettings.DataProvider = value; break; case "DataConnectionString": shellSettings.DataConnectionString = value; break; default: shellSettings.RawDataSettings.Add(key, value); break; } } return(shellSettings); }
/// <summary> /// 保存配置 /// </summary> /// <param name="settings">DataSettings对象</param> public virtual void SaveSettings(DataSettings settings) { if (settings == null) { throw new ArgumentNullException("settings"); } //单元测试时,使用webHelper.MapPath替代HostingEnvironment.MapPath string filePath = Path.Combine(MapPath("~/App_Data/"), Filename); if (!File.Exists(filePath)) { using (File.Create(filePath)) { } } var text = ComposeSettings(settings); File.WriteAllText(filePath, text); }
/// <summary> /// 解析配置文件 /// </summary> /// <param name="text">配置文本</param> /// <returns>DataSettings对象</returns> protected virtual DataSettings ParseSettings(string text) { var shellSettings = new DataSettings(); if (String.IsNullOrEmpty(text)) return shellSettings; var settings = new List<string>(); using (var reader = new StringReader(text)) { string str; while ((str = reader.ReadLine()) != null) settings.Add(str); } foreach (var setting in settings) { var separatorIndex = setting.IndexOf(Separator); if (separatorIndex == -1) { continue; } string key = setting.Substring(0, separatorIndex).Trim(); string value = setting.Substring(separatorIndex + 1).Trim(); switch (key) { case "DataProvider": shellSettings.DataProvider = value; break; case "DataConnectionString": shellSettings.DataConnectionString = value; break; default: shellSettings.RawDataSettings.Add(key, value); break; } } return shellSettings; }
public WCCommonService(ILog log, IWCHelper helper, DataSettings dataSettings) { _log = log; _helper = helper; _dataSettings = dataSettings; }
/// <summary> /// 保存配置 /// </summary> /// <param name="settings">DataSettings对象</param> public virtual void SaveSettings(DataSettings settings) { if (settings == null) throw new ArgumentNullException("settings"); //单元测试时,使用webHelper.MapPath替代HostingEnvironment.MapPath string filePath = Path.Combine(MapPath("~/App_Data/"), Filename); if (!File.Exists(filePath)) { using (File.Create(filePath)) { } } var text = ComposeSettings(settings); File.WriteAllText(filePath, text); }
protected BaseDataProviderManager(DataSettings settings) { if (settings == null) throw new ArgumentNullException("settings"); this.Settings = settings; }
public EfDataProviderManager(DataSettings settings) : base(settings) { }