Remove .Any
H2 Records
This commit is contained in:
2
Models/Binder/.editorconfig
Normal file
2
Models/Binder/.editorconfig
Normal file
@ -0,0 +1,2 @@
|
||||
[*.cs]
|
||||
csharp_preserve_single_line_statements = true
|
@ -25,22 +25,14 @@ public class AppSettings
|
||||
private static Models.AppSettings Get(AppSettings? appSettings)
|
||||
{
|
||||
Models.AppSettings result;
|
||||
if (appSettings?.Company is null)
|
||||
throw new NullReferenceException(nameof(appSettings.Company));
|
||||
if (appSettings?.DefaultNoteType is null)
|
||||
throw new NullReferenceException(nameof(appSettings.DefaultNoteType));
|
||||
if (appSettings?.ExcludeDirectoryNames is null)
|
||||
throw new NullReferenceException(nameof(appSettings.ExcludeDirectoryNames));
|
||||
if (appSettings?.ExcludeSchemes is null)
|
||||
throw new NullReferenceException(nameof(appSettings.ExcludeSchemes));
|
||||
if (appSettings?.PersonBirthdayFormat is null)
|
||||
throw new NullReferenceException(nameof(appSettings.PersonBirthdayFormat));
|
||||
if (appSettings?.PersonCharacters is null)
|
||||
throw new NullReferenceException(nameof(appSettings.PersonCharacters));
|
||||
if (appSettings?.PersonTitleFilters is null)
|
||||
throw new NullReferenceException(nameof(appSettings.PersonTitleFilters));
|
||||
if (appSettings?.WorkingDirectoryName is null)
|
||||
throw new NullReferenceException(nameof(appSettings.WorkingDirectoryName));
|
||||
if (appSettings?.Company is null) throw new NullReferenceException(nameof(appSettings.Company));
|
||||
if (appSettings?.DefaultNoteType is null) throw new NullReferenceException(nameof(appSettings.DefaultNoteType));
|
||||
if (appSettings?.ExcludeDirectoryNames is null) throw new NullReferenceException(nameof(appSettings.ExcludeDirectoryNames));
|
||||
if (appSettings?.ExcludeSchemes is null) throw new NullReferenceException(nameof(appSettings.ExcludeSchemes));
|
||||
if (appSettings?.PersonBirthdayFormat is null) throw new NullReferenceException(nameof(appSettings.PersonBirthdayFormat));
|
||||
if (appSettings?.PersonCharacters is null) throw new NullReferenceException(nameof(appSettings.PersonCharacters));
|
||||
if (appSettings?.PersonTitleFilters is null) throw new NullReferenceException(nameof(appSettings.PersonTitleFilters));
|
||||
if (appSettings?.WorkingDirectoryName is null) throw new NullReferenceException(nameof(appSettings.WorkingDirectoryName));
|
||||
result = new(
|
||||
appSettings.Company,
|
||||
appSettings.DefaultNoteType,
|
||||
@ -60,6 +52,19 @@ public class AppSettings
|
||||
#pragma warning disable IL3050, IL2026
|
||||
AppSettings? appSettings = configurationRoot.Get<AppSettings>();
|
||||
#pragma warning restore IL3050, IL2026
|
||||
if (appSettings?.Company is null)
|
||||
{
|
||||
foreach (IConfigurationProvider configurationProvider in configurationRoot.Providers)
|
||||
{
|
||||
if (configurationProvider is not Microsoft.Extensions.Configuration.Json.JsonConfigurationProvider jsonConfigurationProvider)
|
||||
continue;
|
||||
if (jsonConfigurationProvider.Source.FileProvider is not Microsoft.Extensions.FileProviders.PhysicalFileProvider physicalFileProvider)
|
||||
continue;
|
||||
if (!physicalFileProvider.Root.Contains("UserSecrets"))
|
||||
continue;
|
||||
throw new NotSupportedException(physicalFileProvider.Root);
|
||||
}
|
||||
}
|
||||
result = Get(appSettings);
|
||||
return result;
|
||||
}
|
||||
|
12
Models/H2HexColor.cs
Normal file
12
Models/H2HexColor.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace File_Folder_Helper.Models;
|
||||
|
||||
internal record H2HexColor(string H2,
|
||||
string HexColor);
|
||||
|
||||
[JsonSourceGenerationOptions(WriteIndented = true, DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
[JsonSerializable(typeof(H2HexColor))]
|
||||
internal partial class H2PatternMatchesSourceGenerationContext : JsonSerializerContext
|
||||
{
|
||||
}
|
13
Models/H2NoCheckboxes.cs
Normal file
13
Models/H2NoCheckboxes.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace File_Folder_Helper.Models;
|
||||
|
||||
internal record H2NoCheckboxes(string H2,
|
||||
ReadOnlyCollection<string> Lines);
|
||||
|
||||
[JsonSourceGenerationOptions(WriteIndented = true, DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
[JsonSerializable(typeof(H2NoCheckboxes))]
|
||||
internal partial class H2NoCheckboxesSourceGenerationContext : JsonSerializerContext
|
||||
{
|
||||
}
|
14
Models/H2WithCheckboxes.cs
Normal file
14
Models/H2WithCheckboxes.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace File_Folder_Helper.Models;
|
||||
|
||||
internal record H2WithCheckboxes(int Completed,
|
||||
string H2,
|
||||
int NotCompleted,
|
||||
int Total);
|
||||
|
||||
[JsonSourceGenerationOptions(WriteIndented = true, DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
[JsonSerializable(typeof(H2WithCheckboxes))]
|
||||
internal partial class H2WithCheckboxesSourceGenerationContext : JsonSerializerContext
|
||||
{
|
||||
}
|
@ -2,12 +2,12 @@ using System.Text.Json.Serialization;
|
||||
|
||||
namespace File_Folder_Helper.Models;
|
||||
|
||||
public record LineNumber(int? Created,
|
||||
int? H1,
|
||||
int? FrontMatterYamlEnd,
|
||||
int? Status,
|
||||
int? Type,
|
||||
int? Updated);
|
||||
internal record LineNumber(int? Created,
|
||||
int? H1,
|
||||
int? FrontMatterYamlEnd,
|
||||
int? Status,
|
||||
int? Type,
|
||||
int? Updated);
|
||||
|
||||
[JsonSourceGenerationOptions(WriteIndented = true)]
|
||||
[JsonSerializable(typeof(LineNumber))]
|
||||
|
@ -1,17 +1,23 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace File_Folder_Helper.Models;
|
||||
|
||||
public record MarkdownFile(string File,
|
||||
string Directory,
|
||||
string FileName,
|
||||
string FileNameWithoutExtension,
|
||||
string Extension,
|
||||
DateTime CreationDateTime,
|
||||
DateTime LastWriteDateTime,
|
||||
LineNumber LineNumber,
|
||||
string Type,
|
||||
string H1);
|
||||
internal record MarkdownFile(ReadOnlyCollection<string>? Assignees,
|
||||
DateTime CreationDateTime,
|
||||
string Directory,
|
||||
string Extension,
|
||||
string File,
|
||||
string FileName,
|
||||
string FileNameWithoutExtension,
|
||||
string H1,
|
||||
ReadOnlyCollection<H2HexColor>? H2HexColorCollection,
|
||||
ReadOnlyCollection<H2NoCheckboxes>? H2NoCheckboxesCollection,
|
||||
ReadOnlyCollection<H2WithCheckboxes>? H2WithCheckboxesCollection,
|
||||
DateTime LastWriteDateTime,
|
||||
LineNumber LineNumber,
|
||||
string? RequestedDateTime,
|
||||
string Type);
|
||||
|
||||
[JsonSourceGenerationOptions(WriteIndented = true)]
|
||||
[JsonSerializable(typeof(MarkdownFile))]
|
||||
|
Reference in New Issue
Block a user