예제 #1
0
파일: IniKey.cs 프로젝트: dengliyan/XUtils
 public bool SetName(string sKey)
 {
     sKey = sKey.Trim();
     if (sKey.Length != 0)
     {
         IniKey key = this.m_section.GetKey(sKey);
         if (key != this && key != null)
         {
             return(false);
         }
         try
         {
             this.m_section.m_keys.Remove(this.m_sKey);
             this.m_section.m_keys[sKey] = this;
             this.m_sKey = sKey;
             return(true);
         }
         catch (Exception ex)
         {
             Trace.WriteLine(ex.Message);
         }
         return(false);
     }
     return(false);
 }
예제 #2
0
        public bool RenameKey(string sSection, string sKey, string sNewKey)
        {
            IniSection section = this.GetSection(sSection);

            if (section != null)
            {
                IniKey key = section.GetKey(sKey);
                if (key != null)
                {
                    return(key.SetName(sNewKey));
                }
            }
            return(false);
        }
예제 #3
0
        public string GetKeyValue(string sSection, string sKey)
        {
            IniSection section = this.GetSection(sSection);

            if (section != null)
            {
                IniKey key = section.GetKey(sKey);
                if (key != null)
                {
                    return(key.Value);
                }
            }
            return(string.Empty);
        }
예제 #4
0
        public bool SetKeyValue(string sSection, string sKey, string sValue)
        {
            IniSection iniSection = this.AddSection(sSection);

            if (iniSection != null)
            {
                IniKey iniKey = iniSection.AddKey(sKey);
                if (iniKey != null)
                {
                    iniKey.Value = sValue;
                    return(true);
                }
            }
            return(false);
        }
예제 #5
0
 public bool RemoveKey(IniKey Key)
 {
     if (Key != null)
     {
         try
         {
             this.m_keys.Remove(Key.Name);
             return(true);
         }
         catch (Exception ex)
         {
             Trace.WriteLine(ex.Message);
         }
         return(false);
     }
     return(false);
 }
예제 #6
0
        public IniKey AddKey(string sKey)
        {
            sKey = sKey.Trim();
            IniKey iniKey = null;

            if (sKey.Length != 0)
            {
                if (this.m_keys.ContainsKey(sKey))
                {
                    iniKey = (IniKey)this.m_keys[sKey];
                }
                else
                {
                    iniKey            = new IniKey(this, sKey);
                    this.m_keys[sKey] = iniKey;
                }
            }
            return(iniKey);
        }