/// <summary> /// 读取模板Config文件 /// </summary> public void ReadConfigFile() { object obj = null; TextReader reader = null; try { XmlSerializer x = new XmlSerializer(typeof(Templates)); reader = new StreamReader(ConfigFile, System.Text.Encoding.Unicode); obj = x.Deserialize(reader); } catch (FileNotFoundException ex) { throw new Exception("Templates config file not found", ex); } catch (System.InvalidOperationException ex) { throw new Exception("Invalid Operation", ex.InnerException); } finally { if (reader != null) reader.Close(); } Templates = (Templates)obj; }
/// <summary> /// 构造函数 /// </summary> /// <param name="page">页面Page对象,用于获取Request对象用</param> /// <param name="ResetConfig">是否Reset 配置文件</param> public TemplateAdmin(Page page, bool ResetConfig) { SetConfigFilePath(page); if (ResetConfig) { Templates = new Templates(); SaveConfigFile(); } else { ReadConfigFile(); } }