From 18264b4b2b4d20d1301f2b6d35bbe396be003aba Mon Sep 17 00:00:00 2001 From: "Dylan R. E. Moonfire" Date: Mon, 6 Jun 2022 09:32:22 -0500 Subject: [PATCH] fix: correcting some patterns and inheritances --- Nitride.sln.DotSettings | 1 + .../WithPropertySourceGenerator.cs | 6 ++- src/Nitride.IO/README.md | 6 +-- .../ConvertMarkdownToGemtext.cs | 9 ++++ src/Nitride.Markdown/ConvertMarkdownToHtml.cs | 9 ++++ src/Nitride.Markdown/IdentifyMarkdown.cs | 15 +------ .../IdentifyMarkdownFromPath.cs | 26 +++++++++++ src/Nitride/Entities/README.md | 44 +++++++++---------- src/Nitride/ROADMAP.md | 10 ++--- 9 files changed, 82 insertions(+), 44 deletions(-) create mode 100644 src/Nitride.Markdown/IdentifyMarkdownFromPath.cs diff --git a/Nitride.sln.DotSettings b/Nitride.sln.DotSettings index 06b6404..bd0fdf7 100644 --- a/Nitride.sln.DotSettings +++ b/Nitride.sln.DotSettings @@ -1366,5 +1366,6 @@ using(DataAccessAdapter dataAccessAdapter = new DataAccessAdapter(ConnectionStri True 2.0 InCSharpStatement + True True diff --git a/src/Nitride.Generators/WithPropertySourceGenerator.cs b/src/Nitride.Generators/WithPropertySourceGenerator.cs index 08eb9d8..7e3e239 100644 --- a/src/Nitride.Generators/WithPropertySourceGenerator.cs +++ b/src/Nitride.Generators/WithPropertySourceGenerator.cs @@ -120,7 +120,11 @@ public class WithPropertySourceGenerator : ISourceGenerator // We have the components for writing out a setter. buffer.AppendLine( - string.Format(" public {0} With{1}({2} value)", cds.Identifier, pds.Identifier, pds.Type)); + string.Format( + " public virtual {0} With{1}({2} value)", + cds.Identifier, + pds.Identifier, + pds.Type)); buffer.AppendLine(" {"); buffer.AppendLine(string.Format(" this.{0} = value;", pds.Identifier)); buffer.AppendLine(" return this;"); diff --git a/src/Nitride.IO/README.md b/src/Nitride.IO/README.md index 2b62695..6ef044f 100644 --- a/src/Nitride.IO/README.md +++ b/src/Nitride.IO/README.md @@ -4,9 +4,9 @@ This assembly contains the primary system for reading and writing from the disk, along with various processes to manipulate paths. It contains three primary components: -- File System I/O -- Path Normalization -- Disk-Based Content +- File System I/O +- Path Normalization +- Disk-Based Content ## File System I/O diff --git a/src/Nitride.Markdown/ConvertMarkdownToGemtext.cs b/src/Nitride.Markdown/ConvertMarkdownToGemtext.cs index ef691a0..a388eec 100644 --- a/src/Nitride.Markdown/ConvertMarkdownToGemtext.cs +++ b/src/Nitride.Markdown/ConvertMarkdownToGemtext.cs @@ -1,3 +1,5 @@ +using System; + using FluentValidation; using Gallium; @@ -23,6 +25,13 @@ public class ConvertMarkdownToGemtext : ConvertMarkdownToBase { } + /// + public override ConvertMarkdownToGemtext WithConfigureMarkdown(Action? value) + { + base.WithConfigureMarkdown(value); + return this; + } + /// /// Converts the Markdown file into HTML. /// diff --git a/src/Nitride.Markdown/ConvertMarkdownToHtml.cs b/src/Nitride.Markdown/ConvertMarkdownToHtml.cs index 97ca475..a411f32 100644 --- a/src/Nitride.Markdown/ConvertMarkdownToHtml.cs +++ b/src/Nitride.Markdown/ConvertMarkdownToHtml.cs @@ -1,3 +1,5 @@ +using System; + using FluentValidation; using Gallium; @@ -20,6 +22,13 @@ public class ConvertMarkdownToHtml : ConvertMarkdownToBase { } + /// + public override ConvertMarkdownToHtml WithConfigureMarkdown(Action? value) + { + base.WithConfigureMarkdown(value); + return this; + } + /// /// Converts the Markdown file into HTML. /// diff --git a/src/Nitride.Markdown/IdentifyMarkdown.cs b/src/Nitride.Markdown/IdentifyMarkdown.cs index cf90ec8..260fe09 100644 --- a/src/Nitride.Markdown/IdentifyMarkdown.cs +++ b/src/Nitride.Markdown/IdentifyMarkdown.cs @@ -24,10 +24,9 @@ public partial class IdentifyMarkdown : IOperation public IdentifyMarkdown(IValidator validator) { this.validator = validator; - this.IsMarkdownTest = DefaultIsMarkdown; } - public Func IsMarkdownTest { get; set; } + public Func IsMarkdownTest { get; set; } = null!; /// public IEnumerable Run(IEnumerable input) @@ -38,16 +37,6 @@ public partial class IdentifyMarkdown : IOperation .ForEachEntity(this.MarkBinaryEntities); } - private static bool DefaultIsMarkdown(Entity entity, UPath path) - { - return (path.GetExtensionWithDot() ?? string.Empty).ToLowerInvariant() switch - { - ".md" => true, - ".markdown" => true, - _ => false, - }; - } - private Entity MarkBinaryEntities(Entity entity, UPath path, IBinaryContent binary) { // If we aren't a Markdown file, then there is nothing @@ -65,7 +54,7 @@ public partial class IdentifyMarkdown : IOperation else { throw new InvalidOperationException( - "Cannot convert a binary content to a " + "text without ITextContentConvertable."); + "Cannot convert a binary content to a text without ITextContentConvertable."); } return entity; diff --git a/src/Nitride.Markdown/IdentifyMarkdownFromPath.cs b/src/Nitride.Markdown/IdentifyMarkdownFromPath.cs new file mode 100644 index 0000000..20435dc --- /dev/null +++ b/src/Nitride.Markdown/IdentifyMarkdownFromPath.cs @@ -0,0 +1,26 @@ +using FluentValidation; + +using Gallium; + +using Zio; + +namespace Nitride.Markdown; + +public class IdentifyMarkdownFromPath : IdentifyMarkdown +{ + public IdentifyMarkdownFromPath(IValidator validator) + : base(validator) + { + this.IsMarkdownTest = DefaultIsMarkdown; + } + + private static bool DefaultIsMarkdown(Entity entity, UPath path) + { + return (path.GetExtensionWithDot() ?? string.Empty).ToLowerInvariant() switch + { + ".md" => true, + ".markdown" => true, + _ => false, + }; + } +} diff --git a/src/Nitride/Entities/README.md b/src/Nitride/Entities/README.md index 519c714..17f320b 100644 --- a/src/Nitride/Entities/README.md +++ b/src/Nitride/Entities/README.md @@ -48,34 +48,34 @@ Assert.Equal(2, newEntity.Count); The basic operations for entity components are: -- `Add(component)`: Adds a component as the given type. If there is - already a component there, an exception will be thrown. -- `Add(component)`: As `Add(component)` but the `TType` is the same as - `component.GetType()`. -- `Remove()`: Removes any component of the given type, if exists. If - there is no such component, then nothing happens. -- `Remove(component)`: Same as `Remove` with the component given - determining the `TType`. -- `Set(component)`: Adds or updates a component of the given type. -- `Set(component)`: Same as `Set` with the component given determining - the `TType`. -- `Copy()`: Creates a copy of the entity and assigns it a new identifier. -- `ExactCopy()`: Creates a copy of the entity with the same identifier. +- `Add(component)`: Adds a component as the given type. If there is + already a component there, an exception will be thrown. +- `Add(component)`: As `Add(component)` but the `TType` is the same as + `component.GetType()`. +- `Remove()`: Removes any component of the given type, if exists. If + there is no such component, then nothing happens. +- `Remove(component)`: Same as `Remove` with the component given + determining the `TType`. +- `Set(component)`: Adds or updates a component of the given type. +- `Set(component)`: Same as `Set` with the component given determining + the `TType`. +- `Copy()`: Creates a copy of the entity and assigns it a new identifier. +- `ExactCopy()`: Creates a copy of the entity with the same identifier. As above, all of these return a new entity (or the same one if no change is made to the entity). ### Query Components -- `bool Has()`: Returns a value indicating whether the entity has the - given component type. -- `TType Get()`: Returns the value of the registered component. If there - is no such object, this will throw an exception. -- `TType? GetOptional()`: Returns the value of the registered component. - If there is no such object, this will return the default value. -- `bool TryGet(out TType component)`: Attempt to get the component. If it - cannot be retrieved, then this will return `false` and `component` is - undefined. +- `bool Has()`: Returns a value indicating whether the entity has the + given component type. +- `TType Get()`: Returns the value of the registered component. If there + is no such object, this will throw an exception. +- `TType? GetOptional()`: Returns the value of the registered component. + If there is no such object, this will return the default value. +- `bool TryGet(out TType component)`: Attempt to get the component. If it + cannot be retrieved, then this will return `false` and `component` is + undefined. ## Collections diff --git a/src/Nitride/ROADMAP.md b/src/Nitride/ROADMAP.md index 0d8e157..b5b2761 100644 --- a/src/Nitride/ROADMAP.md +++ b/src/Nitride/ROADMAP.md @@ -2,8 +2,8 @@ ## Immediate -- Switch the various operations to be async - - ReadFiles - - WriteFiles -- Implement mime type determination -- Implement a convert to text content based on mime type +- Switch the various operations to be async + - ReadFiles + - WriteFiles +- Implement mime type determination +- Implement a convert to text content based on mime type