Beispiel #1
0
 public override int GetHashCode()
 {
     unchecked
     {
         int hashCode = 13;
         hashCode = (hashCode * 17) ^ TypeOfFileSearch.GetHashCode();
         hashCode = (hashCode * 17) ^ FilePattern?.GetHashCode() ?? 5;
         hashCode = (hashCode * 17) ^ IgnoreFilePattern?.GetHashCode() ?? 5;
         hashCode = (hashCode * 17) ^ TypeOfSearch.GetHashCode();
         hashCode = (hashCode * 17) ^ SearchFor?.GetHashCode() ?? 5;
         hashCode = (hashCode * 17) ^ ReplaceWith?.GetHashCode() ?? 5;
         hashCode = (hashCode * 17) ^ CaseSensitive.GetHashCode();
         hashCode = (hashCode * 17) ^ WholeWord.GetHashCode();
         hashCode = (hashCode * 17) ^ Multiline.GetHashCode();
         hashCode = (hashCode * 17) ^ Singleline.GetHashCode();
         hashCode = (hashCode * 17) ^ BooleanOperators.GetHashCode();
         hashCode = (hashCode * 17) ^ IncludeSubfolders.GetHashCode();
         hashCode = (hashCode * 17) ^ IncludeHidden.GetHashCode();
         hashCode = (hashCode * 17) ^ IncludeBinary.GetHashCode();
         hashCode = (hashCode * 17) ^ MaxSubfolderDepth.GetHashCode();
         hashCode = (hashCode * 17) ^ UseGitignore.GetHashCode();
         hashCode = (hashCode * 17) ^ SkipRemoteCloudStorageFiles.GetHashCode();
         hashCode = (hashCode * 17) ^ IncludeArchive.GetHashCode();
         hashCode = (hashCode * 17) ^ FollowSymlinks.GetHashCode();
         hashCode = (hashCode * 17) ^ CodePage.GetHashCode();
         hashCode = (hashCode * 17) ^ ApplyFileSourceFilters.GetHashCode();
         hashCode = (hashCode * 17) ^ ApplyFilePropertyFilters.GetHashCode();
         hashCode = (hashCode * 17) ^ ApplyContentSearchFilters.GetHashCode();
         return(hashCode);
     }
 }
Beispiel #2
0
        protected override RuleResult processQueryPart(SplittingQuery.Part part)
        {
            if (part == null)
            {
                return(null);
            }

            if (string.IsNullOrWhiteSpace(this.ReplaceWith))
            {
                return(null); // new RuleResult(SplittingQuery.SplitQuery(" "), this.NextStep);
            }
            if (              //this.ReplaceWith.Contains("${q}") &&
                part.Prefix.Equals(_prefix, StringComparison.InvariantCultureIgnoreCase) &&
                (
                    string.IsNullOrWhiteSpace(_valueConstrain) ||
                    Regex.IsMatch(part.Value, _valueConstrain, HlidacStatu.Util.Consts.DefaultRegexQueryOption)
                )
                )
            {
                string rq = " " + ReplaceWith.Replace("${q}", part.Value);
                return(new RuleResult(SplittingQuery.SplitQuery($" {rq} "), this.NextStep));
            }

            return(null);
        }
 public override int GetHashCode()
 {
     unchecked
     {
         int hashCode = 13;
         hashCode = (hashCode * 17) ^ TypeOfFileSearch.GetHashCode();
         hashCode = (hashCode * 17) ^ FilePattern.GetHashCode();
         hashCode = (hashCode * 17) ^ IgnoreFilePattern.GetHashCode();
         hashCode = (hashCode * 17) ^ TypeOfSearch.GetHashCode();
         hashCode = (hashCode * 17) ^ SearchFor.GetHashCode();
         hashCode = (hashCode * 17) ^ ReplaceWith.GetHashCode();
         hashCode = (hashCode * 17) ^ CaseSensitive.GetHashCode();
         hashCode = (hashCode * 17) ^ WholeWord.GetHashCode();
         hashCode = (hashCode * 17) ^ Multiline.GetHashCode();
         hashCode = (hashCode * 17) ^ Singleline.GetHashCode();
         hashCode = (hashCode * 17) ^ BooleanOperators.GetHashCode();
         hashCode = (hashCode * 17) ^ IncludeSubfolders.GetHashCode();
         hashCode = (hashCode * 17) ^ IncludeHidden.GetHashCode();
         hashCode = (hashCode * 17) ^ IncludeBinary.GetHashCode();
         hashCode = (hashCode * 17) ^ MaxSubfolderDepth.GetHashCode();
         hashCode = (hashCode * 17) ^ UseGitignore.GetHashCode();
         hashCode = (hashCode * 17) ^ IncludeArchive.GetHashCode();
         hashCode = (hashCode * 17) ^ FollowSymlinks.GetHashCode();
         hashCode = (hashCode * 17) ^ CodePage.GetHashCode();
         return(hashCode);
     }
 }
