Пример #1
0
		public void Load(Stream Stream, Encoding Encoding)
		{
			Entries.Clear();
			var AllContent = Stream.ReadAllContentsAsString(Encoding, true).TrimStart();
			var Parts = AllContent.Split(new string[] { "## POINTER " }, StringSplitOptions.RemoveEmptyEntries);
			foreach (var Part in Parts)
			{
				//Console.WriteLine(Part.EscapeString());

				var Subparts = Part.Split(new string[] { "\r\n", "\r", "\n" }, 2, StringSplitOptions.None);
				var InfoMatch = Regex.Match(Subparts[0], @"(\d+).*$", RegexOptions.Compiled | RegexOptions.Multiline);
				var Text = Subparts[1].TrimEnd();
				var Id = ConvertEx.FlexibleToInt(InfoMatch.Groups[1].Value);

				Entries[Id] = new Entry()
				{
					Id = Id,
					Text = Text,
				};
				//Console.WriteLine(Subparts.ToStringArray().EscapeString());
			}
		}
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="stream"></param>
        /// <param name="encoding"></param>
        public void Load(Stream stream, Encoding encoding)
        {
            _entries.Clear();
            var allContent = stream.ReadAllContentsAsString(encoding).TrimStart();
            var parts      = allContent.Split(new[] { "## POINTER " }, StringSplitOptions.RemoveEmptyEntries);

            foreach (var part in parts)
            {
                //Console.WriteLine(Part.EscapeString());

                var subparts  = part.Split(new[] { "\r\n", "\r", "\n" }, 2, StringSplitOptions.None);
                var infoMatch = Regex.Match(subparts[0], @"(\d+).*$", RegexOptions.Compiled | RegexOptions.Multiline);
                var text      = subparts[1].TrimEnd();
                var id        = ConvertEx.FlexibleToInt(infoMatch.Groups[1].Value);

                _entries[id] = new Entry()
                {
                    Id   = id,
                    Text = text,
                };
                //Console.WriteLine(Subparts.ToStringArray().EscapeString());
            }
        }