private void sectionLookup(IniFileSectionStart test, IniFileValue r)
 {
     switch (r.Key.ToString())
     {
         case "EffectClass":
             //valueLookup(r);
             Console.Out.WriteLine(r.Value);
             effectClass = r.Value.ToString();
             break;
         case "Description":
             description = r.Value.ToString();
             break;
         case "StartLinkID":
             startLinkID = int.Parse(r.Value.ToString());
             break;
         case "NextLinkID":
             nextLinkID = int.Parse(r.Value.ToString());
             break;
         case "BaseAssetID":
             baseAssetID = int.Parse(r.Value.ToString());
             break;
         case "SFX":
             soundFxFile = r.Value.ToString();
             break;
     }
 }
 private void valueLookup(IniFileSectionStart test, IniFileValue r)
 {
     String parsed = "";
     switch (r.Key.ToString())
     {
         case "BuffType":
             parsed = r.Value.ToString();
             type = parsed.Replace("'", "\\'");
             break;
         case "BuffAsset":
             parsed = r.Value.ToString();
             asset_name = parsed.Replace("'", "\\'");
             break;
         case "BuffToolTip":
             parsed = r.Value.ToString();
             tooltip = parsed.Replace("'", "\\'");
             break;
         case "BuffAltToolTip":
             parsed = r.Value.ToString();
             alt_tooltip = parsed.Replace("'", "\\'");
             break;
         case "IsGoodBuff":
             bool boolTest = bool.Parse(r.Value.ToString());
             is_good_buff = Convert.ToInt32(boolTest);
             break;
     }
 }
Exemple #3
0
        public static IniFileElement ParseLine(string line)
        {
            if (line == null)
            {
                return(null);
            }
            if (line.Contains("\n"))
            {
                throw new ArgumentException("String passed to the ParseLine method cannot contain more than one line.");
            }
            string         testString     = line.Trim();
            IniFileElement iniFileElement = null;

            if (IniFileBlankLine.IsLineValid(testString))
            {
                iniFileElement = new IniFileBlankLine(1);
            }
            else if (IniFileCommentary.IsLineValid(line))
            {
                iniFileElement = new IniFileCommentary(line);
            }
            else if (IniFileSectionStart.IsLineValid(testString))
            {
                iniFileElement = new IniFileSectionStart(line);
            }
            else if (IniFileValue.IsLineValid(testString))
            {
                iniFileElement = new IniFileValue(line);
            }
            return(iniFileElement ?? new IniFileElement(line));
        }
Exemple #4
0
        public List <IniFileElement> ReadSection()
        {
            if (current == null || !(current is IniFileSectionStart))
            {
                throw new InvalidOperationException("The current position of the reader must be at IniFileSectionStart. Use GotoSection method");
            }
            List <IniFileElement> list = new List <IniFileElement>();
            IniFileElement        item = current;

            list.Add(item);
            string text = "";
            string text2;

            while ((text2 = ReadLine()) != null)
            {
                if (IniFileSectionStart.IsLineValid(text2.Trim()))
                {
                    current = new IniFileSectionStart(text2);
                    break;
                }
                text = text + text2 + Environment.NewLine;
            }
            if (text.EndsWith(Environment.NewLine) && text != Environment.NewLine)
            {
                text = text.Substring(0, text.Length - Environment.NewLine.Length);
            }
            list.AddRange(ParseText(text));
            return(list);
        }
Exemple #5
0
 public IniFileSection this[string sectionName]
 {
     get
     {
         IniFileSection section = getSection(sectionName);
         if (section != null)
         {
             return(section);
         }
         IniFileSectionStart iniFileSectionStart;
         if (sections.Count > 0)
         {
             IniFileSectionStart sectionStart = sections[sections.Count - 1].sectionStart;
             iniFileSectionStart = sectionStart.CreateNew(sectionName);
         }
         else
         {
             iniFileSectionStart = IniFileSectionStart.FromName(sectionName);
         }
         elements.Add(iniFileSectionStart);
         section = new IniFileSection(this, iniFileSectionStart);
         sections.Add(section);
         return(section);
     }
 }
Exemple #6
0
        public static IniFileSectionStart FromName(string sectionName)
        {
            IniFileSectionStart iniFileSectionStart = new IniFileSectionStart();

            iniFileSectionStart.SectionName = sectionName;
            iniFileSectionStart.FormatDefault();
            return(iniFileSectionStart);
        }
