public config(string filename, e_c_type c_type = e_c_type.C_TYPE_COMMON) { _file = filename; filename = string.Format("{0}conf\\{1}", AppDomain.CurrentDomain.BaseDirectory, filename); try { using (StreamReader stream = new StreamReader(filename)) { ini = new IniHandle(_file, stream.ReadToEnd()); values = new Dictionary <string, object>(); } } catch (Exception e) { console.error("The file could not be read:"); console.error(e.Message); return; } switch (c_type) { case e_c_type.C_TYPE_COMMON: _ReadCommonConfig(); return; default: return; } }
public MOG_Ini(string fullFilename) { mChanged = false; mFullFilename = ""; mSections = new ArrayList(); mLockedFileStream = null; mHandle = IniHandle.ClearHandle; Load(fullFilename); }
public MOG_Ini() { mSections = new ArrayList(); mFullFilename = ""; mSectionCache = new MOG_IniSection(); mKeyCache = new MOG_IniKey(); mChanged = false; mHandle = IniHandle.ClearHandle; mLockedFileStream = null; }
public void Close() { Save(); // Close the StreamWriter who will close the FileStream for us. if (mHandle == IniHandle.HoldHandle) { mLockedFileStream.Close(); mHandle = IniHandle.ClearHandle; } // Clear previous member data mSections.Clear(); mFullFilename = ""; mChanged = false; }
public bool Open(string fullFilename, FileShare shareLevel) { Close(); // Clear previous member data if (mSections.Count != 0) { mSections.Clear(); } mSectionCache = new MOG_IniSection(); mKeyCache = new MOG_IniKey(); mFullFilename = fullFilename; mHandle = IniHandle.HoldHandle; return(LoadFile(fullFilename, FileAccess.ReadWrite, shareLevel)); }
public void init(string filename) { _file = filename; filename = string.Format("{0}conf\\{1}", AppDomain.CurrentDomain.BaseDirectory, filename); try { using (StreamReader stream = new StreamReader(filename)) { ini = new IniHandle(_file, stream.ReadToEnd()); values = new Dictionary <string, object>(); } } catch (Exception e) { console.error("The file could not be read:"); console.error(e.Message); return; } _ReadConfig(); }
/// <summary> /// Initialize the corresponding file processing object. /// </summary> /// <typeparam name="TEntity">file entity</typeparam> /// <param name="handleEnum">handle enum</param> /// <returns>handle</returns> private IHandle <TEntity> InitHandle <TEntity>(HandleEnum handleEnum) where TEntity : class { IHandle <TEntity> handle = null; switch (handleEnum) { case HandleEnum.DB: handle = new DBHandle <TEntity>(); break; case HandleEnum.INI: handle = new IniHandle <TEntity>(); break; case HandleEnum.JSON: handle = new JsonHandle <TEntity>(); break; case HandleEnum.XML: handle = new XmlHandle <TEntity>(); break; } return(handle); }