fix: correcting some patterns and inheritances

This commit is contained in:
Dylan R. E. Moonfire 2022-06-06 09:32:22 -05:00
parent dd2ed640e9
commit 18264b4b2b
9 changed files with 82 additions and 44 deletions

View file

@ -1366,5 +1366,6 @@ using(DataAccessAdapter dataAccessAdapter = new DataAccessAdapter(ConnectionStri
<s:Boolean x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=F87CBA43E9CDCC41A45B39A2A2A25764/Scope/=2C285F182AC98D44B0B4F29D4D2149EC/@KeyIndexDefined">True</s:Boolean> <s:Boolean x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=F87CBA43E9CDCC41A45B39A2A2A25764/Scope/=2C285F182AC98D44B0B4F29D4D2149EC/@KeyIndexDefined">True</s:Boolean>
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=F87CBA43E9CDCC41A45B39A2A2A25764/Scope/=2C285F182AC98D44B0B4F29D4D2149EC/CustomProperties/=minimumLanguageVersion/@EntryIndexedValue">2.0</s:String> <s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=F87CBA43E9CDCC41A45B39A2A2A25764/Scope/=2C285F182AC98D44B0B4F29D4D2149EC/CustomProperties/=minimumLanguageVersion/@EntryIndexedValue">2.0</s:String>
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=F87CBA43E9CDCC41A45B39A2A2A25764/Scope/=2C285F182AC98D44B0B4F29D4D2149EC/Type/@EntryValue">InCSharpStatement</s:String> <s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=F87CBA43E9CDCC41A45B39A2A2A25764/Scope/=2C285F182AC98D44B0B4F29D4D2149EC/Type/@EntryValue">InCSharpStatement</s:String>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Gemtext/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Tocks/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Tocks/@EntryIndexedValue">True</s:Boolean>
</wpf:ResourceDictionary> </wpf:ResourceDictionary>

View file

@ -120,7 +120,11 @@ public class WithPropertySourceGenerator : ISourceGenerator
// We have the components for writing out a setter. // We have the components for writing out a setter.
buffer.AppendLine( 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(" {");
buffer.AppendLine(string.Format(" this.{0} = value;", pds.Identifier)); buffer.AppendLine(string.Format(" this.{0} = value;", pds.Identifier));
buffer.AppendLine(" return this;"); buffer.AppendLine(" return this;");

View file

@ -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 along with various processes to manipulate paths. It contains three primary
components: components:
- File System I/O - File System I/O
- Path Normalization - Path Normalization
- Disk-Based Content - Disk-Based Content
## File System I/O ## File System I/O

View file

@ -1,3 +1,5 @@
using System;
using FluentValidation; using FluentValidation;
using Gallium; using Gallium;
@ -23,6 +25,13 @@ public class ConvertMarkdownToGemtext : ConvertMarkdownToBase
{ {
} }
/// <inheritdoc />
public override ConvertMarkdownToGemtext WithConfigureMarkdown(Action<MarkdownPipelineBuilder>? value)
{
base.WithConfigureMarkdown(value);
return this;
}
/// <summary> /// <summary>
/// Converts the Markdown file into HTML. /// Converts the Markdown file into HTML.
/// </summary> /// </summary>

View file

@ -1,3 +1,5 @@
using System;
using FluentValidation; using FluentValidation;
using Gallium; using Gallium;
@ -20,6 +22,13 @@ public class ConvertMarkdownToHtml : ConvertMarkdownToBase
{ {
} }
/// <inheritdoc />
public override ConvertMarkdownToHtml WithConfigureMarkdown(Action<MarkdownPipelineBuilder>? value)
{
base.WithConfigureMarkdown(value);
return this;
}
/// <summary> /// <summary>
/// Converts the Markdown file into HTML. /// Converts the Markdown file into HTML.
/// </summary> /// </summary>

View file

@ -24,10 +24,9 @@ public partial class IdentifyMarkdown : IOperation
public IdentifyMarkdown(IValidator<IdentifyMarkdown> validator) public IdentifyMarkdown(IValidator<IdentifyMarkdown> validator)
{ {
this.validator = validator; this.validator = validator;
this.IsMarkdownTest = DefaultIsMarkdown;
} }
public Func<Entity, UPath, bool> IsMarkdownTest { get; set; } public Func<Entity, UPath, bool> IsMarkdownTest { get; set; } = null!;
/// <inheritdoc /> /// <inheritdoc />
public IEnumerable<Entity> Run(IEnumerable<Entity> input) public IEnumerable<Entity> Run(IEnumerable<Entity> input)
@ -38,16 +37,6 @@ public partial class IdentifyMarkdown : IOperation
.ForEachEntity<UPath, IBinaryContent>(this.MarkBinaryEntities); .ForEachEntity<UPath, IBinaryContent>(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) private Entity MarkBinaryEntities(Entity entity, UPath path, IBinaryContent binary)
{ {
// If we aren't a Markdown file, then there is nothing // If we aren't a Markdown file, then there is nothing
@ -65,7 +54,7 @@ public partial class IdentifyMarkdown : IOperation
else else
{ {
throw new InvalidOperationException( 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; return entity;

View file

@ -0,0 +1,26 @@
using FluentValidation;
using Gallium;
using Zio;
namespace Nitride.Markdown;
public class IdentifyMarkdownFromPath : IdentifyMarkdown
{
public IdentifyMarkdownFromPath(IValidator<IdentifyMarkdown> 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,
};
}
}

View file

@ -48,34 +48,34 @@ Assert.Equal(2, newEntity.Count);
The basic operations for entity components are: The basic operations for entity components are:
- `Add<TType>(component)`: Adds a component as the given type. If there is - `Add<TType>(component)`: Adds a component as the given type. If there is
already a component there, an exception will be thrown. already a component there, an exception will be thrown.
- `Add(component)`: As `Add<TType>(component)` but the `TType` is the same as - `Add(component)`: As `Add<TType>(component)` but the `TType` is the same as
`component.GetType()`. `component.GetType()`.
- `Remove<TType>()`: Removes any component of the given type, if exists. If - `Remove<TType>()`: Removes any component of the given type, if exists. If
there is no such component, then nothing happens. there is no such component, then nothing happens.
- `Remove(component)`: Same as `Remove<TType>` with the component given - `Remove(component)`: Same as `Remove<TType>` with the component given
determining the `TType`. determining the `TType`.
- `Set<TType>(component)`: Adds or updates a component of the given type. - `Set<TType>(component)`: Adds or updates a component of the given type.
- `Set(component)`: Same as `Set<TType>` with the component given determining - `Set(component)`: Same as `Set<TType>` with the component given determining
the `TType`. the `TType`.
- `Copy()`: Creates a copy of the entity and assigns it a new identifier. - `Copy()`: Creates a copy of the entity and assigns it a new identifier.
- `ExactCopy()`: Creates a copy of the entity with the same 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 As above, all of these return a new entity (or the same one if no change is made
to the entity). to the entity).
### Query Components ### Query Components
- `bool Has<TType>()`: Returns a value indicating whether the entity has the - `bool Has<TType>()`: Returns a value indicating whether the entity has the
given component type. given component type.
- `TType Get<TType>()`: Returns the value of the registered component. If there - `TType Get<TType>()`: Returns the value of the registered component. If there
is no such object, this will throw an exception. is no such object, this will throw an exception.
- `TType? GetOptional<TType>()`: Returns the value of the registered component. - `TType? GetOptional<TType>()`: Returns the value of the registered component.
If there is no such object, this will return the default value. If there is no such object, this will return the default value.
- `bool TryGet<TType>(out TType component)`: Attempt to get the component. If it - `bool TryGet<TType>(out TType component)`: Attempt to get the component. If it
cannot be retrieved, then this will return `false` and `component` is cannot be retrieved, then this will return `false` and `component` is
undefined. undefined.
## Collections ## Collections

View file

@ -2,8 +2,8 @@
## Immediate ## Immediate
- Switch the various operations to be async - Switch the various operations to be async
- ReadFiles - ReadFiles
- WriteFiles - WriteFiles
- Implement mime type determination - Implement mime type determination
- Implement a convert to text content based on mime type - Implement a convert to text content based on mime type