public object Clone() { BooruTagList cList = new BooruTagList(); this.ForEach(x => cList.Add(x.Clone() as BooruTag)); return(cList); }
private static void TagDelta(ref BooruTagList Tags, string deltaString) { var removeTags = new List <string>(); var addTags = new List <string>(); string[] deltaParts = deltaString.Split(new char[1] { ' ' }, StringSplitOptions.RemoveEmptyEntries); foreach (string part in deltaParts) { if (part.StartsWith("_") && part.Length > 1) { removeTags.Add(part.Substring(1).ToLower()); } else { addTags.Add(part.ToLower()); } } for (int i = Tags.Count - 1; !(i < 0); i--) { if (removeTags.Contains(Tags[i].Tag)) { Tags.RemoveAt(i); } } foreach (string addTag in addTags) { Tags.Add(new BooruTag(addTag)); } }
public static BooruTagList FromTable(DataTable Table) { BooruTagList bTagList = new BooruTagList(); foreach (DataRow row in Table.Rows) { bTagList.Add(BooruTag.FromRow(row)); } return(bTagList); }
public static BooruTagList FromReader(ReaderWriter Reader) { uint count = Reader.ReadUInt(); BooruTagList bTagList = new BooruTagList(); for (uint i = 0; i < count; i++) { bTagList.Add(BooruTag.FromReader(Reader)); } return(bTagList); }
private static ulong AddPost(Stream str, BooruPost Post, BooruTagList Tags, BooruImage Image) { ulong postID = 0; Request(str, RequestCode.Add_Post, (rw) => { Post.ToWriter(rw); Tags.ToWriter(rw); Image.ToWriter(rw); }, (rw) => { postID = rw.ReadULong(); }); return(postID); }
public static BooruTagList FromString(string Tags) { BooruTagList bTagList = new BooruTagList(); if (!string.IsNullOrWhiteSpace(Tags)) { string[] parts = Tags.Split(new char[4] { ' ', '\r', '\n', '\t' }, StringSplitOptions.RemoveEmptyEntries); foreach (string part in parts) { bTagList.Add(new BooruTag(part.ToLower())); } } return(bTagList); }
private static string BooruTagListToString(BooruTagList Tags, bool Color) { string[] strTags = new string[Tags.Count]; for (int i = 0; i < strTags.Length; i++) { if (Color) { strTags[i] = "\x1b[38;5;" + ColorHelper.GetXTermIndexFromColor(Tags[i].Color) + "m" + Tags[i].Tag; } else { strTags[i] = Tags[i].Tag; } } return(string.Join(" ", strTags) + (Color ? "\x1b[0m" : string.Empty)); }
private static BooruPost GetPost(Stream str, ulong ID) { BooruPost post = null; Request(str, RequestCode.Get_Post, (rw) => rw.Write(ID), (rw) => { post = BooruPost.FromReader(rw); }); Request(str, RequestCode.Get_PostTags, (rw) => rw.Write(ID), (rw) => { post.Tags = BooruTagList.FromReader(rw); }); return(post); }