Exemplo n.º 1
0
        /// <summary>
        /// Parses a <see cref="UnicodeRange"/>.
        /// </summary>
        /// <param name="s">The string to parse.</param>
        /// <returns>The parsed <see cref="UnicodeRange"/>.</returns>
        /// <exception cref="FormatException"></exception>
        public static UnicodeRange Parse(string s)
        {
            if (string.IsNullOrEmpty(s))
            {
                throw new FormatException("Could not parse specified Unicode range.");
            }

            var parts = s.Split(',');

            var length = parts.Length;

            if (length == 0)
            {
                throw new FormatException("Could not parse specified Unicode range.");
            }

            if (length == 1)
            {
                return(new UnicodeRange(UnicodeRangeSegment.Parse(parts[0])));
            }

            var segments = new UnicodeRangeSegment[length];

            for (int i = 0; i < length; i++)
            {
                segments[i] = UnicodeRangeSegment.Parse(parts[i].Trim());
            }

            return(new UnicodeRange(segments));
        }
Exemplo n.º 2
0
        public UnicodeRange(IReadOnlyList <UnicodeRangeSegment> segments)
        {
            if (segments is null || segments.Count == 0)
            {
                throw new ArgumentException(nameof(segments));
            }

            _single   = segments[0];
            _segments = segments;
        }
Exemplo n.º 3
0
 public UnicodeRange(UnicodeRangeSegment single)
 {
     _single = single;
 }
Exemplo n.º 4
0
 public UnicodeRange(int start, int end)
 {
     _single = new UnicodeRangeSegment(start, end);
 }