Exemple #7
0
        public void DeleteSection(string name)
        {
            IniFileSection section = getSection(name);

            if (section != null)
            {
                IniFileSectionStart sectionStart = section.sectionStart;
                elements.Remove(sectionStart);
                for (int i = elements.IndexOf(sectionStart) + 1; i < elements.Count && !(elements[i] is IniFileSectionStart); i++)
                {
                    elements.RemoveAt(i);
                }
            }
        }
Exemple #8
0
        public IniFileSectionStart CreateNew(string sectName)
        {
            IniFileSectionStart iniFileSectionStart = new IniFileSectionStart();

            iniFileSectionStart.sectionName = sectName;
            if (IniFileSettings.PreserveFormatting)
            {
                iniFileSectionStart.formatting = formatting;
                iniFileSectionStart.Format();
            }
            else
            {
                iniFileSectionStart.Format();
            }
            return(iniFileSectionStart);
        }
Exemple #9
0
        public IniFileValue GotoValue(string key, bool searchWholeFile)
        {
            string text;

            do
            {
                text = ReadLine();
                if (text == null)
                {
                    return(null);
                }
                if (IniFileValue.IsLineValid(text.Trim()))
                {
                    IniFileValue iniFileValue = ParseLine(text) as IniFileValue;
                    if (iniFileValue != null && (iniFileValue.Key == key || (!IniFileSettings.CaseSensitive && iniFileValue.Key.ToLowerInvariant() == key.ToLowerInvariant())))
                    {
                        return(iniFileValue);
                    }
                }
            }while (searchWholeFile || !IniFileSectionStart.IsLineValid(text.Trim()));
            return(null);
        }
Exemple #10
0
        public static IniFile FromElements(IEnumerable <IniFileElement> elemes)
        {
            IniFile iniFile = new IniFile();

            iniFile.elements.AddRange(elemes);
            if (iniFile.elements.Count > 0)
            {
                IniFileSection iniFileSection = null;
                if (iniFile.elements[iniFile.elements.Count - 1] is IniFileBlankLine)
                {
                    iniFile.elements.RemoveAt(iniFile.elements.Count - 1);
                }
                for (int i = 0; i < iniFile.elements.Count; i++)
                {
                    IniFileElement iniFileElement = iniFile.elements[i];
                    if (iniFileElement is IniFileSectionStart)
                    {
                        iniFileSection = new IniFileSection(iniFile, (IniFileSectionStart)iniFileElement);
                        iniFile.sections.Add(iniFileSection);
                    }
                    else if (iniFileSection != null)
                    {
                        iniFileSection.elements.Add(iniFileElement);
                    }
                    else if (iniFile.sections.Exists((IniFileSection a) => a.Name == ""))
                    {
                        iniFile.sections[0].elements.Add(iniFileElement);
                    }
                    else if (iniFileElement is IniFileValue)
                    {
                        iniFileSection = new IniFileSection(iniFile, IniFileSectionStart.FromName(""));
                        iniFileSection.elements.Add(iniFileElement);
                        iniFile.sections.Add(iniFileSection);
                    }
                }
            }
            return(iniFile);
        }
Exemple #11
0
        public IniFileSectionStart GotoSection(string sectionName)
        {
            IniFileSectionStart iniFileSectionStart = null;

            while (true)
            {
                string text = ReadLine();
                if (text == null)
                {
                    current = null;
                    return(null);
                }
                if (IniFileSectionStart.IsLineValid(text))
                {
                    iniFileSectionStart = (ParseLine(text) as IniFileSectionStart);
                    if (iniFileSectionStart != null && (iniFileSectionStart.SectionName == sectionName || (!IniFileSettings.CaseSensitive && iniFileSectionStart.SectionName.ToLowerInvariant() == sectionName)))
                    {
                        break;
                    }
                }
            }
            current = iniFileSectionStart;
            return(iniFileSectionStart);
        }
Exemple #12
0
 internal IniFileSection(IniFile _parent, IniFileSectionStart sect)
 {
     sectionStart = sect;
     parent       = _parent;
 }
