Beispiel #1
0
 public void WriteElement(IniFileElement element)
 {
     if (!IniFileSettings.PreserveFormatting)
     {
         element.FormatDefault();
     }
     if ((!(element is IniFileBlankLine) || IniFileSettings.AllowBlankLines) && (IniFileSettings.AllowEmptyValues || !(element is IniFileValue) || !(((IniFileValue)element).Value == "")))
     {
         base.WriteLine(element.Line);
     }
 }
Beispiel #2
0
 public void Format(bool preserveIntendation)
 {
     for (int i = 0; i < elements.Count; i++)
     {
         IniFileElement iniFileElement = elements[i];
         string         intendation    = iniFileElement.Intendation;
         iniFileElement.FormatDefault();
         if (preserveIntendation)
         {
             iniFileElement.Intendation = intendation;
         }
     }
 }
Beispiel #3
0
        public void Format(bool preserveIntendation)
        {
            string intendation  = "";
            string intendation2 = "";

            for (int i = 0; i < elements.Count; i++)
            {
                IniFileElement iniFileElement = elements[i];
                if (preserveIntendation)
                {
                    if (iniFileElement is IniFileSectionStart)
                    {
                        intendation2 = (intendation = iniFileElement.Intendation);
                    }
                    else if (iniFileElement is IniFileValue)
                    {
                        intendation2 = iniFileElement.Intendation;
                    }
                }
                iniFileElement.FormatDefault();
                if (preserveIntendation)
                {
                    if (iniFileElement is IniFileSectionStart)
                    {
                        iniFileElement.Intendation = intendation;
                    }
                    else if (iniFileElement is IniFileCommentary && i != elements.Count - 1 && !(elements[i + 1] is IniFileBlankLine))
                    {
                        iniFileElement.Intendation = elements[i + 1].Intendation;
                    }
                    else
                    {
                        iniFileElement.Intendation = intendation2;
                    }
                }
            }
        }
Beispiel #4
0
 /// <summary>Writes INI file element to the file.</summary>
 /// <param name="element">Element to write.</param>
 public void WriteElement(IniFileElement element)
 {
     if (!IniFileSettings.PreserveFormatting)
         element.FormatDefault();
     // do not write if:
     if (!( // 1) element is a blank line AND blank lines are not allowed
         (element is IniFileBlankLine && !IniFileSettings.AllowBlankLines)
          // 2) element is an empty value AND empty values are not allowed
         || (!IniFileSettings.AllowEmptyValues && element is IniFileValue && ((IniFileValue)element).Value == "")))
         base.WriteLine(element.Line);
 }