using System.Collections.Generic; using System; namespace Gallery { // Class Gallery Here are informations about the current random stored public class Gallery{ public int GalleryId { get; } public List Tags { get; } public Gallery(string HttpGalleryString) { GalleryId = GetGalleryId(HttpGalleryString); Tags = GetTags(HttpGalleryString); } private List GetTags(string HttpGalleryString){ List Tags = new List(); string TagsSection = ""; string Tag = ""; int LastStartTagName; int StartTagName; int EndTagName; string Pattern1 = "class=\"name\">"; string Pattern2 = ""; int IndexOfTags = HttpGalleryString.IndexOf("Tags:"); int IndexOfArtists = HttpGalleryString.IndexOf("Artists:"); for (int i = IndexOfTags; i < IndexOfArtists; i++){ TagsSection += HttpGalleryString[i]; } StartTagName = TagsSection.IndexOf(Pattern1) + Pattern1.Length; EndTagName = TagsSection.IndexOf(Pattern2, StartTagName); do{ Tag = ""; for (int i = StartTagName; i < EndTagName; i++){ Tag += TagsSection[i]; } Tags.Add(Tag); LastStartTagName = StartTagName; StartTagName = TagsSection.IndexOf(Pattern1, EndTagName) + Pattern1.Length; EndTagName = TagsSection.IndexOf(Pattern2, StartTagName); } while (LastStartTagName < StartTagName); for (int i = 0; i < Tags.Count; i++){ if (Tags[i].Contains('=')){ Tags.Clear(); Tags.Add("Haha, kei Tags UmU"); } } return Tags; } private int GetGalleryId(string HttpGalleryString){ string Pattern1 = "#"; string Pattern2 = ""; string GalleryId = ""; int StartIndex = HttpGalleryString.IndexOf(Pattern1) + Pattern1.Length; for (int i = StartIndex; i < HttpGalleryString.IndexOf(Pattern2, StartIndex); i++){ GalleryId += HttpGalleryString[i]; } return int.Parse(GalleryId); } } }