nuget bump
2023-11-02 2023-11-08 net8.0 editorconfig NuGet NuSpec Kanban
This commit is contained in:
@ -146,8 +146,8 @@ internal static partial class HelperCreateNoteFiles
|
||||
file = string.Concat(Path.Combine(directory, $"{dateTime:yyyy-MM-dd}.md"));
|
||||
if (File.Exists(file))
|
||||
continue;
|
||||
File.WriteAllLines(file, new string[]
|
||||
{
|
||||
File.WriteAllLines(file,
|
||||
[
|
||||
"---",
|
||||
"type: daily-note",
|
||||
$"created: {dateTime:yyyy-MM-dd}",
|
||||
@ -158,7 +158,7 @@ internal static partial class HelperCreateNoteFiles
|
||||
"```bash",
|
||||
string.Empty,
|
||||
"```",
|
||||
});
|
||||
]);
|
||||
if (directory != lastDirectory)
|
||||
{
|
||||
Directory.SetCreationTime(directory, dateTime);
|
||||
@ -192,8 +192,8 @@ internal static partial class HelperCreateNoteFiles
|
||||
string? attributes;
|
||||
int descriptionKey = 2;
|
||||
string[]? headerColumns;
|
||||
List<string> allLines = [];
|
||||
string destinationDirectory;
|
||||
List<string> allLines = new();
|
||||
DateTime dateTime = new(ticks);
|
||||
string csvHeader = "type,title,description,tags,links,body";
|
||||
string tsvHeader = "type\ttitle\tdescription\ttags\tlinks\tbody";
|
||||
@ -275,8 +275,8 @@ internal static partial class HelperCreateNoteFiles
|
||||
|
||||
internal static void CreateNoteFiles(ILogger<Worker> logger, string argsZero)
|
||||
{
|
||||
List<string> importFiles = [];
|
||||
long ticks = DateTime.Now.Ticks;
|
||||
List<string> importFiles = new();
|
||||
CleanExistingFiles(logger, argsZero, ticks);
|
||||
importFiles.AddRange(Directory.GetFiles(argsZero, "*.csv", SearchOption.TopDirectoryOnly));
|
||||
importFiles.AddRange(Directory.GetFiles(argsZero, "*.tsv", SearchOption.TopDirectoryOnly));
|
||||
|
@ -24,7 +24,7 @@ internal static class HelperDeleteEmptyDirectories
|
||||
}
|
||||
}
|
||||
if (directories.Length > 0)
|
||||
files = Array.Empty<string>();
|
||||
files = [];
|
||||
else
|
||||
files = Directory.GetFiles(checkDirectory, "*", SearchOption.TopDirectoryOnly);
|
||||
if (directories.Length == 0 && files.Length == 0)
|
||||
@ -40,7 +40,7 @@ internal static class HelperDeleteEmptyDirectories
|
||||
}
|
||||
else
|
||||
{
|
||||
List<string> check = new();
|
||||
List<string> check = [];
|
||||
foreach (string directory in directories)
|
||||
{
|
||||
DeleteOldLogFilesAndDeleteEmptyDirectories(ticks, searchPattern, directory, check);
|
||||
@ -53,7 +53,7 @@ internal static class HelperDeleteEmptyDirectories
|
||||
|
||||
private static void DeleteOldLogFilesAndDeleteEmptyDirectories(ILogger<Worker> logger, long? ticks, string? searchPattern, string rootDirectory)
|
||||
{
|
||||
List<string> check = new();
|
||||
List<string> check = [];
|
||||
List<string> directories = Directory.GetDirectories(rootDirectory, "*", SearchOption.TopDirectoryOnly).ToList();
|
||||
directories.Add(rootDirectory);
|
||||
foreach (string directory in directories)
|
||||
|
@ -23,7 +23,7 @@ internal static class HelperFindReplace
|
||||
|
||||
private static ReadOnlyCollection<(string, string)> GetFindReplace(string tnsNamesOraFile)
|
||||
{
|
||||
List<(string, string)> results = new();
|
||||
List<(string, string)> results = [];
|
||||
string[] segments;
|
||||
string[] lines = File.ReadAllLines(tnsNamesOraFile);
|
||||
foreach (string line in lines)
|
||||
|
@ -73,7 +73,7 @@ internal static partial class HelperGenealogicalDataCommunication
|
||||
|
||||
private static ReadOnlyDictionary<long, ReadOnlyCollection<string>> Convert(Dictionary<long, List<string>> keyValuePairs)
|
||||
{
|
||||
Dictionary<long, ReadOnlyCollection<string>> results = new();
|
||||
Dictionary<long, ReadOnlyCollection<string>> results = [];
|
||||
foreach (KeyValuePair<long, List<string>> keyValuePair in keyValuePairs)
|
||||
results.Add(keyValuePair.Key, new(keyValuePair.Value));
|
||||
return new(results);
|
||||
@ -81,7 +81,7 @@ internal static partial class HelperGenealogicalDataCommunication
|
||||
|
||||
private static Dictionary<string, ReadOnlyCollection<ReadOnlyCollection<string>>> Convert(Dictionary<string, List<ReadOnlyCollection<string>>> keyValuePairs)
|
||||
{
|
||||
Dictionary<string, ReadOnlyCollection<ReadOnlyCollection<string>>> results = new();
|
||||
Dictionary<string, ReadOnlyCollection<ReadOnlyCollection<string>>> results = [];
|
||||
foreach (KeyValuePair<string, List<ReadOnlyCollection<string>>> keyValuePair in keyValuePairs)
|
||||
results.Add(keyValuePair.Key, new(keyValuePair.Value));
|
||||
return new(results);
|
||||
@ -91,13 +91,13 @@ internal static partial class HelperGenealogicalDataCommunication
|
||||
{
|
||||
List<string> results;
|
||||
if (person is null)
|
||||
results = new() { "Id", "First-Name", "Last-Name", "Birth-Date", "Sex", "Address", "City", "State", "Zip", "Phone", "E-mail", "Facebook", "Facebook-Id", "Comment", "U-Id" };
|
||||
results = ["Id", "First-Name", "Last-Name", "Birth-Date", "Sex", "Address", "City", "State", "Zip", "Phone", "E-mail", "Facebook", "Facebook-Id", "Comment", "U-Id"];
|
||||
else
|
||||
{
|
||||
string? facebook = GetFaceBook(person);
|
||||
string? facebookId = GetFaceBookId(person);
|
||||
results = new()
|
||||
{
|
||||
results =
|
||||
[
|
||||
person.Id.ToString(),
|
||||
string.Concat(person.Name?.Given),
|
||||
string.Concat(person.Name?.Sur),
|
||||
@ -113,7 +113,7 @@ internal static partial class HelperGenealogicalDataCommunication
|
||||
string.Concat(facebookId),
|
||||
string.Empty,
|
||||
string.Concat(person.UId)
|
||||
};
|
||||
];
|
||||
}
|
||||
return new(results);
|
||||
}
|
||||
@ -122,7 +122,7 @@ internal static partial class HelperGenealogicalDataCommunication
|
||||
{
|
||||
string[] results;
|
||||
string key;
|
||||
List<(string? Index, string Key)> collection = new();
|
||||
List<(string? Index, string Key)> collection = [];
|
||||
foreach (Family family in familyCollection)
|
||||
{
|
||||
if (family.Id is null)
|
||||
@ -138,7 +138,7 @@ internal static partial class HelperGenealogicalDataCommunication
|
||||
|
||||
private static Dictionary<string, List<ReadOnlyCollection<string>>> Convert(ReadOnlyCollection<string> distinctSortedKKeys)
|
||||
{
|
||||
Dictionary<string, List<ReadOnlyCollection<string>>> results = new();
|
||||
Dictionary<string, List<ReadOnlyCollection<string>>> results = [];
|
||||
ReadOnlyCollection<string> collection;
|
||||
List<ReadOnlyCollection<string>>? objectCollection;
|
||||
foreach (string key in distinctSortedKKeys)
|
||||
@ -147,7 +147,7 @@ internal static partial class HelperGenealogicalDataCommunication
|
||||
continue;
|
||||
if (!results.TryGetValue(key, out objectCollection))
|
||||
{
|
||||
results.Add(key, new());
|
||||
results.Add(key, []);
|
||||
if (!results.TryGetValue(key, out objectCollection))
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
@ -159,7 +159,7 @@ internal static partial class HelperGenealogicalDataCommunication
|
||||
|
||||
private static ReadOnlyCollection<string> GetHeaderLines(string startsWith, string[] sourceLines)
|
||||
{
|
||||
List<string> results = new();
|
||||
List<string> results = [];
|
||||
for (int i = 0; i < sourceLines.Length; i++)
|
||||
{
|
||||
if (sourceLines[i].StartsWith(startsWith))
|
||||
@ -179,7 +179,7 @@ internal static partial class HelperGenealogicalDataCommunication
|
||||
|
||||
private static Dictionary<string, List<string>> GetTxtFileCollection(Input input)
|
||||
{
|
||||
Dictionary<string, List<string>> results = new();
|
||||
Dictionary<string, List<string>> results = [];
|
||||
string[] lines;
|
||||
string[] directories;
|
||||
string directoryName;
|
||||
@ -188,7 +188,7 @@ internal static partial class HelperGenealogicalDataCommunication
|
||||
List<string>? collectionA;
|
||||
List<string>? collectionB;
|
||||
string siblingDirectoryName;
|
||||
string[] files = input.SingletonDirectory is null || !Directory.Exists(input.SingletonDirectory) ? Array.Empty<string>() : Directory.GetFiles(input.SingletonDirectory, "*.txt", SearchOption.AllDirectories);
|
||||
string[] files = input.SingletonDirectory is null || !Directory.Exists(input.SingletonDirectory) ? [] : Directory.GetFiles(input.SingletonDirectory, "*.txt", SearchOption.AllDirectories);
|
||||
foreach (string file in files)
|
||||
{
|
||||
sourceDirectory = Path.GetDirectoryName(file);
|
||||
@ -203,7 +203,7 @@ internal static partial class HelperGenealogicalDataCommunication
|
||||
directoryName = Path.GetFileName(sourceDirectory);
|
||||
if (!results.TryGetValue(directoryName, out collectionA))
|
||||
{
|
||||
results.Add(directoryName, new());
|
||||
results.Add(directoryName, []);
|
||||
if (!results.TryGetValue(directoryName, out collectionA))
|
||||
throw new Exception();
|
||||
}
|
||||
@ -219,7 +219,7 @@ internal static partial class HelperGenealogicalDataCommunication
|
||||
siblingDirectoryName = Path.GetFileName(directory);
|
||||
if (!results.TryGetValue(siblingDirectoryName, out collectionB))
|
||||
{
|
||||
results.Add(siblingDirectoryName, new());
|
||||
results.Add(siblingDirectoryName, []);
|
||||
if (!results.TryGetValue(siblingDirectoryName, out collectionB))
|
||||
throw new Exception();
|
||||
}
|
||||
@ -270,8 +270,8 @@ internal static partial class HelperGenealogicalDataCommunication
|
||||
bool moreAdded = false;
|
||||
List<string>? collection;
|
||||
DateOnly? dateOnly = null;
|
||||
List<string> distinct = new();
|
||||
List<string> @continue = new();
|
||||
List<string> distinct = [];
|
||||
List<string> @continue = [];
|
||||
for (int j = i + 1; j < lines.Count; j++)
|
||||
{
|
||||
if (lines[j][0] == '1')
|
||||
@ -324,7 +324,7 @@ internal static partial class HelperGenealogicalDataCommunication
|
||||
string seven;
|
||||
string? note = null;
|
||||
DateOnly? dateOnly = null;
|
||||
List<string> @continue = new();
|
||||
List<string> @continue = [];
|
||||
bool? isDead = lines[i].Length == 8 && lines[i][..8] == "1 DEAT Y" ? true : lines[i].Length == 8 && lines[i][..8] == "1 DEAT N" ? false : null;
|
||||
for (int j = i + 1; j < lines.Count; j++)
|
||||
{
|
||||
@ -364,7 +364,7 @@ internal static partial class HelperGenealogicalDataCommunication
|
||||
string seven;
|
||||
string? note = null;
|
||||
DateOnly? dateOnly = null;
|
||||
List<string> @continue = new();
|
||||
List<string> @continue = [];
|
||||
for (int j = i + 1; j < lines.Count; j++)
|
||||
{
|
||||
if (lines[j][0] == '1')
|
||||
@ -399,11 +399,11 @@ internal static partial class HelperGenealogicalDataCommunication
|
||||
|
||||
private static string[] GetNewLines(ReadOnlyCollection<string> lines, Birth? birth)
|
||||
{
|
||||
List<string> results = new();
|
||||
List<string> results = [];
|
||||
string six;
|
||||
string text;
|
||||
string seven;
|
||||
List<string> @continue = birth is null ? new() : birth.Continue.ToList();
|
||||
List<string> @continue = birth is null ? [] : birth.Continue.ToList();
|
||||
for (int i = 0; i < lines.Count; i++)
|
||||
{
|
||||
if (birth is null)
|
||||
@ -447,7 +447,7 @@ internal static partial class HelperGenealogicalDataCommunication
|
||||
|
||||
private static List<long> GetIdsWhenPersonHasTitle(ReadOnlyDictionary<long, Person> people)
|
||||
{
|
||||
List<long> results = new();
|
||||
List<long> results = [];
|
||||
foreach (KeyValuePair<long, Person> keyValuePair in people)
|
||||
{
|
||||
if (keyValuePair.Value.Title is null)
|
||||
@ -459,7 +459,7 @@ internal static partial class HelperGenealogicalDataCommunication
|
||||
|
||||
private static ReadOnlyCollection<GenealogicalDataCommunicationRelation> GetRelations(ReadOnlyCollection<ReadOnlyCollection<string>> familyGroupLines)
|
||||
{
|
||||
List<GenealogicalDataCommunicationRelation> results = new();
|
||||
List<GenealogicalDataCommunicationRelation> results = [];
|
||||
int id;
|
||||
string relation;
|
||||
string[] segments;
|
||||
@ -585,12 +585,12 @@ internal static partial class HelperGenealogicalDataCommunication
|
||||
{
|
||||
GenealogicalDataCommunicationCollections result;
|
||||
long? id;
|
||||
List<string> lines = new();
|
||||
List<string> lines = [];
|
||||
List<string> footerLines = [];
|
||||
const string startsWith = "0 @";
|
||||
List<string> footerLines = new();
|
||||
Dictionary<long, List<string>> keyValuePairs = new();
|
||||
List<ReadOnlyCollection<string>> familyGroupLines = new();
|
||||
string[] sourceLines = string.IsNullOrEmpty(input.GenealogicalDataCommunicationFile) || !File.Exists(input.GenealogicalDataCommunicationFile) ? Array.Empty<string>() : File.ReadAllLines(input.GenealogicalDataCommunicationFile);
|
||||
Dictionary<long, List<string>> keyValuePairs = [];
|
||||
List<ReadOnlyCollection<string>> familyGroupLines = [];
|
||||
string[] sourceLines = string.IsNullOrEmpty(input.GenealogicalDataCommunicationFile) || !File.Exists(input.GenealogicalDataCommunicationFile) ? [] : File.ReadAllLines(input.GenealogicalDataCommunicationFile);
|
||||
ReadOnlyCollection<string> headerLines = GetHeaderLines(startsWith, sourceLines);
|
||||
for (int i = headerLines.Count; i < sourceLines.Length; i++)
|
||||
{
|
||||
@ -632,7 +632,7 @@ internal static partial class HelperGenealogicalDataCommunication
|
||||
}
|
||||
if (id is null)
|
||||
throw new Exception(string.Join(Environment.NewLine, lines));
|
||||
keyValuePairs.Add(id.Value, new());
|
||||
keyValuePairs.Add(id.Value, []);
|
||||
if (lines.Count == 0)
|
||||
continue;
|
||||
keyValuePairs[id.Value].AddRange(lines);
|
||||
@ -648,7 +648,7 @@ internal static partial class HelperGenealogicalDataCommunication
|
||||
|
||||
private static ReadOnlyDictionary<long, Person> GetPeople(Input input, GenealogicalDataCommunicationCollections genealogicalDataCommunicationCollections)
|
||||
{
|
||||
Dictionary<long, Person> results = new();
|
||||
Dictionary<long, Person> results = [];
|
||||
long? id;
|
||||
char? sex;
|
||||
Name? name;
|
||||
@ -724,11 +724,11 @@ internal static partial class HelperGenealogicalDataCommunication
|
||||
Collections result;
|
||||
long personKey;
|
||||
char[] ageCollection;
|
||||
Dictionary<long, string> idToName = new();
|
||||
Dictionary<long, long> idToPersonKey = new();
|
||||
Dictionary<long, string> idToGivenName = new();
|
||||
List<PersonExport> collection = [];
|
||||
Dictionary<long, string> idToName = [];
|
||||
Dictionary<long, long> idToPersonKey = [];
|
||||
Dictionary<long, string> idToGivenName = [];
|
||||
int length = appSettings.PersonBirthdayFormat.Length;
|
||||
List<PersonExport> collection = new();
|
||||
foreach (KeyValuePair<long, Person> keyValuePair in people)
|
||||
{
|
||||
if (keyValuePair.Value.Birth?.Note is null)
|
||||
@ -742,7 +742,7 @@ internal static partial class HelperGenealogicalDataCommunication
|
||||
personKey = dateTime.Ticks;
|
||||
idToPersonKey.Add(keyValuePair.Key, personKey);
|
||||
idToName.Add(keyValuePair.Key, WindowsFileSystem().Replace(keyValuePair.Value.Name.ForwardSlashFull, "_"));
|
||||
ageCollection = keyValuePair.Value.Birth.Continue.Count == 0 ? Array.Empty<char>() : keyValuePair.Value.Birth.Continue[0].ToArray();
|
||||
ageCollection = keyValuePair.Value.Birth.Continue.Count == 0 ? [] : keyValuePair.Value.Birth.Continue[0].ToArray();
|
||||
idToGivenName.Add(keyValuePair.Key, string.IsNullOrEmpty(keyValuePair.Value.Name.Given) ? WindowsFileSystem().Replace(keyValuePair.Value.Name.ForwardSlashFull, "_") : WindowsFileSystem().Replace(keyValuePair.Value.Name.Given, "_"));
|
||||
collection.Add(new(keyValuePair.Key, new(keyValuePair.Value.Lines), keyValuePair.Value.Birth.Note, ageCollection, dateTime, personKey));
|
||||
}
|
||||
@ -752,7 +752,7 @@ internal static partial class HelperGenealogicalDataCommunication
|
||||
|
||||
private static List<Family> GetFamilyCollection(ReadOnlyCollection<ReadOnlyCollection<string>> familyGroupLines, ReadOnlyDictionary<long, Person> people, ReadOnlyDictionary<long, long> idToPersonKey, ReadOnlyDictionary<long, string> idToName, ReadOnlyDictionary<long, string> idToGivenName)
|
||||
{
|
||||
List<Family> results = new();
|
||||
List<Family> results = [];
|
||||
string? name;
|
||||
long personKey;
|
||||
Person? person;
|
||||
@ -862,8 +862,8 @@ internal static partial class HelperGenealogicalDataCommunication
|
||||
|
||||
private static void WriteGenealogicalDataCommunicationCollections(ILogger<Worker> logger, Input input, GenealogicalDataCommunicationCollections genealogicalDataCommunicationCollections, ReadOnlyDictionary<long, Person> people)
|
||||
{
|
||||
List<string> lines = new();
|
||||
List<string> allLines = new();
|
||||
List<string> lines = [];
|
||||
List<string> allLines = [];
|
||||
if (genealogicalDataCommunicationCollections.HeaderLines.Count > 0)
|
||||
{
|
||||
allLines.AddRange(genealogicalDataCommunicationCollections.HeaderLines);
|
||||
@ -931,8 +931,8 @@ internal static partial class HelperGenealogicalDataCommunication
|
||||
long count = ticks;
|
||||
string rootDirectory;
|
||||
string approximateYears;
|
||||
List<string> distinct = new();
|
||||
List<string> duplicates = new();
|
||||
List<string> distinct = [];
|
||||
List<string> duplicates = [];
|
||||
string personDisplayDirectoryName;
|
||||
foreach (PersonExport personExport in personExportCollection)
|
||||
{
|
||||
@ -1010,7 +1010,7 @@ internal static partial class HelperGenealogicalDataCommunication
|
||||
[Obsolete]
|
||||
private static string[] GetNewLines(ReadOnlyCollection<string> lines, Name? name, string[] kFiles, string[] mFiles, string[] k2Files, string[] m2Files)
|
||||
{
|
||||
List<string> results = new();
|
||||
List<string> results = [];
|
||||
string six;
|
||||
int? birthLastLine = null;
|
||||
string slugName = WindowsFileSystem().Replace(string.Concat(name?.ForwardSlashFull), "_");
|
||||
|
@ -17,8 +17,8 @@ internal static class HelperHardcodedFileSearchAndSort
|
||||
string checkDirectory;
|
||||
CultureInfo cultureInfo = new("en-US");
|
||||
Calendar calendar = cultureInfo.Calendar;
|
||||
string[] hardcodedValues = new string[]
|
||||
{
|
||||
string[] hardcodedValues =
|
||||
[
|
||||
"BIORAD2",
|
||||
"BIORAD3",
|
||||
"BIORAD4",
|
||||
@ -40,7 +40,7 @@ internal static class HelperHardcodedFileSearchAndSort
|
||||
"WC6Inch",
|
||||
"WC8Inch",
|
||||
"Bio-Rad"
|
||||
};
|
||||
];
|
||||
string[] files = Directory.GetFiles(sourceDirectory, "*", searchOption);
|
||||
foreach (string file in files)
|
||||
{
|
||||
|
@ -11,8 +11,8 @@ internal static class HelperILMerge
|
||||
bool result;
|
||||
ProcessStartInfo processStartInfo;
|
||||
StringBuilder stringBuilder = new();
|
||||
string[] successChecks = new string[] { "success" };
|
||||
string[] errorChecks = new string[] { "Error", "Conflict", "error:" };
|
||||
string[] successChecks = ["success"];
|
||||
string[] errorChecks = ["Error", "Conflict", "error:"];
|
||||
FileInfo ilMerge = new("C:/Users/phares/AppData/Local/IFXApps/ILMerge/ILMerge.exe");
|
||||
string[] dllFiles = Directory.GetFiles(workingDirectory, "*.dll", SearchOption.TopDirectoryOnly);
|
||||
string errorFile = Path.Combine(workingDirectory, string.Concat(Path.GetFileName(workingDirectory), ".err"));
|
||||
|
@ -66,7 +66,7 @@ internal static partial class HelperKanbanMetadata
|
||||
|
||||
private static List<(int, int, string, FileInfo)> GetCollectionFromIndex(string sourceDirectory, string[] lines)
|
||||
{
|
||||
List<(int, int, string, FileInfo)> results = new();
|
||||
List<(int, int, string, FileInfo)> results = [];
|
||||
string line;
|
||||
FileInfo fileInfo;
|
||||
string[] segments;
|
||||
|
@ -13,14 +13,14 @@ internal static class HelperLogMerge
|
||||
FileInfo fileInfo;
|
||||
string[] segments;
|
||||
string checkDirectory;
|
||||
List<string> lines = [];
|
||||
string format = "yyyyMMdd";
|
||||
List<string> moveFiles = [];
|
||||
string segment1 = string.Empty;
|
||||
string sourceFileNameWithoutExtension;
|
||||
List<string> lines = new();
|
||||
List<string> moveFiles = new();
|
||||
DateTime dateTime = DateTime.Now.AddMinutes(2);
|
||||
string[] sourceFiles = Directory.GetFiles(argsZero, "*.log", SearchOption.TopDirectoryOnly);
|
||||
Dictionary<string, Dictionary<int, string[]>> keyValuePairs = new();
|
||||
Dictionary<string, Dictionary<int, string[]>> keyValuePairs = [];
|
||||
foreach (string sourceFile in sourceFiles)
|
||||
{
|
||||
sourceFileNameWithoutExtension = Path.GetFileNameWithoutExtension(sourceFile);
|
||||
@ -33,7 +33,7 @@ internal static class HelperLogMerge
|
||||
moveFiles.Add(sourceFile);
|
||||
day = sourceFileNameWithoutExtension[..8];
|
||||
if (!keyValuePairs.ContainsKey(day))
|
||||
keyValuePairs.Add(day, new Dictionary<int, string[]>());
|
||||
keyValuePairs.Add(day, []);
|
||||
if (sourceFileNameWithoutExtension.Substring(8, 1) == "_")
|
||||
continue;
|
||||
segments = sourceFileNameWithoutExtension.Split('_');
|
||||
|
@ -71,7 +71,7 @@ internal static partial class HelperMarkdown
|
||||
|
||||
private static List<string> GetFrontMatterLines(string[] parsedLines)
|
||||
{
|
||||
List<string> results = new();
|
||||
List<string> results = [];
|
||||
string afterTrim;
|
||||
string[] segments;
|
||||
StringBuilder stringBuilder = new();
|
||||
@ -153,8 +153,8 @@ internal static partial class HelperMarkdown
|
||||
|
||||
private static List<MarkdownFileAndLines> GetMarkdownFileAndLines(string file, List<MarkdownFileAndLines> markdownFiles)
|
||||
{
|
||||
List<MarkdownFileAndLines> results = new();
|
||||
List<string> distinct = new();
|
||||
List<MarkdownFileAndLines> results = [];
|
||||
List<string> distinct = [];
|
||||
string? directory = Path.GetDirectoryName(file);
|
||||
foreach (MarkdownFileAndLines markdownFileAndLines in markdownFiles)
|
||||
{
|
||||
@ -259,12 +259,12 @@ internal static partial class HelperMarkdown
|
||||
int notCompleted;
|
||||
List<string> lines;
|
||||
string? effort = null;
|
||||
List<string> assignees = new();
|
||||
List<string> assignees = [];
|
||||
string? requestedDateTime = null;
|
||||
ReadOnlyCollection<Group> groups;
|
||||
List<H2HexColor> h2HexColors = new();
|
||||
List<H2NoCheckboxes> h2NoCheckboxes = new();
|
||||
List<H2WithCheckboxes> h2WithCheckboxes = new();
|
||||
List<H2HexColor> h2HexColors = [];
|
||||
List<H2NoCheckboxes> h2NoCheckboxes = [];
|
||||
List<H2WithCheckboxes> h2WithCheckboxes = [];
|
||||
if (markdownFileAndLines.MarkdownFile.LineNumber.FrontMatterYamlEnd is not null)
|
||||
{
|
||||
for (int i = 1; i < markdownFileAndLines.Lines.Length; i++)
|
||||
@ -300,7 +300,7 @@ internal static partial class HelperMarkdown
|
||||
h2HexColors.Add(new(line[skip..], $"#{groups.First(l => l.Value.Length == 6)}"));
|
||||
continue;
|
||||
}
|
||||
lines = new();
|
||||
lines = [];
|
||||
if (i + 1 == markdownFileAndLines.Lines.Length)
|
||||
continue;
|
||||
for (int j = i + 1; j < markdownFileAndLines.Lines.Length; j++)
|
||||
@ -335,10 +335,10 @@ internal static partial class HelperMarkdown
|
||||
|
||||
private static List<MarkdownFileAndLines> Distinct(IEnumerable<MarkdownFileAndLines>? markdownFileAndLinesCollection)
|
||||
{
|
||||
List<MarkdownFileAndLines> results = new();
|
||||
List<MarkdownFileAndLines> results = [];
|
||||
if (markdownFileAndLinesCollection is not null)
|
||||
{
|
||||
List<string> distinct = new();
|
||||
List<string> distinct = [];
|
||||
foreach (MarkdownFileAndLines markdownFileAndLines in markdownFileAndLinesCollection)
|
||||
{
|
||||
if (distinct.Contains(markdownFileAndLines.MarkdownFile.File))
|
||||
@ -352,7 +352,7 @@ internal static partial class HelperMarkdown
|
||||
|
||||
private static List<MarkdownFileAndLines> GetMarkdownFileAndLines(ReadOnlyDictionary<string, List<MarkdownFileAndLines>> keyValuePairs)
|
||||
{
|
||||
List<MarkdownFileAndLines> results = new();
|
||||
List<MarkdownFileAndLines> results = [];
|
||||
foreach (KeyValuePair<string, List<MarkdownFileAndLines>> keyValuePair in keyValuePairs)
|
||||
{
|
||||
foreach (MarkdownFileAndLines markdownFileAndLines in keyValuePair.Value)
|
||||
@ -370,7 +370,7 @@ internal static partial class HelperMarkdown
|
||||
string[] segmentsB;
|
||||
string segmentsLast;
|
||||
string segmentsFirst;
|
||||
List<string> jsonLines = new();
|
||||
List<string> jsonLines = [];
|
||||
for (int i = 0; i < frontMatterYamlEnd; i++)
|
||||
{
|
||||
if (lines[i] == "---")
|
||||
@ -430,13 +430,13 @@ internal static partial class HelperMarkdown
|
||||
if (jsonLines.Count > 0)
|
||||
(result, keyValuePairs, results) = Get(jsonLines);
|
||||
else
|
||||
(result, keyValuePairs, results) = (null, null, new());
|
||||
(result, keyValuePairs, results) = (null, null, []);
|
||||
return (result, keyValuePairs, results.ToArray());
|
||||
}
|
||||
|
||||
private static ReadOnlyDictionary<string, List<MarkdownFileAndLines>> GetKeyValuePairs(ReadOnlyDictionary<string, MarkdownFileAndLines> relativeToCollection)
|
||||
{
|
||||
Dictionary<string, List<MarkdownFileAndLines>> results = new();
|
||||
Dictionary<string, List<MarkdownFileAndLines>> results = [];
|
||||
MarkdownFile markdownFile;
|
||||
string fileNameWithoutExtension;
|
||||
string fileNameWithoutExtensionB;
|
||||
@ -446,7 +446,7 @@ internal static partial class HelperMarkdown
|
||||
markdownFile = relativeTo.Value.MarkdownFile;
|
||||
if (!results.TryGetValue(relativeTo.Key, out markdownFiles))
|
||||
{
|
||||
results.Add(relativeTo.Key, new());
|
||||
results.Add(relativeTo.Key, []);
|
||||
if (!results.TryGetValue(relativeTo.Key, out markdownFiles))
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
@ -459,7 +459,7 @@ internal static partial class HelperMarkdown
|
||||
fileNameWithoutExtensionB = fileNameWithoutExtension.Replace("%20", "-").Replace(' ', '-');
|
||||
if (!results.TryGetValue(markdownFile.FileNameWithoutExtension, out markdownFiles))
|
||||
{
|
||||
results.Add(markdownFile.FileNameWithoutExtension, new());
|
||||
results.Add(markdownFile.FileNameWithoutExtension, []);
|
||||
if (!results.TryGetValue(markdownFile.FileNameWithoutExtension, out markdownFiles))
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
@ -468,7 +468,7 @@ internal static partial class HelperMarkdown
|
||||
continue;
|
||||
if (!results.TryGetValue(fileNameWithoutExtension, out markdownFiles))
|
||||
{
|
||||
results.Add(fileNameWithoutExtension, new());
|
||||
results.Add(fileNameWithoutExtension, []);
|
||||
if (!results.TryGetValue(fileNameWithoutExtension, out markdownFiles))
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
@ -476,7 +476,7 @@ internal static partial class HelperMarkdown
|
||||
continue;
|
||||
if (!results.TryGetValue(fileNameWithoutExtensionB, out markdownFiles))
|
||||
{
|
||||
results.Add(fileNameWithoutExtensionB, new());
|
||||
results.Add(fileNameWithoutExtensionB, []);
|
||||
if (!results.TryGetValue(fileNameWithoutExtensionB, out markdownFiles))
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
@ -487,7 +487,7 @@ internal static partial class HelperMarkdown
|
||||
markdownFile = relativeTo.Value.MarkdownFile;
|
||||
if (!results.TryGetValue(markdownFile.H1, out markdownFiles))
|
||||
{
|
||||
results.Add(markdownFile.H1, new());
|
||||
results.Add(markdownFile.H1, []);
|
||||
if (!results.TryGetValue(markdownFile.H1, out markdownFiles))
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
@ -548,7 +548,7 @@ internal static partial class HelperMarkdown
|
||||
|
||||
private static ReadOnlyDictionary<string, MarkdownFileAndLines> GetRelativeToCollection(AppSettings appSettings, Input input, string[] files, bool force)
|
||||
{
|
||||
Dictionary<string, MarkdownFileAndLines> results = new();
|
||||
Dictionary<string, MarkdownFileAndLines> results = [];
|
||||
string h1;
|
||||
string key;
|
||||
string type;
|
||||
@ -571,7 +571,7 @@ internal static partial class HelperMarkdown
|
||||
else
|
||||
{
|
||||
type = appSettings.DefaultNoteType;
|
||||
File.WriteAllLines(file, new string[] { "---", $"type: \"{type}\"", "---", string.Empty, $"# {h1}" });
|
||||
File.WriteAllLines(file, ["---", $"type: \"{type}\"", "---", string.Empty, $"# {h1}"]);
|
||||
lines = File.ReadAllLines(file).ToList();
|
||||
}
|
||||
markdownFile = new(fileInfo.CreationTime,
|
||||
@ -587,23 +587,23 @@ internal static partial class HelperMarkdown
|
||||
if (force || input.StartAt is null || file.StartsWith(input.StartAt))
|
||||
results.Add(key, new(markdownFile, lines.ToArray()));
|
||||
else
|
||||
results.Add(key, new(markdownFile, Array.Empty<string>()));
|
||||
results.Add(key, new(markdownFile, []));
|
||||
}
|
||||
return new(results);
|
||||
}
|
||||
|
||||
private static ReadOnlyDictionary<string, List<Card>> GetColumnsToCards(Input input, ReadOnlyDictionary<string, MarkdownFileAndLines> relativeToCollection)
|
||||
{
|
||||
Dictionary<string, List<Card>> results = new();
|
||||
Dictionary<string, List<Card>> results = [];
|
||||
Card card;
|
||||
string key;
|
||||
string[] lines;
|
||||
string[] segmentsA;
|
||||
string? column = null;
|
||||
List<Card> cards = new();
|
||||
List<Card> cards = [];
|
||||
List<string> allKeys = [];
|
||||
MarkdownFile markdownFile;
|
||||
MarkdownExtra markdownExtra;
|
||||
List<string> allKeys = new();
|
||||
MarkdownFileAndLines? markdownFileAndLines;
|
||||
foreach (KeyValuePair<string, MarkdownFileAndLines> relativeTo in relativeToCollection)
|
||||
allKeys.Add(relativeTo.Key);
|
||||
@ -626,7 +626,7 @@ internal static partial class HelperMarkdown
|
||||
if (column is null)
|
||||
throw new NullReferenceException(nameof(column));
|
||||
results.Add(column, cards);
|
||||
cards = new();
|
||||
cards = [];
|
||||
}
|
||||
column = lines[i][3..].TrimEnd();
|
||||
if (lines.Length == i + 1)
|
||||
@ -695,7 +695,7 @@ internal static partial class HelperMarkdown
|
||||
{
|
||||
column = "Not Linked";
|
||||
results.Add(column, cards);
|
||||
cards = new();
|
||||
cards = [];
|
||||
}
|
||||
}
|
||||
return new(results);
|
||||
@ -714,7 +714,7 @@ internal static partial class HelperMarkdown
|
||||
else
|
||||
{
|
||||
List<MarkdownFileAndLines> matches;
|
||||
matches = markdownFileAndLinesCollection is null ? new() : GetMarkdownFileAndLines(file, markdownFileAndLinesCollection);
|
||||
matches = markdownFileAndLinesCollection is null ? [] : GetMarkdownFileAndLines(file, markdownFileAndLinesCollection);
|
||||
if (matches.Count == 1)
|
||||
result = matches[0];
|
||||
else
|
||||
@ -793,7 +793,7 @@ internal static partial class HelperMarkdown
|
||||
private static int ConvertFrontMatterToJsonFriendly(ReadOnlyDictionary<string, MarkdownFileAndLines> relativeToCollection)
|
||||
{
|
||||
int result = 0;
|
||||
List<string> results = new();
|
||||
List<string> results = [];
|
||||
bool write;
|
||||
string[] lines;
|
||||
MarkdownFile markdownFile;
|
||||
@ -1101,7 +1101,7 @@ internal static partial class HelperMarkdown
|
||||
|
||||
private static List<MarkdownFileAndLines> GetRecursiveLines(AppSettings appSettings, Input input, ILogger<Worker> logger, ReadOnlyDictionary<string, MarkdownFileAndLines> relativeToCollection)
|
||||
{
|
||||
List<MarkdownFileAndLines> results = new();
|
||||
List<MarkdownFileAndLines> results = [];
|
||||
string[] lines;
|
||||
List<char> indentations;
|
||||
MarkdownFile markdownFile;
|
||||
@ -1113,8 +1113,8 @@ internal static partial class HelperMarkdown
|
||||
continue;
|
||||
if (input.StartAt is null || !relativeTo.Value.MarkdownFile.File.StartsWith(input.StartAt) || Path.GetFileName(relativeTo.Value.MarkdownFile.Directory) != Path.GetFileName(input.StartAt))
|
||||
continue;
|
||||
indentations = new();
|
||||
recursiveLines = new();
|
||||
indentations = [];
|
||||
recursiveLines = [];
|
||||
lines = relativeTo.Value.Lines;
|
||||
markdownFile = relativeTo.Value.MarkdownFile;
|
||||
SetRecursiveLines(appSettings, logger, keyValuePairs, markdownFile.FileNameWithoutExtension, markdownFile, lines, indentations, recursiveLines);
|
||||
@ -1153,7 +1153,7 @@ internal static partial class HelperMarkdown
|
||||
|
||||
private static List<Record> GetWithLinksForHugo(AppSettings appSettings, Input input)
|
||||
{
|
||||
List<Record> results = new();
|
||||
List<Record> results = [];
|
||||
string file;
|
||||
string line;
|
||||
string[] lines;
|
||||
@ -1212,7 +1212,7 @@ internal static partial class HelperMarkdown
|
||||
|
||||
private static List<string> GetDistinct(List<Record> collection)
|
||||
{
|
||||
List<string> results = new();
|
||||
List<string> results = [];
|
||||
foreach (Record record in collection)
|
||||
{
|
||||
if (results.Contains(record.Directory))
|
||||
@ -1278,7 +1278,7 @@ internal static partial class HelperMarkdown
|
||||
private static int SetFrontMatterAndH1(AppSettings appSettings, ReadOnlyDictionary<string, MarkdownFileAndLines> relativeToCollection)
|
||||
{
|
||||
int result = 0;
|
||||
List<string> results = new();
|
||||
List<string> results = [];
|
||||
string h1Line;
|
||||
string[] lines;
|
||||
string typeLine;
|
||||
|
@ -17,9 +17,9 @@ internal static class HelperPackageFilesByDate
|
||||
PackageJson? packageJson;
|
||||
string[] packageJsonFiles;
|
||||
string? packageJsonDirectory;
|
||||
List<DateTime> dateTimes = [];
|
||||
string fileNameWithoutExtension;
|
||||
string packageJsonDirectoryName;
|
||||
List<DateTime> dateTimes = new();
|
||||
if (log is null)
|
||||
throw new NullReferenceException();
|
||||
if (!Directory.Exists(sourceDirectory))
|
||||
|
@ -113,7 +113,7 @@ internal static class HelperPdfStripperWrapper
|
||||
string[] lines;
|
||||
string fileName;
|
||||
string[] segments;
|
||||
List<string> collection = new();
|
||||
List<string> collection = [];
|
||||
foreach (string file in files)
|
||||
{
|
||||
lines = File.ReadAllLines(file);
|
||||
|
@ -14,7 +14,7 @@ internal static class HelperRenameToOldMoveDeleteOldMerge
|
||||
{
|
||||
string renameFile;
|
||||
string destinationFile;
|
||||
List<string> deleteFiles = new();
|
||||
List<string> deleteFiles = [];
|
||||
string[] moveFiles = Directory.GetFiles(argsZero, "*", SearchOption.TopDirectoryOnly);
|
||||
log.LogInformation("<{moveFiles.Length}> to move", moveFiles.Length);
|
||||
foreach (string moveFile in moveFiles)
|
||||
|
@ -48,7 +48,7 @@ internal static class HelperStart
|
||||
if (!result)
|
||||
result = standardOutput == string.Empty && standardError == string.Empty;
|
||||
if (!result)
|
||||
File.WriteAllLines(errorFile, new string[] { standardOutput, Environment.NewLine, Environment.NewLine, standardError });
|
||||
File.WriteAllLines(errorFile, [standardOutput, Environment.NewLine, Environment.NewLine, standardError]);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -122,7 +122,7 @@ internal static partial class HelperVSCodePossibleExtension
|
||||
|
||||
private static ReadOnlyCollection<int> GetMethodLines(ReadOnlyCollection<Method> methods)
|
||||
{
|
||||
List<int> results = new();
|
||||
List<int> results = [];
|
||||
foreach (Method method in methods)
|
||||
{
|
||||
for (int i = method.StartLine; i < method.EndLine + 1; i++)
|
||||
@ -133,7 +133,7 @@ internal static partial class HelperVSCodePossibleExtension
|
||||
|
||||
private static ReadOnlyCollection<Method> GetMethods(string cSharpFile, ILogger<Worker> logger, string[] lines)
|
||||
{
|
||||
List<Method> results = new();
|
||||
List<Method> results = [];
|
||||
int blocks;
|
||||
bool isLinq;
|
||||
int endLine;
|
||||
@ -210,7 +210,7 @@ internal static partial class HelperVSCodePossibleExtension
|
||||
private static bool WriteAllLines(string cSharpFile, string[] lines, ReadOnlyCollection<Method> methods)
|
||||
{
|
||||
bool result;
|
||||
List<string> results = new();
|
||||
List<string> results = [];
|
||||
ReadOnlyCollection<int> methodLines = GetMethodLines(methods);
|
||||
int minMethodLines = methodLines.Min();
|
||||
for (int i = 0; i < minMethodLines; i++)
|
||||
|
@ -11,29 +11,50 @@ internal static partial class HelperZipFilesBy
|
||||
[GeneratedRegex("[a-zA-Z0-9]{1,}")]
|
||||
private static partial Regex LowerAlphaAlphaAndNumber();
|
||||
|
||||
private static bool SetDateFromZipEntry(ILogger<Worker> logger, string[] zipFiles, string keyFile, string keyFileB, string keyFileC)
|
||||
private static DateTimeOffset? GetDateTimeOffset(string keyFileExtension, FileInfo fileInfo, FileInfo extractKeyFileInfo)
|
||||
{
|
||||
DateTimeOffset? dateTimeOffset = null;
|
||||
using ZipArchive zip = ZipFile.Open(fileInfo.FullName, ZipArchiveMode.Read);
|
||||
foreach (ZipArchiveEntry zipArchiveEntry in zip.Entries)
|
||||
{
|
||||
if (!zipArchiveEntry.Name.EndsWith(keyFileExtension))
|
||||
continue;
|
||||
dateTimeOffset = zipArchiveEntry.LastWriteTime;
|
||||
if (fileInfo.FullName[0] != '\\')
|
||||
{
|
||||
zipArchiveEntry.ExtractToFile(extractKeyFileInfo.FullName);
|
||||
File.SetCreationTime(extractKeyFileInfo.FullName, fileInfo.CreationTime);
|
||||
File.SetLastWriteTime(extractKeyFileInfo.FullName, dateTimeOffset.Value.LocalDateTime);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return dateTimeOffset;
|
||||
}
|
||||
|
||||
private static bool ExtractKeyFileAndSetDateFromZipEntry(ILogger<Worker> logger, string[] zipFiles, string keyFileExtension, string keyFileExtensionB, string keyFileExtensionC)
|
||||
{
|
||||
bool result = false;
|
||||
string[] files;
|
||||
string checkFile;
|
||||
FileInfo fileInfo;
|
||||
string? zipDirectory;
|
||||
FileInfo extractKeyFileInfo;
|
||||
DateTimeOffset? dateTimeOffset;
|
||||
foreach (string zipFile in zipFiles)
|
||||
{
|
||||
fileInfo = new(zipFile);
|
||||
if (fileInfo.DirectoryName is null)
|
||||
throw new NullReferenceException(nameof(fileInfo.DirectoryName));
|
||||
extractKeyFileInfo = new(Path.Combine(fileInfo.DirectoryName, $"{Path.GetFileNameWithoutExtension(fileInfo.Name)}{keyFileExtension}"));
|
||||
if (extractKeyFileInfo.Exists)
|
||||
{
|
||||
if (extractKeyFileInfo.CreationTime.ToString("yyyy-MM-dd") == fileInfo.CreationTime.ToString("yyyy-MM-dd") && extractKeyFileInfo.LastWriteTime.ToString("yyyy-MM-dd") == fileInfo.LastWriteTime.ToString("yyyy-MM-dd"))
|
||||
continue;
|
||||
File.Delete(extractKeyFileInfo.FullName);
|
||||
}
|
||||
try
|
||||
{
|
||||
dateTimeOffset = null;
|
||||
fileInfo = new(zipFile);
|
||||
using ZipArchive zip = ZipFile.Open(zipFile, ZipArchiveMode.Read);
|
||||
foreach (ZipArchiveEntry zipArchiveEntry in zip.Entries)
|
||||
{
|
||||
if (!zipArchiveEntry.Name.EndsWith(keyFile))
|
||||
continue;
|
||||
dateTimeOffset = zipArchiveEntry.LastWriteTime;
|
||||
break;
|
||||
}
|
||||
zipDirectory = Path.GetDirectoryName(zipFile);
|
||||
if (dateTimeOffset is null || zipDirectory is null)
|
||||
dateTimeOffset = GetDateTimeOffset(keyFileExtension, fileInfo, extractKeyFileInfo);
|
||||
if (dateTimeOffset is null)
|
||||
continue;
|
||||
if (fileInfo.LastWriteTime != dateTimeOffset.Value.LocalDateTime)
|
||||
{
|
||||
@ -41,7 +62,9 @@ internal static partial class HelperZipFilesBy
|
||||
if (!result)
|
||||
result = true;
|
||||
}
|
||||
files = Directory.GetFiles(zipDirectory, $"*{keyFile}", SearchOption.TopDirectoryOnly);
|
||||
if (string.IsNullOrEmpty(keyFileExtensionB))
|
||||
continue;
|
||||
files = Directory.GetFiles(fileInfo.DirectoryName, keyFileExtensionB, SearchOption.TopDirectoryOnly);
|
||||
foreach (string file in files)
|
||||
{
|
||||
fileInfo = new(file);
|
||||
@ -52,22 +75,11 @@ internal static partial class HelperZipFilesBy
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
if (string.IsNullOrEmpty(keyFileB))
|
||||
if (string.IsNullOrEmpty(keyFileExtensionC))
|
||||
continue;
|
||||
files = Directory.GetFiles(zipDirectory, keyFileB, SearchOption.TopDirectoryOnly);
|
||||
foreach (string file in files)
|
||||
{
|
||||
fileInfo = new(file);
|
||||
if (fileInfo.LastWriteTime != dateTimeOffset.Value.LocalDateTime)
|
||||
{
|
||||
File.SetLastWriteTime(fileInfo.FullName, dateTimeOffset.Value.LocalDateTime);
|
||||
if (!result)
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
if (string.IsNullOrEmpty(keyFileC))
|
||||
continue;
|
||||
files = Directory.GetFiles(zipDirectory, keyFileC, SearchOption.TopDirectoryOnly);
|
||||
if (fileInfo.DirectoryName is null)
|
||||
throw new NullReferenceException(nameof(fileInfo.DirectoryName));
|
||||
files = Directory.GetFiles(fileInfo.DirectoryName, keyFileExtensionC, SearchOption.TopDirectoryOnly);
|
||||
foreach (string file in files)
|
||||
{
|
||||
fileInfo = new(file);
|
||||
@ -93,6 +105,7 @@ internal static partial class HelperZipFilesBy
|
||||
{ File.Move(zipFile, checkFile); }
|
||||
catch (Exception) { logger.LogInformation("<{zipFile}> couldn't be moved!", zipFile); }
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -115,9 +128,9 @@ internal static partial class HelperZipFilesBy
|
||||
DateTime dateTime = DateTime.MinValue;
|
||||
DateTime firstEmail = new(2019, 3, 8);
|
||||
CultureInfo cultureInfo = new("en-US");
|
||||
Dictionary<string, DateTime> weeks = [];
|
||||
Calendar calendar = cultureInfo.Calendar;
|
||||
Regex regex = LowerAlphaAlphaAndNumber();
|
||||
Dictionary<string, DateTime> weeks = new();
|
||||
int ticksLength = nowDateTime.AddDays(-6).Ticks.ToString().Length;
|
||||
for (int i = 0; i < int.MaxValue; i++)
|
||||
{
|
||||
@ -131,10 +144,10 @@ internal static partial class HelperZipFilesBy
|
||||
}
|
||||
weekOfYear = calendar.GetWeekOfYear(nowDateTime, CalendarWeekRule.FirstDay, DayOfWeek.Sunday).ToString("00");
|
||||
string skipKey = string.Concat(nowDateTime.ToString("yyyy"), "_Week_", weekOfYear);
|
||||
Dictionary<string, List<string>> keyValuePairs = new();
|
||||
Dictionary<string, List<string>> keyValuePairs = [];
|
||||
string[] topDirectories = Directory.GetDirectories(sourceDirectory, "*", SearchOption.TopDirectoryOnly);
|
||||
if (topDirectories.Length == 0)
|
||||
topDirectories = new string[] { sourceDirectory };
|
||||
topDirectories = [sourceDirectory];
|
||||
foreach (string topDirectory in topDirectories)
|
||||
{
|
||||
keyValuePairs.Clear();
|
||||
@ -187,7 +200,7 @@ internal static partial class HelperZipFilesBy
|
||||
if (key == skipKey)
|
||||
continue;
|
||||
if (!keyValuePairs.ContainsKey(key))
|
||||
keyValuePairs.Add(key, new List<string>());
|
||||
keyValuePairs.Add(key, []);
|
||||
keyValuePairs[key].Add(subFile);
|
||||
}
|
||||
}
|
||||
@ -237,30 +250,30 @@ internal static partial class HelperZipFilesBy
|
||||
return result;
|
||||
}
|
||||
|
||||
internal static bool SetDateFromZipEntryForNuspec(ILogger<Worker> logger, string[] files) =>
|
||||
SetDateFromZipEntry(logger, files, ".nuspec", "icon", "readme");
|
||||
internal static bool ExportNuspecAndSetDateFromZipEntry(ILogger<Worker> logger, string[] files) =>
|
||||
ExtractKeyFileAndSetDateFromZipEntry(logger, files, ".nuspec", "icon", "readme");
|
||||
|
||||
internal static bool SetDateFromZipEntry(ILogger<Worker> logger, string sourceDirectory, SearchOption searchOption = SearchOption.AllDirectories)
|
||||
internal static bool ExtractKeyFileAndSetDateFromZipEntry(ILogger<Worker> logger, string sourceDirectory, SearchOption searchOption = SearchOption.AllDirectories)
|
||||
{
|
||||
bool result = false;
|
||||
bool loop;
|
||||
string keyFile;
|
||||
string keyFileB;
|
||||
string keyFileC;
|
||||
string[] zipFiles;
|
||||
string searchPattern;
|
||||
string keyFileExtension;
|
||||
string keyFileExtensionB;
|
||||
string keyFileExtensionC;
|
||||
if (!Directory.Exists(sourceDirectory))
|
||||
_ = Directory.CreateDirectory(sourceDirectory);
|
||||
for (int i = 1; i < 3; i++)
|
||||
{
|
||||
(searchPattern, keyFile, keyFileB, keyFileC) = i switch
|
||||
(searchPattern, keyFileExtension, keyFileExtensionB, keyFileExtensionC) = i switch
|
||||
{
|
||||
1 => ("*.nupkg", ".nuspec", "icon", "readme"),
|
||||
2 => ("*.vsix", ".vsixmanifest", string.Empty, string.Empty),
|
||||
_ => throw new NotSupportedException()
|
||||
};
|
||||
zipFiles = Directory.GetFiles(sourceDirectory, searchPattern, searchOption);
|
||||
loop = SetDateFromZipEntry(logger, zipFiles, keyFile, keyFileB, keyFileC);
|
||||
loop = ExtractKeyFileAndSetDateFromZipEntry(logger, zipFiles, keyFileExtension, keyFileExtensionB, keyFileExtensionC);
|
||||
if (loop && !result)
|
||||
result = true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user