47 lines
1.8 KiB
C#
47 lines
1.8 KiB
C#
using Microsoft.Extensions.Logging;
|
|
namespace File_Folder_Helper.ADO2024.PI3;
|
|
|
|
internal static partial class Helper20240916
|
|
{
|
|
|
|
internal static void DebugProxyPass(ILogger<Worker> logger, List<string> args)
|
|
{
|
|
string debug;
|
|
string domain;
|
|
string[] lines;
|
|
string fileName;
|
|
string[] segments;
|
|
string includePath = args[3];
|
|
string searchString = args[4];
|
|
string searchPattern = args[2];
|
|
string[] searchStrings = args[5].Split('~');
|
|
string sourceDirectory = Path.GetFullPath(args[0]);
|
|
string[] files = Directory.GetFiles(sourceDirectory, searchPattern, SearchOption.AllDirectories);
|
|
logger.LogInformation("With search pattern '{SearchPattern}' found {files} file(s)", searchPattern, files.Length);
|
|
foreach (string file in files)
|
|
{
|
|
debug = string.Empty;
|
|
domain = string.Empty;
|
|
lines = File.ReadAllLines(file);
|
|
fileName = Path.GetFileName(file);
|
|
foreach (string line in lines)
|
|
{
|
|
segments = line.Split(searchString, StringSplitOptions.None);
|
|
if (segments.Length > 1 && segments[1][0] is ' ' or '\t')
|
|
domain = segments[1].Trim();
|
|
segments = line.Split(searchStrings, StringSplitOptions.None);
|
|
if (segments.Length < 2)
|
|
continue;
|
|
if (segments[1][0] is not ' ' and not '\t')
|
|
continue;
|
|
debug = segments[1].Trim();
|
|
}
|
|
logger.LogInformation("include {includePath}{fileName}; # https://{domain} # {debug}",
|
|
includePath,
|
|
fileName,
|
|
domain,
|
|
debug);
|
|
}
|
|
}
|
|
|
|
} |