private static void FilterIniFile(string SourceName, string TargetName, List <string> IniKeyBlacklist, List <string> InSectionBlacklist)
        {
            string[]      Lines             = File.ReadAllLines(SourceName);
            StringBuilder NewLines          = new StringBuilder("");
            bool          bFilteringSection = false;

            foreach (string OriginalLine in Lines)
            {
                string Line      = OriginalLine.Trim();
                bool   bFiltered = bFilteringSection;

                // look for each filter on each line
                if (!bFiltered)
                {
                    string TrimmedLine = Line.TrimStart(IgnoredIniValuePrefixes);
                    foreach (string Filter in IniKeyBlacklist)
                    {
                        if (TrimmedLine.StartsWith(Filter + "="))
                        {
                            bFiltered = true;
                            break;
                        }
                    }
                }

                if (InSectionBlacklist != null)
                {
                    if (Line.StartsWith("[") && Line.EndsWith("]"))
                    {
                        string SectionName = Line.Substring(1, Line.Length - 2);
                        bFilteringSection = bFiltered = InSectionBlacklist.Contains(SectionName);

                        if (bFilteringSection)
                        {
                            Log.TraceLog("Filtering config section '{0}'", SectionName);
                        }
                    }
                }

                // write out if it's not filtered out
                if (!bFiltered)
                {
                    NewLines.AppendLine(Line);
                }
            }

            // now write out the final .ini file
            if (File.Exists(TargetName))
            {
                File.Delete(TargetName);
            }
            File.WriteAllText(TargetName, NewLines.ToString());

            // other code assumes same timestamp for source and dest
            File.SetLastWriteTimeUtc(TargetName, File.GetLastWriteTimeUtc(SourceName));
        }
Exemple #2
0
 public override string ToString()
 {
     return(string.Format("{0} {1} ({2}, {3}) [original: {4} ({5}, {6})]",
                          Message,
                          MappedFilePath ?? "",
                          MappedLine.ToString(),
                          MappedColumn.ToString(),
                          OriginalFilePath ?? "",
                          OriginalLine.ToString(),
                          OriginalColumn.ToString()));
 }
Exemple #3
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = GeneratedLine.GetHashCode();
         hashCode = (hashCode * 397) ^ GeneratedColumn.GetHashCode();
         hashCode = (hashCode * 397) ^ OriginalLine.GetHashCode();
         hashCode = (hashCode * 397) ^ OriginalColumn.GetHashCode();
         hashCode = (hashCode * 397) ^ (Source != null ? Source.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Name != null ? Name.GetHashCode() : 0);
         return(hashCode);
     }
 }
Exemple #4
0
 public override string ToString()
 {
     return(string.Format("{0} {1} {2} {3} {4} {5} ({5}, {6}) [original: {7} ({8}, {9})]",
                          Id,
                          Message,
                          Severity.ToString(),
                          ProjectId,
                          MappedFilePath ?? "",
                          MappedLine.ToString(),
                          MappedColumn.ToString(),
                          OriginalFilePath ?? "",
                          OriginalLine.ToString(),
                          OriginalColumn.ToString()));
 }
Exemple #5
0
        protected override void PostSyntaxFixes()
        {
            // This should be some mistake -- likely missing directives
            // PDS doc does say symbols must start in column 1

            // In ACME, symbols not beginning in column 1 must end in ':'
            if (Symbol.Length > 0 &&
                !Symbol.EndsWith(":") &&
                !OriginalLine.StartsWith(Symbol))
            {
                var codeIndex = Code.IndexOf(Symbol);
                Code = Code.Substring(codeIndex);
            }
        }
Exemple #6
0
 public override string ToString()
 => $"{Priority} {Message} {MappedFilePath ?? ""} ({MappedLine.ToString()}, {MappedColumn.ToString()}) [original: {OriginalFilePath ?? ""} ({OriginalLine.ToString()}, {OriginalColumn.ToString()})";