Ejemplo n.º 1
0
        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;
            }
        }
Ejemplo n.º 2
0
 public MOG_Ini(string fullFilename)
 {
     mChanged          = false;
     mFullFilename     = "";
     mSections         = new ArrayList();
     mLockedFileStream = null;
     mHandle           = IniHandle.ClearHandle;
     Load(fullFilename);
 }
Ejemplo n.º 3
0
 public MOG_Ini()
 {
     mSections         = new ArrayList();
     mFullFilename     = "";
     mSectionCache     = new MOG_IniSection();
     mKeyCache         = new MOG_IniKey();
     mChanged          = false;
     mHandle           = IniHandle.ClearHandle;
     mLockedFileStream = null;
 }
Ejemplo n.º 4
0
        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;
        }
Ejemplo n.º 5
0
        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));
        }
Ejemplo n.º 6
0
        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();
        }
Ejemplo n.º 7
0
        /// <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);
        }