Beispiel #4
0
 private int GetReplaceHash()
 {
     unchecked
     {
         int hashCode = GetSearchHash();
         hashCode = (hashCode * 397) ^ ReplaceWith?.GetHashCode() ?? 5;
         return(hashCode);
     }
 }
Beispiel #5
0
 public override int GetHashCode()
 {
     unchecked
     {
         int hashCode = 13;
         hashCode = (hashCode * 397) ^ FilePattern.GetHashCode();
         hashCode = (hashCode * 397) ^ SearchFor.GetHashCode();
         hashCode = (hashCode * 397) ^ ReplaceWith.GetHashCode();
         return(hashCode);
     }
 }
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = base.GetHashCode();
         hashCode = (hashCode * 397) ^ (FieldsToSearch != null ? FieldsToSearch.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Find != null ? Find.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ReplaceWith != null ? ReplaceWith.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ CaseMatch.GetHashCode();
         hashCode = (hashCode * 397) ^ (Result != null ? Result.GetHashCode() : 0);
         return(hashCode);
     }
 }
            public int CompareTo(object obj)
            {
                Substitution b = (Substitution)obj;
                int          x = SearchFor.CompareTo(b.SearchFor);

                if (x != 0)
                {
                    return(x);
                }
                x = ReplaceWith.CompareTo(b.ReplaceWith);
                if (x != 0)
                {
                    return(x);
                }
                return(Scope.CompareTo(b.Scope));
            }
Beispiel #8
0
        internal string Replace(Microsoft.CodeAnalysis.INamedTypeSymbol typeInfo)
        {
            if (ReplaceWith.StartsWith("{"))
            {
                var args = ReplaceWith.Substring(1, ReplaceWith.Length - 2).Split(' ');
                switch (args[0])
                {
                case "typeparameter":
                    return(TypeProcessor.ConvertType(typeInfo.TypeArguments.ElementAt(int.Parse(args[1]))));

                default:
                    throw new Exception("Invalid parameter: " + args[0]);
                }
            }
            else
            {
                return(this.ReplaceWith);
            }
        }