Exemple #13
0
 internal IniFileSection(IniFile _parent, IniFileSectionStart sect)
 {
     sectionStart = sect;
     parent = _parent;
 }
 private void valueLookup(IniFileSectionStart test, IniFileValue r)
 {
     String parsed = "";
     switch (r.Key.ToString())
     {
         case "Activated":
             bool boolTest = bool.Parse(r.Value.ToString());
             is_activated = Convert.ToInt32(boolTest);
             break;
         case "Category":
             parsed = r.Value.ToString();
             category = parsed.Replace("'", "\\'");
             break;
         case "Description":
             parsed = r.Value.ToString();
             description = parsed.Replace("'", "\\'");
             break;
         case "Desc_1":
             parsed = r.Value.ToString();
             desc_1 = parsed.Replace("'", "\\'");
             break;
         case "Desc_2":
             parsed = r.Value.ToString();
             desc_2 = parsed.Replace("'", "\\'");
             break;
         case "Desc_3":
             parsed = r.Value.ToString();
             desc_3 = parsed.Replace("'", "\\'");
             break;
         case "Desc_4":
             parsed = r.Value.ToString();
             desc_4 = parsed.Replace("'", "\\'");
             break;
         case "Desc_5":
             parsed = r.Value.ToString();
             desc_5 = parsed.Replace("'", "\\'");
             break;
         case "Desc_6":
             parsed = r.Value.ToString();
             desc_6 = parsed.Replace("'", "\\'");
             break;
         case "Desc_7":
             parsed = r.Value.ToString();
             desc_7 = parsed.Replace("'", "\\'");
             break;
         case "Desc_8":
             parsed = r.Value.ToString();
             desc_8 = parsed.Replace("'", "\\'");
             break;
         case "Desc_9":
             parsed = r.Value.ToString();
             desc_9 = parsed.Replace("'", "\\'");
             break;
         case "Range":
             //range = Convert.ToInt32(r.Value.ToString());
             break;
         case "Warrior":
             warrior_max_level = Convert.ToInt32(r.Value.ToString());
             break;
         case "Sentinel":
             sentinel_max_level = Convert.ToInt32(r.Value.ToString());
             break;
         case "Privateer":
             privateer_max_level = Convert.ToInt32(r.Value.ToString());
             break;
         case "Defender":
             defender_max_level = Convert.ToInt32(r.Value.ToString());
             break;
         case "Explorer":
             explorer_max_level = Convert.ToInt32(r.Value.ToString());
             break;
         case "Seeker":
             seeker_max_level = Convert.ToInt32(r.Value.ToString());
             break;
         case "Enforcer":
             enforcer_max_level = Convert.ToInt32(r.Value.ToString());
             break;
         case "Scout":
             scout_max_level = Convert.ToInt32(r.Value.ToString());
             break;
         case "Tradesman":
             tradesman_max_level = Convert.ToInt32(r.Value.ToString());
             break;
     }
 }
 /// <summary>Crates a IniFileSectionStart object from name of a section.</summary>
 /// <param name="sectionName">Name of a section</param>
 public static IniFileSectionStart FromName(string sectionName)
 {
     IniFileSectionStart ret = new IniFileSectionStart();
     ret.SectionName = sectionName;
     ret.FormatDefault();
     return ret;
 }
 /// <summary>Creates a new IniFileSectionStart object basing on a name of section and the formatting style of this section.</summary>
 /// <param name="sectName">Name of the new section</param>
 public IniFileSectionStart CreateNew(string sectName)
 {
     IniFileSectionStart ret = new IniFileSectionStart();
     ret.sectionName = sectName;
     if (IniFileSettings.PreserveFormatting) {
         ret.formatting = formatting;
         ret.Format();
     }
     else
         ret.Format();
     return ret;
 }
Exemple #17
0
 /// <summary>Parses a single line.</summary>
 /// <param name="line">Text to parse.</param>
 public static IniFileElement ParseLine(string line)
 {
     if (line == null)
         return null;
     if (line.Contains("\n"))
         throw new ArgumentException("String passed to the ParseLine method cannot contain more than one line.");
     string trim = line.Trim();
     IniFileElement elem = null;
     if (IniFileBlankLine.IsLineValid(trim))
         elem = new IniFileBlankLine(1);
     else if (IniFileCommentary.IsLineValid(line))
         elem = new IniFileCommentary(line);
     else if (IniFileSectionStart.IsLineValid(trim))
         elem = new IniFileSectionStart(line);
     else if (IniFileValue.IsLineValid(trim))
         elem = new IniFileValue(line);
     return elem ?? new IniFileElement(line);
 }