コード例 #1
0
            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 }
                    });
                }
            }
コード例 #2
0
            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;
                }
            }
コード例 #3
0
        public void AddComment(IFilterLine line)
        {
            if (!this.Content.ContainsKey("comment"))
            {
                this.Content.Add("comment", new List <IFilterLine>());
            }

            this.Content["comment"].Add(line);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
 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));
 }
コード例 #7
0
ファイル: FilterEntry.cs プロジェクト: srlehn/FilterPolishZ
        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);
        }
コード例 #8
0
ファイル: FilterEntry.cs プロジェクト: srlehn/FilterPolishZ
        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);
        }
コード例 #9
0
            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");
                }
            }
コード例 #10
0
            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");
                }
            }
コード例 #11
0
            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;
                }
            }
コード例 #12
0
 public bool Has(IFilterLine line)
 {
     return(this.Has(line.Ident));
 }
コード例 #13
0
ファイル: IFilterLine.cs プロジェクト: srlehn/FilterPolishZ
 public static IFilterLine AddCore(this IFilterLine me, ILineValueCore LineValueCore)
 {
     me.Value = LineValueCore;
     return(me);
 }
コード例 #14
0
        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();
        }
コード例 #15
0
 public List <IFilterLine> Get(IFilterLine line)
 {
     return(this.Get(line.Ident));
 }
コード例 #16
0
 public IFilterLine GetFirst(IFilterLine line)
 {
     return(this.GetFirst(line.Ident));
 }
コード例 #17
0
ファイル: IFilterLine.cs プロジェクト: srlehn/FilterPolishZ
 public static IFilterLine Define(this IFilterLine me, string ident)
 {
     me.Ident = ident;
     return(me);
 }