Beispiel #9
0
        protected override RuleResult processQueryPart(SplittingQuery.Part part)
        {
            if (part == null)
            {
                return(null);
            }


            if (
                (
                    (!string.IsNullOrWhiteSpace(_specificPrefix) && part.Prefix.Equals(_specificPrefix, StringComparison.InvariantCultureIgnoreCase))
                    ||
                    (part.Prefix.Equals("osobaid:", StringComparison.InvariantCultureIgnoreCase) ||
                     part.Prefix.Equals("osobaidprijemce:", StringComparison.InvariantCultureIgnoreCase) ||
                     part.Prefix.Equals("osobaidplatce:", StringComparison.InvariantCultureIgnoreCase)

                     || part.Prefix.Equals("osobaidveritel:", StringComparison.InvariantCultureIgnoreCase) ||
                     part.Prefix.Equals("osobaidveritel:", StringComparison.InvariantCultureIgnoreCase)

                     || part.Prefix.Equals("osobaidspravce:", StringComparison.InvariantCultureIgnoreCase) ||
                     part.Prefix.Equals("osobaidzadavatel:", StringComparison.InvariantCultureIgnoreCase) ||
                     part.Prefix.Equals("osobaiddodavatel:", StringComparison.InvariantCultureIgnoreCase)
                    )
                ) &&
                (Regex.IsMatch(part.Value, @"(?<q>((\w{1,} [-]{1} \w{1,})([-]{1} \d{1,3})?))", HlidacStatu.Util.Consts.DefaultRegexQueryOption))
                )
            {
                if (!string.IsNullOrWhiteSpace(this.ReplaceWith))
                {
                    //list of ICO connected to this person
                    string nameId = part.Value;

                    Data.Osoba p         = Data.Osoby.GetByNameId.Get(nameId);
                    string     icosQuery = "";

                    //string icoprefix = replaceWith;
                    var templ = $" ( {ReplaceWith}{{0}} ) ";
                    if (ReplaceWith.Contains("${q}"))
                    {
                        templ = $" ( {ReplaceWith.Replace("${q}", "{0}")} )";
                    }
                    if (p != null)
                    {
                        var icos = p
                                   .AktualniVazby(Data.Relation.AktualnostType.Nedavny)
                                   .Where(w => !string.IsNullOrEmpty(w.To.Id))
                                   //.Where(w => Analysis.ACore.GetBasicStatisticForICO(w.To.Id).Summary.Pocet > 0)
                                   .Select(w => w.To.Id)
                                   .Distinct().ToArray();


                        if (icos != null && icos.Length > 0)
                        {
                            icosQuery = " ( " + icos
                                        .Select(t => string.Format(templ, t))
                                        .Aggregate((f, s) => f + " OR " + s) + " ) ";
                        }
                        else
                        {
                            icosQuery = string.Format(templ, "noOne"); //$" ( {icoprefix}:noOne ) ";
                        }
                        bool lastCondAdded = false;
                        if (!string.IsNullOrEmpty(this.AddLastCondition))
                        {
                            if (this.AddLastCondition.Contains("${q}"))
                            {
                                icosQuery = Tools.ModifyQueryOR(icosQuery, this.AddLastCondition.Replace("${q}", part.Value));
                            }
                            else
                            {
                                icosQuery = Tools.ModifyQueryOR(icosQuery, this.AddLastCondition);
                            }
                            lastCondAdded = true;
                            //this.AddLastCondition = null; //done, don't do it anywhere
                        }
                        return(new RuleResult(SplittingQuery.SplitQuery($"{icosQuery}"), this.NextStep, lastCondAdded));
                    }
                } // if (!string.IsNullOrWhiteSpace(this.ReplaceWith))
                else if (!string.IsNullOrWhiteSpace(this.AddLastCondition))
                {
                    if (this.AddLastCondition.Contains("${q}"))
                    {
                        var q = this.AddLastCondition.Replace("${q}", part.Value);
                        return(new RuleResult(SplittingQuery.SplitQuery(q), this.NextStep, true));
                    }
                    else
                    {
                        var q = this.AddLastCondition;
                        return(new RuleResult(SplittingQuery.SplitQuery(q), this.NextStep, true));
                    }
                }
            }
            return(null);
        }
 private string GetBraceNewLineFormatting(ReplaceWith format) {
     switch (format) {
         case ReplaceWith.InsertNewLineAndIndentation:
             return _options.NewLine + GetIndentation();
         case ReplaceWith.InsertSpace:
             return " ";
         default:
             throw new InvalidOperationException();
     }
 }
 private void ReplacePreceedingIncludingNewLines(int start, ReplaceWith braceOnNewline, bool replaceOnNewLine = false) {
     int codeIndex;
     for (codeIndex = start - 1; codeIndex >= 0; codeIndex--) {
         if (_code[codeIndex] == '\r' || _code[codeIndex] == '\n') {
             // new lines are always ok to replace...
             if (replaceOnNewLine) {
                 MaybeReplaceText(
                    codeIndex + 1,
                    start,
                    GetIndentation());
                 break;
             }
             continue;
         } else if (_code[codeIndex] == ' ' || _code[codeIndex] == '\t') {
             // spaces are ok as long as we're not just trying to fix up newlines...
             continue;
         } else {
             // hit a newline, replace the indentation with new indentation
             MaybeReplaceText(
                 codeIndex + 1,
                 start,
                 GetBraceNewLineFormatting(braceOnNewline)
             );
             break;
         }
     }
     if (codeIndex == -1) {
         MaybeReplaceText(
             0,
             start,
             GetBraceNewLineFormatting(braceOnNewline)
         );
     }
 }