コード例 #1
0
 /// <summary>
 /// Split a string by line breaks.
 /// </summary>
 /// <param name="source">
 /// The string to split.
 /// </param>
 /// <returns>
 /// The split strings.
 /// </returns>
 private static IEnumerable <string> SplitByLineBreaks(string source)
 {
     return(LineRegex
            .Matches(source)
            .Cast <Match>()
            .Select(x => x.Value));
 }
コード例 #2
0
        public IniPropertyData(string existingText) : base(IniLineType.Property, existingText)
        {
            var matches = LineRegex.Matches(existingText);

            Key   = matches[0].Groups[1].Value.Trim();
            Value = matches[0].Groups[2].Value.Trim();
        }
コード例 #3
0
        private IniCommentData(string textOrLine, bool isLine) : base(IniLineType.Comment, isLine ? textOrLine : null)
        {
            if (string.IsNullOrWhiteSpace(textOrLine))
            {
                throw new System.ArgumentException("message", nameof(textOrLine));
            }

            if (isLine)
            {
                var matches = LineRegex.Matches(textOrLine);
                Text = matches[0].Groups[1].Value.Trim();
            }
            else
            {
                Text = textOrLine;
            }
        }
コード例 #4
0
        private IniSectionData(string nameOrLine, bool isLine) : base(IniLineType.SectionHeader, isLine ? nameOrLine : null)
        {
            if (string.IsNullOrWhiteSpace(nameOrLine))
            {
                throw new ArgumentException("message", nameof(nameOrLine));
            }

            if (isLine)
            {
                var matches = LineRegex.Matches(nameOrLine);
                Name = matches[0].Groups[1].Value;
            }
            else
            {
                Name = nameOrLine;
            }

            AddLine(this);
        }