private void SaveStyleData(string value, string name, IFilterLine line) { if (string.IsNullOrEmpty(name)) { return; } if (valueToNamesDic.ContainsKey(value)) { if (valueToNamesDic[value].ContainsKey(name)) { valueToNamesDic[value][name]++; } else { valueToNamesDic[value].Add(name, 1); } } else { valueToNamesDic.Add(value, new Dictionary <string, int> { { name, 1 } }); } }
private void VerifyStyleValues(string value, string name, IFilterLine line) { if (this.nameToValuesDic.ContainsKey(name)) { var newValue = this.nameToValuesDic[name].Keys.Single(); if (newValue == value) { return; } var newLine = LineParser.GenerateFilterLine(LineParser.TokenizeFilterLineString(line.Ident + " " + newValue)); line.Value = newLine.Value; } else if (this.valueToNamesDic.ContainsKey(value)) { // style name was removed -> check dic for new name var newName = this.valueToNamesDic[value].Keys.Single(); if (newName == name) { return; } line.Comment = newName; } }
public void AddComment(IFilterLine line) { if (!this.Content.ContainsKey("comment")) { this.Content.Add("comment", new List <IFilterLine>()); } this.Content["comment"].Add(line); }
public bool Add(IFilterLine line) { if (!this.Content.ContainsKey(line.Ident)) { this.Content.Add(line.Ident, new List <IFilterLine>()); this.Content[line.Ident].Add(line); return(true); } this.Content[line.Ident].Add(line); return(false); }
private void AddNewSection(string name, int depth, IFilterLine line) { // the more brackets, the less deep the section is -> we invert that number here depth = MaxDepth - depth; var index = this.AddIndex(depth); var prefix = this.GetPrefix(depth); var title = this.BuildLineTitle(depth, index, name, prefix); line.Comment = title; this.tableLines.Add(title); }
public bool Equals(IFilterLine line) { if (this.Ident != line.Ident) { return(false); } if (this.Enabled != line.Enabled) { return(false); } return(this.Value.Equals(line.Value)); }
public static FilterEntry CreateDataEntry(IFilterLine line) { var entry = new FilterEntry(); entry.Header = new FilterEntryHeader(); entry.Header.HeaderValue = line.Ident; entry.Header.IsFrozen = line.identCommented; entry.Header.IsActive = true; entry.Header.Type = FilterGenerationConfig.FilterEntryType.Content; entry.Header.ExtractTagsFromLine(line, entry); entry.Content = new FilterEntryDataContent(); entry.Content.Content = new Dictionary <string, List <IFilterLine> >(); return(entry); }
public static FilterEntry CreateCommentEntry(IFilterLine line) { var entry = new FilterEntry(); entry.Header = new FilterEntryHeader(); entry.Header.Type = FilterGenerationConfig.FilterEntryType.Comment; entry.Header.IsFrozen = true; entry.Header.IsActive = true; entry.Content = new FilterEntryDataContent(); entry.Content.Content = new Dictionary <string, List <IFilterLine> >(); entry.Content.AddComment(line); return(entry); }
private void VerifyStyleNames(string value, string name, IFilterLine line) { if (this.valueToNamesDic.ContainsKey(value)) { var styleNames = this.valueToNamesDic[value]; var newName = styleNames.Keys.Single(); if (newName == name) { return; } line.Comment = newName; } else if (this.nameToValuesDic.ContainsKey(name)) { throw new Exception("unexpected care for styleVerifier"); } }
private void VerifyStyleNames(string value, string name, IFilterLine line) { if (this.valueToNamesDic.ContainsKey(value)) { var styleNames = this.valueToNamesDic[value]; var newName = styleNames.OrderByDescending(x => x.Value).First().Key; if (newName == name) { return; } line.Comment = newName; } else if (this.nameToValuesDic.ContainsKey(name)) { Console.WriteLine("todo"); // throw new Exception("unexpected care for styleVerifier"); } }
private void VerifyStyleValues(string value, string name, IFilterLine line) { // if (this.nameToValuesDic.ContainsKey(name)) // { // var newValue = this.nameToValuesDic[name].OrderByDescending(x => x.Value).First().Key; //// if (newValue == value) return; // // var newLine = LineParser.GenerateFilterLine(LineParser.TokenizeFilterLineString(line.Ident + " " + newValue)); // line.Value = newLine.Value; // } if (this.valueToNamesDic.ContainsKey(value)) { // style name was removed -> check dic for new name var newName = this.valueToNamesDic[value].OrderByDescending(x => x.Value).First().Key; if (newName == name) { return; } line.Comment = newName; } }
public bool Has(IFilterLine line) { return(this.Has(line.Ident)); }
public static IFilterLine AddCore(this IFilterLine me, ILineValueCore LineValueCore) { me.Value = LineValueCore; return(me); }
public void ExtractTagsFromLine(IFilterLine line, FilterEntry entry) { GenerationTags = new List <GenerationTag>(); TierTags = new TierTagSet(); bool firstComment = true; StringBuilder builder = new StringBuilder(); var strings = line.Comment.ToLower().Split(FilterGenerationConfig.WhiteLineChars); foreach (var s in strings) { if (s.Length == 0) { continue; } if (s[0] == '%') { GenerationTag tag; var split = s.Substring(1).ToUpper(); var lastPos = split.Length - 1; var command = split.Substring(0, lastPos); short digit = -1; // in case the command is something without digit at the end (like %UP, unlike %h3) if (FilterGenerationConfig.EntryCommand.ContainsKey(split)) { command = split; } // checking if the last char is a digit wont work correctly in cases of e.g. "crafting-83" // which will save the "3" as strictness, so we instead check if the command is in the EntryCommand list else if (FilterGenerationConfig.EntryCommand.ContainsKey(command)) { digit = short.Parse(split.Substring(lastPos)); } else if (FilterGenerationConfig.EntryCommand.ContainsKey(split.Split(new[] { "->" }, StringSplitOptions.None).First())) { command = split.Split(new[] { "->" }, StringSplitOptions.None).First(); } else { throw new Exception("unknown entry tag command: " + split); } var tagType = FilterGenerationConfig.EntryCommand[command]; tag = tagType(entry) as GenerationTag; tag.Strictness = digit; tag.Value = command; if (tag is ReceiverEntryCommand r) { r.TypeValue = split.Replace(command, ""); } if (tag is SenderEntryCommand se) { se.TypeValue = split.Replace(command, ""); } this.GenerationTags.Add(tag); } else if (s[0] == '$') { this.TierTags.Add(s); } else { if (!firstComment) { builder.Append(" "); } else { firstComment = false; } builder.Append(s); } } HeaderComment = builder.ToString(); }
public List <IFilterLine> Get(IFilterLine line) { return(this.Get(line.Ident)); }
public IFilterLine GetFirst(IFilterLine line) { return(this.GetFirst(line.Ident)); }
public static IFilterLine Define(this IFilterLine me, string ident) { me.Ident = ident; return(me); }