예제 #1
0
 public IniFileSectionStart(string content)
     : base(content)
 {
     formatting = ExtractFormat(content);
     content    = content.TrimStart();
     if (IniFileSettings.AllowInlineComments)
     {
         IniFileSettings.indexOfAnyResult indexOfAnyResult = IniFileSettings.indexOfAny(content, IniFileSettings.CommentChars);
         if (indexOfAnyResult.index > content.IndexOf(IniFileSettings.SectionCloseBracket))
         {
             inlineComment     = content.Substring(indexOfAnyResult.index + indexOfAnyResult.any.Length);
             inlineCommentChar = indexOfAnyResult.any;
             content           = content.Substring(0, indexOfAnyResult.index);
         }
     }
     if (IniFileSettings.AllowTextOnTheRight)
     {
         int num = content.LastIndexOf(IniFileSettings.SectionCloseBracket);
         if (num != content.Length - 1)
         {
             textOnTheRight = content.Substring(num + 1);
             content        = content.Substring(0, num);
         }
     }
     sectionName  = content.Substring(IniFileSettings.SectionOpenBracket.Length, content.Length - IniFileSettings.SectionCloseBracket.Length - IniFileSettings.SectionOpenBracket.Length).Trim();
     base.Content = content;
     Format();
 }
예제 #2
0
 /// <summary>Initializes a new instance IniFileSectionStart</summary>
 /// <param name="content">Actual content of a line in an INI file. Initializer assumes that it is valid.</param>
 public IniFileSectionStart(string content)
     : base(content)
 {
     //content = Content;
     formatting = ExtractFormat(content);
     content    = content.TrimStart();
     if (IniFileSettings.AllowInlineComments)
     {
         IniFileSettings.indexOfAnyResult result = IniFileSettings.indexOfAny(content, IniFileSettings.CommentChars);
         if (result.index > content.IndexOf(IniFileSettings.SectionCloseBracket))
         {
             inlineComment     = content.Substring(result.index + result.any.Length);
             inlineCommentChar = result.any;
             content           = content.Substring(0, result.index);
         }
     }
     if (IniFileSettings.AllowTextOnTheRight)
     {
         int closeBracketPos = content.LastIndexOf(IniFileSettings.SectionCloseBracket);
         if (closeBracketPos != content.Length - 1)
         {
             textOnTheRight = content.Substring(closeBracketPos + 1);
             content        = content.Substring(0, closeBracketPos);
         }
     }
     sectionName = content.Substring(IniFileSettings.SectionOpenBracket.Length, content.Length - IniFileSettings.SectionCloseBracket.Length - IniFileSettings.SectionOpenBracket.Length).Trim();
     Content     = content;
     Format();
 }
예제 #3
0
        /// <summary>Initializes a new instance IniFileValue.</summary>
        /// <param name="content">Actual content of a line in an INI file. Initializer assumes that it is valid.</param>
        public IniFileValue(string content)
            : base(content)
        {
            string[] split = Content.Split(new string[] { IniFileSettings.EqualsString }, StringSplitOptions.None);
            formatting = ExtractFormat(content);
            string split0 = split[0].Trim();
            string split1 = split.Length >= 1 ?
                            split[1].Trim()
                                : "";

            if (split0.Length > 0)
            {
                if (IniFileSettings.AllowInlineComments)
                {
                    IniFileSettings.indexOfAnyResult result = IniFileSettings.indexOfAny(split1, IniFileSettings.CommentChars);
                    if (result.index != -1)
                    {
                        inlineComment     = split1.Substring(result.index + result.any.Length);
                        split1            = split1.Substring(0, result.index).TrimEnd();
                        inlineCommentChar = result.any;
                    }
                }
                if (IniFileSettings.QuoteChar != null && split1.Length >= 2)
                {
                    char quoteChar = (char)IniFileSettings.QuoteChar;
                    if (split1[0] == quoteChar)
                    {
                        int lastQuotePos;
                        if (IniFileSettings.AllowTextOnTheRight)
                        {
                            lastQuotePos = split1.LastIndexOf(quoteChar);
                            if (lastQuotePos != split1.Length - 1)
                            {
                                textOnTheRight = split1.Substring(lastQuotePos + 1);
                            }
                        }
                        else
                        {
                            lastQuotePos = split1.Length - 1;
                        }
                        if (lastQuotePos > 0)
                        {
                            if (split1.Length == 2)
                            {
                                split1 = "";
                            }
                            else
                            {
                                split1 = split1.Substring(1, lastQuotePos - 1);
                            }
                        }
                    }
                }
                key   = split0;
                value = split1;
            }
            Format();
        }
예제 #4
0
        public IniFileValue(string content)
            : base(content)
        {
            string[] array = base.Content.Split(new string[1]
            {
                IniFileSettings.EqualsString
            }, StringSplitOptions.None);
            formatting = ExtractFormat(content);
            string text  = array[0].Trim();
            string text2 = (array.Length >= 1) ? array[1].Trim() : "";

            if (text.Length > 0)
            {
                if (IniFileSettings.AllowInlineComments)
                {
                    IniFileSettings.indexOfAnyResult indexOfAnyResult = IniFileSettings.indexOfAny(text2, IniFileSettings.CommentChars);
                    if (indexOfAnyResult.index != -1)
                    {
                        inlineComment     = text2.Substring(indexOfAnyResult.index + indexOfAnyResult.any.Length);
                        text2             = text2.Substring(0, indexOfAnyResult.index).TrimEnd();
                        inlineCommentChar = indexOfAnyResult.any;
                    }
                }
                if (((int?)IniFileSettings.QuoteChar).HasValue && text2.Length >= 2)
                {
                    char c = IniFileSettings.QuoteChar.Value;
                    if (text2[0] == c)
                    {
                        int num;
                        if (IniFileSettings.AllowTextOnTheRight)
                        {
                            num = text2.LastIndexOf(c);
                            if (num != text2.Length - 1)
                            {
                                textOnTheRight = text2.Substring(num + 1);
                            }
                        }
                        else
                        {
                            num = text2.Length - 1;
                        }
                        if (num > 0)
                        {
                            text2 = ((text2.Length != 2) ? text2.Substring(1, num - 1) : "");
                        }
                    }
                }
                key   = text;
                value = text2;
            }
            Format();
        }