refactor!: fixed missed namespaces
- reformatted code and cleaned up references
This commit is contained in:
parent
6a397f5284
commit
9e93eb6ce6
109 changed files with 748 additions and 432 deletions
|
@ -7,20 +7,20 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\..\src\MfGames.Nitride.IO\MfGames.Nitride.IO.csproj" />
|
<ProjectReference Include="..\..\src\MfGames.Nitride.IO\MfGames.Nitride.IO.csproj"/>
|
||||||
<ProjectReference Include="..\..\src\MfGames.Nitride\MfGames.Nitride.csproj" />
|
<ProjectReference Include="..\..\src\MfGames.Nitride\MfGames.Nitride.csproj"/>
|
||||||
<ProjectReference Include="..\..\tests\MfGames.Nitride.Tests\MfGames.Nitride.Tests.csproj" />
|
<ProjectReference Include="..\..\tests\MfGames.Nitride.Tests\MfGames.Nitride.Tests.csproj"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="CliWrap" Version="3.5.0" />
|
<PackageReference Include="CliWrap" Version="3.5.0"/>
|
||||||
<PackageReference Include="JunitXml.TestLogger" Version="3.0.114" />
|
<PackageReference Include="JunitXml.TestLogger" Version="3.0.114"/>
|
||||||
<PackageReference Include="xunit" Version="2.4.2" />
|
<PackageReference Include="xunit" Version="2.4.2"/>
|
||||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
|
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="MfGames.IO" Version="1.2.7" />
|
<PackageReference Include="MfGames.IO" Version="1.2.7"/>
|
||||||
<PackageReference Include="coverlet.collector" Version="3.1.2">
|
<PackageReference Include="coverlet.collector" Version="3.1.2">
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
using MfGames.Gallium;
|
using MfGames.Gallium;
|
||||||
|
|
||||||
using MfGames.Nitride;
|
using MfGames.Nitride;
|
||||||
using MfGames.Nitride.IO.Contents;
|
using MfGames.Nitride.IO.Contents;
|
||||||
using MfGames.Nitride.IO.Directories;
|
using MfGames.Nitride.IO.Directories;
|
||||||
|
|
|
@ -4,7 +4,6 @@ using System.Threading.Tasks;
|
||||||
using Autofac;
|
using Autofac;
|
||||||
|
|
||||||
using MfGames.IO.Extensions;
|
using MfGames.IO.Extensions;
|
||||||
|
|
||||||
using MfGames.Nitride;
|
using MfGames.Nitride;
|
||||||
using MfGames.Nitride.IO;
|
using MfGames.Nitride.IO;
|
||||||
|
|
||||||
|
@ -27,7 +26,8 @@ public static class CopyFilesProgram
|
||||||
// system. At the moment, we set the "root" directory which will
|
// system. At the moment, we set the "root" directory which will
|
||||||
// contains all the paths, both input and output.
|
// contains all the paths, both input and output.
|
||||||
DirectoryInfo rootDir =
|
DirectoryInfo rootDir =
|
||||||
typeof(CopyFilesProgram).GetDirectory()!.FindGitRoot()!.GetDirectory("examples/CopyFiles");
|
typeof(CopyFilesProgram).GetDirectory()!.FindGitRoot()!
|
||||||
|
.GetDirectory("examples/CopyFiles");
|
||||||
|
|
||||||
builder.WithRootDirectory(rootDir);
|
builder.WithRootDirectory(rootDir);
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@ using System.Threading.Tasks;
|
||||||
using CliWrap;
|
using CliWrap;
|
||||||
|
|
||||||
using MfGames.IO.Extensions;
|
using MfGames.IO.Extensions;
|
||||||
|
|
||||||
using MfGames.Nitride.Tests;
|
using MfGames.Nitride.Tests;
|
||||||
|
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
@ -27,7 +26,8 @@ public class CopyFilesTest : NitrideTestBase
|
||||||
{
|
{
|
||||||
// Figure out the paths for this test.
|
// Figure out the paths for this test.
|
||||||
DirectoryInfo rootDir =
|
DirectoryInfo rootDir =
|
||||||
typeof(CopyFilesProgram).GetDirectory()!.FindGitRoot()!.GetDirectory("examples/CopyFiles");
|
typeof(CopyFilesProgram).GetDirectory()!.FindGitRoot()!
|
||||||
|
.GetDirectory("examples/CopyFiles");
|
||||||
|
|
||||||
DirectoryInfo outputDir = rootDir.GetDirectory("output");
|
DirectoryInfo outputDir = rootDir.GetDirectory("output");
|
||||||
FileInfo projectFile = rootDir.GetFile("CopyFiles.csproj");
|
FileInfo projectFile = rootDir.GetFile("CopyFiles.csproj");
|
||||||
|
|
|
@ -4,12 +4,11 @@ using System.Linq;
|
||||||
|
|
||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
|
|
||||||
using MfGames.Gallium;
|
|
||||||
|
|
||||||
using Ical.Net.CalendarComponents;
|
using Ical.Net.CalendarComponents;
|
||||||
using Ical.Net.DataTypes;
|
using Ical.Net.DataTypes;
|
||||||
using Ical.Net.Serialization;
|
using Ical.Net.Serialization;
|
||||||
|
|
||||||
|
using MfGames.Gallium;
|
||||||
using MfGames.Nitride.Contents;
|
using MfGames.Nitride.Contents;
|
||||||
using MfGames.Nitride.Temporal;
|
using MfGames.Nitride.Temporal;
|
||||||
|
|
||||||
|
@ -62,12 +61,14 @@ public partial class CreateCalender : OperationBase
|
||||||
this.validator.ValidateAndThrow(this);
|
this.validator.ValidateAndThrow(this);
|
||||||
|
|
||||||
SplitEntityEnumerations split = input.SplitEntity<Instant>();
|
SplitEntityEnumerations split = input.SplitEntity<Instant>();
|
||||||
IEnumerable<Entity> datedAndCalendars = this.CreateCalendarEntity(split.HasAll);
|
IEnumerable<Entity> datedAndCalendars =
|
||||||
|
this.CreateCalendarEntity(split.HasAll);
|
||||||
|
|
||||||
return datedAndCalendars.Union(split.NotHasAll);
|
return datedAndCalendars.Union(split.NotHasAll);
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerable<Entity> CreateCalendarEntity(IEnumerable<Entity> entities)
|
private IEnumerable<Entity> CreateCalendarEntity(
|
||||||
|
IEnumerable<Entity> entities)
|
||||||
{
|
{
|
||||||
// Create the calendar in the same time zone as the rest of the system.
|
// Create the calendar in the same time zone as the rest of the system.
|
||||||
var calendar = new Ical.Net.Calendar();
|
var calendar = new Ical.Net.Calendar();
|
||||||
|
@ -76,7 +77,8 @@ public partial class CreateCalender : OperationBase
|
||||||
|
|
||||||
// Go through the events and add all of them.
|
// Go through the events and add all of them.
|
||||||
var input = entities.ToList();
|
var input = entities.ToList();
|
||||||
IEnumerable<CalendarEvent> events = input.Select(this.CreateCalendarEvent);
|
IEnumerable<CalendarEvent> events =
|
||||||
|
input.Select(this.CreateCalendarEvent);
|
||||||
|
|
||||||
calendar.Events.AddRange(events);
|
calendar.Events.AddRange(events);
|
||||||
|
|
||||||
|
|
|
@ -10,16 +10,16 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\MfGames.Nitride.IO\MfGames.Nitride.IO.csproj" />
|
<ProjectReference Include="..\MfGames.Nitride.IO\MfGames.Nitride.IO.csproj"/>
|
||||||
<ProjectReference Include="..\MfGames.Nitride.Temporal\MfGames.Nitride.Temporal.csproj" />
|
<ProjectReference Include="..\MfGames.Nitride.Temporal\MfGames.Nitride.Temporal.csproj"/>
|
||||||
<ProjectReference Include="..\MfGames.Nitride\MfGames.Nitride.csproj" />
|
<ProjectReference Include="..\MfGames.Nitride\MfGames.Nitride.csproj"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="MfGames.Gallium" Version="0.3.0" />
|
<PackageReference Include="MfGames.Gallium" Version="0.3.0"/>
|
||||||
<PackageReference Include="Ical.Net" Version="4.2.0" />
|
<PackageReference Include="Ical.Net" Version="4.2.0"/>
|
||||||
<PackageReference Include="NodaTime" Version="3.1.2" />
|
<PackageReference Include="NodaTime" Version="3.1.2"/>
|
||||||
<PackageReference Include="Zio" Version="0.15.0" />
|
<PackageReference Include="Zio" Version="0.15.0"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<!-- Include the source generator -->
|
<!-- Include the source generator -->
|
||||||
|
|
|
@ -8,7 +8,8 @@ public static class NitrideCalendarBuilderExtensions
|
||||||
{
|
{
|
||||||
public static NitrideBuilder UseCalendar(this NitrideBuilder builder)
|
public static NitrideBuilder UseCalendar(this NitrideBuilder builder)
|
||||||
{
|
{
|
||||||
return builder.UseTemporal()
|
return builder
|
||||||
|
.UseTemporal()
|
||||||
.ConfigureContainer(x => x.RegisterModule<NitrideCalendarModule>());
|
.ConfigureContainer(x => x.RegisterModule<NitrideCalendarModule>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@ using System.Linq;
|
||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
|
|
||||||
using MfGames.Gallium;
|
using MfGames.Gallium;
|
||||||
|
|
||||||
using MfGames.Nitride.Contents;
|
using MfGames.Nitride.Contents;
|
||||||
using MfGames.Nitride.Feeds.Structure;
|
using MfGames.Nitride.Feeds.Structure;
|
||||||
|
|
||||||
|
|
|
@ -10,15 +10,15 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\MfGames.Nitride.IO\MfGames.Nitride.IO.csproj" />
|
<ProjectReference Include="..\MfGames.Nitride.IO\MfGames.Nitride.IO.csproj"/>
|
||||||
<ProjectReference Include="..\MfGames.Nitride.Temporal\MfGames.Nitride.Temporal.csproj" />
|
<ProjectReference Include="..\MfGames.Nitride.Temporal\MfGames.Nitride.Temporal.csproj"/>
|
||||||
<ProjectReference Include="..\MfGames.Nitride\MfGames.Nitride.csproj" />
|
<ProjectReference Include="..\MfGames.Nitride\MfGames.Nitride.csproj"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="MfGames.Gallium" Version="0.3.0" />
|
<PackageReference Include="MfGames.Gallium" Version="0.3.0"/>
|
||||||
<PackageReference Include="NodaTime" Version="3.1.2" />
|
<PackageReference Include="NodaTime" Version="3.1.2"/>
|
||||||
<PackageReference Include="Zio" Version="0.15.0" />
|
<PackageReference Include="Zio" Version="0.15.0"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<!-- Include the source generator -->
|
<!-- Include the source generator -->
|
||||||
|
|
|
@ -29,7 +29,10 @@ public partial class AtomAuthor
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(this.Name))
|
if (!string.IsNullOrEmpty(this.Name))
|
||||||
{
|
{
|
||||||
author.Add(new XElement(XmlConstants.AtomNamespace + "name", new XText(this.Name)));
|
author.Add(
|
||||||
|
new XElement(
|
||||||
|
XmlConstants.AtomNamespace + "name",
|
||||||
|
new XText(this.Name)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return author;
|
return author;
|
||||||
|
|
|
@ -36,7 +36,9 @@ public partial class AtomCategory
|
||||||
throw new NullReferenceException("Category term cannot be null.");
|
throw new NullReferenceException("Category term cannot be null.");
|
||||||
}
|
}
|
||||||
|
|
||||||
var elem = new XElement(XmlConstants.AtomNamespace + "category", new XAttribute("term", this.Term));
|
var elem = new XElement(
|
||||||
|
XmlConstants.AtomNamespace + "category",
|
||||||
|
new XAttribute("term", this.Term));
|
||||||
|
|
||||||
if (this.Scheme != null)
|
if (this.Scheme != null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -24,7 +24,10 @@ public static class AtomHelper
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrWhiteSpace(text))
|
if (!string.IsNullOrWhiteSpace(text))
|
||||||
{
|
{
|
||||||
elem.Add(new XElement(XmlConstants.AtomNamespace + name, new XText(text)));
|
elem.Add(
|
||||||
|
new XElement(
|
||||||
|
XmlConstants.AtomNamespace + name,
|
||||||
|
new XText(text)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,10 +10,12 @@ public static class XmlConstants
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The XML namespace for Atom feeds.
|
/// The XML namespace for Atom feeds.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly XNamespace AtomNamespace = "http://www.w3.org/2005/Atom";
|
public static readonly XNamespace AtomNamespace =
|
||||||
|
"http://www.w3.org/2005/Atom";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The XML namespace for media.
|
/// The XML namespace for media.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly XNamespace MediaNamespace = "http://search.yahoo.com/mrss/";
|
public static readonly XNamespace MediaNamespace =
|
||||||
|
"http://search.yahoo.com/mrss/";
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ public static class NitrideGemtextBuilderExtensions
|
||||||
{
|
{
|
||||||
public static NitrideBuilder UseGemtext(this NitrideBuilder builder)
|
public static NitrideBuilder UseGemtext(this NitrideBuilder builder)
|
||||||
{
|
{
|
||||||
return builder.ConfigureContainer(x => x.RegisterModule<NitrideGemtextModule>());
|
return builder.ConfigureContainer(
|
||||||
|
x => x.RegisterModule<NitrideGemtextModule>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,12 @@ public static class CodeAnalysisExtensions
|
||||||
string format,
|
string format,
|
||||||
params object[] parameters)
|
params object[] parameters)
|
||||||
{
|
{
|
||||||
context.Message(messageCode, location, DiagnosticSeverity.Error, format, parameters);
|
context.Message(
|
||||||
|
messageCode,
|
||||||
|
location,
|
||||||
|
DiagnosticSeverity.Error,
|
||||||
|
format,
|
||||||
|
parameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -72,7 +77,12 @@ public static class CodeAnalysisExtensions
|
||||||
string format,
|
string format,
|
||||||
params object[] parameters)
|
params object[] parameters)
|
||||||
{
|
{
|
||||||
context.Message(messageCode, location, DiagnosticSeverity.Info, format, parameters);
|
context.Message(
|
||||||
|
messageCode,
|
||||||
|
location,
|
||||||
|
DiagnosticSeverity.Info,
|
||||||
|
format,
|
||||||
|
parameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -106,7 +116,12 @@ public static class CodeAnalysisExtensions
|
||||||
string format,
|
string format,
|
||||||
params object[] parameters)
|
params object[] parameters)
|
||||||
{
|
{
|
||||||
context.Message(messageCode, location, DiagnosticSeverity.Warning, format, parameters);
|
context.Message(
|
||||||
|
messageCode,
|
||||||
|
location,
|
||||||
|
DiagnosticSeverity.Warning,
|
||||||
|
format,
|
||||||
|
parameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -134,7 +149,10 @@ public static class CodeAnalysisExtensions
|
||||||
severity,
|
severity,
|
||||||
severity,
|
severity,
|
||||||
true,
|
true,
|
||||||
severity is DiagnosticSeverity.Warning or DiagnosticSeverity.Info ? 4 : 0,
|
severity is DiagnosticSeverity.Warning
|
||||||
|
or DiagnosticSeverity.Info
|
||||||
|
? 4
|
||||||
|
: 0,
|
||||||
location: location));
|
location: location));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,10 +10,10 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="MfGames.Gallium" Version="0.3.0" />
|
<PackageReference Include="MfGames.Gallium" Version="0.3.0"/>
|
||||||
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.3.1" />
|
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.3.1"/>
|
||||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.3.1" />
|
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.3.1"/>
|
||||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.3.1" />
|
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.3.1"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -22,7 +22,8 @@ public class WithPropertySourceGenerator : ISourceGenerator
|
||||||
// Get the generator infrastructure will create a receiver and
|
// Get the generator infrastructure will create a receiver and
|
||||||
// populate it we can retrieve the populated instance via the
|
// populate it we can retrieve the populated instance via the
|
||||||
// context.
|
// context.
|
||||||
var syntaxReceiver = (WithPropertySyntaxReceiver?)context.SyntaxReceiver;
|
var syntaxReceiver =
|
||||||
|
(WithPropertySyntaxReceiver?)context.SyntaxReceiver;
|
||||||
|
|
||||||
if (syntaxReceiver == null)
|
if (syntaxReceiver == null)
|
||||||
{
|
{
|
||||||
|
@ -37,7 +38,9 @@ public class WithPropertySourceGenerator : ISourceGenerator
|
||||||
Location.Create(
|
Location.Create(
|
||||||
"Temporary.g.cs",
|
"Temporary.g.cs",
|
||||||
TextSpan.FromBounds(0, 0),
|
TextSpan.FromBounds(0, 0),
|
||||||
new LinePositionSpan(new LinePosition(0, 0), new LinePosition(0, 0))),
|
new LinePositionSpan(
|
||||||
|
new LinePosition(0, 0),
|
||||||
|
new LinePosition(0, 0))),
|
||||||
"Generating additional identifier code: {0}",
|
"Generating additional identifier code: {0}",
|
||||||
message);
|
message);
|
||||||
}
|
}
|
||||||
|
@ -58,7 +61,8 @@ public class WithPropertySourceGenerator : ISourceGenerator
|
||||||
public void Initialize(GeneratorInitializationContext context)
|
public void Initialize(GeneratorInitializationContext context)
|
||||||
{
|
{
|
||||||
// Register a factory that can create our custom syntax receiver
|
// Register a factory that can create our custom syntax receiver
|
||||||
context.RegisterForSyntaxNotifications(() => new WithPropertySyntaxReceiver(context));
|
context.RegisterForSyntaxNotifications(
|
||||||
|
() => new WithPropertySyntaxReceiver(context));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void GenerateClassFile(
|
private void GenerateClassFile(
|
||||||
|
@ -96,7 +100,10 @@ public class WithPropertySourceGenerator : ISourceGenerator
|
||||||
foreach (PropertyDeclarationSyntax pds in properties)
|
foreach (PropertyDeclarationSyntax pds in properties)
|
||||||
{
|
{
|
||||||
// See if we have a setter.
|
// See if we have a setter.
|
||||||
bool found = pds.AccessorList?.Accessors.Any(x => x.Keyword.ToString() == "set") ?? false;
|
bool found =
|
||||||
|
pds.AccessorList?.Accessors.Any(
|
||||||
|
x => x.Keyword.ToString() == "set")
|
||||||
|
?? false;
|
||||||
|
|
||||||
if (!found)
|
if (!found)
|
||||||
{
|
{
|
||||||
|
@ -132,7 +139,8 @@ public class WithPropertySourceGenerator : ISourceGenerator
|
||||||
pds.Type));
|
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;");
|
||||||
buffer.AppendLine(" }");
|
buffer.AppendLine(" }");
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,10 +3,9 @@ using System.Collections.Generic;
|
||||||
|
|
||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
|
|
||||||
using MfGames.Gallium;
|
|
||||||
|
|
||||||
using HandlebarsDotNet;
|
using HandlebarsDotNet;
|
||||||
|
|
||||||
|
using MfGames.Gallium;
|
||||||
using MfGames.Nitride.Contents;
|
using MfGames.Nitride.Contents;
|
||||||
|
|
||||||
namespace MfGames.Nitride.Handlebars;
|
namespace MfGames.Nitride.Handlebars;
|
||||||
|
@ -61,7 +60,8 @@ public partial class ApplyStyleTemplate : OperationBase
|
||||||
{
|
{
|
||||||
object model = this.CreateModelCallback!(entity);
|
object model = this.CreateModelCallback!(entity);
|
||||||
string name = this.GetTemplateName!(entity);
|
string name = this.GetTemplateName!(entity);
|
||||||
HandlebarsTemplate<object, object> template = this.cache.GetNamedTemplate(name);
|
HandlebarsTemplate<object, object> template =
|
||||||
|
this.cache.GetNamedTemplate(name);
|
||||||
string result = template(model!);
|
string result = template(model!);
|
||||||
|
|
||||||
return entity.SetTextContent(result);
|
return entity.SetTextContent(result);
|
||||||
|
|
|
@ -23,12 +23,14 @@ public class ForEachHandlebarsBlock<TModel> : HandlebarsBlockBase
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the callback that is called when nothing is found.
|
/// Gets or sets the callback that is called when nothing is found.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Action<EncodedTextWriter, BlockHelperOptions, Context, Arguments>? NothingFound { get; set; }
|
public Action<EncodedTextWriter, BlockHelperOptions, Context, Arguments>?
|
||||||
|
NothingFound { get; set; }
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override string HelperName { get; }
|
protected override string HelperName { get; }
|
||||||
|
|
||||||
public ForEachHandlebarsBlock<TModel> WithGetList(Func<TModel, IEnumerable<object>>? callback)
|
public ForEachHandlebarsBlock<TModel> WithGetList(
|
||||||
|
Func<TModel, IEnumerable<object>>? callback)
|
||||||
{
|
{
|
||||||
this.GetList = callback;
|
this.GetList = callback;
|
||||||
|
|
||||||
|
@ -36,7 +38,8 @@ public class ForEachHandlebarsBlock<TModel> : HandlebarsBlockBase
|
||||||
}
|
}
|
||||||
|
|
||||||
public ForEachHandlebarsBlock<TModel> WithNothingFoundText(
|
public ForEachHandlebarsBlock<TModel> WithNothingFoundText(
|
||||||
Action<EncodedTextWriter, BlockHelperOptions, Context, Arguments>? callback)
|
Action<EncodedTextWriter, BlockHelperOptions, Context, Arguments>?
|
||||||
|
callback)
|
||||||
{
|
{
|
||||||
this.NothingFound = callback;
|
this.NothingFound = callback;
|
||||||
|
|
||||||
|
|
|
@ -16,13 +16,15 @@ public class HandlebarsTemplateCache
|
||||||
|
|
||||||
private readonly ModificationSynchronizer locker;
|
private readonly ModificationSynchronizer locker;
|
||||||
|
|
||||||
private readonly Dictionary<string, HandlebarsTemplate<object, object>> templates;
|
private readonly Dictionary<string, HandlebarsTemplate<object, object>>
|
||||||
|
templates;
|
||||||
|
|
||||||
public HandlebarsTemplateCache(IHandlebars handlebars)
|
public HandlebarsTemplateCache(IHandlebars handlebars)
|
||||||
{
|
{
|
||||||
this.handlebars = handlebars;
|
this.handlebars = handlebars;
|
||||||
this.locker = new ModificationSynchronizer();
|
this.locker = new ModificationSynchronizer();
|
||||||
this.templates = new Dictionary<string, HandlebarsTemplate<object, object>>();
|
this.templates =
|
||||||
|
new Dictionary<string, HandlebarsTemplate<object, object>>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -39,7 +41,8 @@ public class HandlebarsTemplateCache
|
||||||
() => !this.templates.ContainsKey(literal),
|
() => !this.templates.ContainsKey(literal),
|
||||||
() =>
|
() =>
|
||||||
{
|
{
|
||||||
HandlebarsTemplate<object, object> template = this.handlebars!.Compile(literal);
|
HandlebarsTemplate<object, object> template =
|
||||||
|
this.handlebars!.Compile(literal);
|
||||||
|
|
||||||
this.templates[literal] = template;
|
this.templates[literal] = template;
|
||||||
|
|
||||||
|
@ -56,7 +59,8 @@ public class HandlebarsTemplateCache
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="templateName"></param>
|
/// <param name="templateName"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public HandlebarsTemplate<object, object> GetNamedTemplate(string templateName)
|
public HandlebarsTemplate<object, object> GetNamedTemplate(
|
||||||
|
string templateName)
|
||||||
{
|
{
|
||||||
string template = $"{{{{> {templateName}}}}}";
|
string template = $"{{{{> {templateName}}}}}";
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,8 @@ public partial class IdentifyHandlebarsFromComponent : IOperation
|
||||||
{
|
{
|
||||||
private readonly IValidator<IdentifyHandlebarsFromComponent> validator;
|
private readonly IValidator<IdentifyHandlebarsFromComponent> validator;
|
||||||
|
|
||||||
public IdentifyHandlebarsFromComponent(IValidator<IdentifyHandlebarsFromComponent> validator)
|
public IdentifyHandlebarsFromComponent(
|
||||||
|
IValidator<IdentifyHandlebarsFromComponent> validator)
|
||||||
{
|
{
|
||||||
this.validator = validator;
|
this.validator = validator;
|
||||||
}
|
}
|
||||||
|
@ -30,6 +31,8 @@ public partial class IdentifyHandlebarsFromComponent : IOperation
|
||||||
this.validator.ValidateAndThrow(this);
|
this.validator.ValidateAndThrow(this);
|
||||||
|
|
||||||
return input.Select(
|
return input.Select(
|
||||||
(entity) => this.HasHandlebarsTest.Invoke(entity) ? entity.Set(HasHandlebarsTemplate.Instance) : entity);
|
(entity) => this.HasHandlebarsTest.Invoke(entity)
|
||||||
|
? entity.Set(HasHandlebarsTemplate.Instance)
|
||||||
|
: entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,8 @@ using FluentValidation;
|
||||||
|
|
||||||
namespace MfGames.Nitride.Handlebars;
|
namespace MfGames.Nitride.Handlebars;
|
||||||
|
|
||||||
public class IdentifyHandlebarsFromComponentValidator : AbstractValidator<IdentifyHandlebarsFromComponent>
|
public class IdentifyHandlebarsFromComponentValidator
|
||||||
|
: AbstractValidator<IdentifyHandlebarsFromComponent>
|
||||||
{
|
{
|
||||||
public IdentifyHandlebarsFromComponentValidator()
|
public IdentifyHandlebarsFromComponentValidator()
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
using MfGames.Gallium;
|
using MfGames.Gallium;
|
||||||
|
|
||||||
using MfGames.Nitride.Contents;
|
using MfGames.Nitride.Contents;
|
||||||
|
|
||||||
namespace MfGames.Nitride.Handlebars;
|
namespace MfGames.Nitride.Handlebars;
|
||||||
|
|
|
@ -10,15 +10,15 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Autofac" Version="6.4.0" />
|
<PackageReference Include="Autofac" Version="6.4.0"/>
|
||||||
<PackageReference Include="MfGames.Gallium" Version="0.3.0" />
|
<PackageReference Include="MfGames.Gallium" Version="0.3.0"/>
|
||||||
<PackageReference Include="Handlebars.Net" Version="2.1.2" />
|
<PackageReference Include="Handlebars.Net" Version="2.1.2"/>
|
||||||
<PackageReference Include="NodaTime.Testing" Version="3.1.2" />
|
<PackageReference Include="NodaTime.Testing" Version="3.1.2"/>
|
||||||
<PackageReference Include="Open.Threading" Version="2.2.1" />
|
<PackageReference Include="Open.Threading" Version="2.2.1"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\MfGames.Nitride\MfGames.Nitride.csproj" />
|
<ProjectReference Include="..\MfGames.Nitride\MfGames.Nitride.csproj"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<!-- Include the source generator -->
|
<!-- Include the source generator -->
|
||||||
|
|
|
@ -12,7 +12,8 @@ public static class NitrideHandlebarsBuilderExtensions
|
||||||
public static NitrideBuilder UseHandlebars(this NitrideBuilder builder)
|
public static NitrideBuilder UseHandlebars(this NitrideBuilder builder)
|
||||||
{
|
{
|
||||||
return builder
|
return builder
|
||||||
.ConfigureContainer(x => x.RegisterModule<NitrideHandlebarsModule>());
|
.ConfigureContainer(
|
||||||
|
x => x.RegisterModule<NitrideHandlebarsModule>());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static NitrideBuilder UseHandlebars(
|
public static NitrideBuilder UseHandlebars(
|
||||||
|
|
|
@ -23,8 +23,10 @@ public class NitrideHandlebarsModule : Module
|
||||||
builder.Register(
|
builder.Register(
|
||||||
(context) =>
|
(context) =>
|
||||||
{
|
{
|
||||||
IHandlebars handlebars = HandlebarsDotNet.Handlebars.Create();
|
IHandlebars handlebars =
|
||||||
IEnumerable<IHandlebarsLoader> helpers = context.Resolve<IEnumerable<IHandlebarsLoader>>();
|
HandlebarsDotNet.Handlebars.Create();
|
||||||
|
IEnumerable<IHandlebarsLoader> helpers =
|
||||||
|
context.Resolve<IEnumerable<IHandlebarsLoader>>();
|
||||||
|
|
||||||
foreach (IHandlebarsLoader helper in helpers)
|
foreach (IHandlebarsLoader helper in helpers)
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,10 +3,9 @@ using System.Collections.Generic;
|
||||||
|
|
||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
|
|
||||||
using MfGames.Gallium;
|
|
||||||
|
|
||||||
using HandlebarsDotNet;
|
using HandlebarsDotNet;
|
||||||
|
|
||||||
|
using MfGames.Gallium;
|
||||||
using MfGames.Nitride.Contents;
|
using MfGames.Nitride.Contents;
|
||||||
|
|
||||||
namespace MfGames.Nitride.Handlebars;
|
namespace MfGames.Nitride.Handlebars;
|
||||||
|
@ -43,7 +42,8 @@ public partial class RenderContentTemplate : OperationBase
|
||||||
{
|
{
|
||||||
this.validator.ValidateAndThrow(this);
|
this.validator.ValidateAndThrow(this);
|
||||||
|
|
||||||
return input.SelectEntity<HasHandlebarsTemplate, ITextContent>(this.Apply);
|
return input.SelectEntity<HasHandlebarsTemplate, ITextContent>(
|
||||||
|
this.Apply);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Entity Apply(
|
private Entity Apply(
|
||||||
|
@ -52,7 +52,8 @@ public partial class RenderContentTemplate : OperationBase
|
||||||
ITextContent content)
|
ITextContent content)
|
||||||
{
|
{
|
||||||
string text = content.GetText();
|
string text = content.GetText();
|
||||||
HandlebarsTemplate<object, object> template = this.cache.GetLiteralTemplate(text);
|
HandlebarsTemplate<object, object> template =
|
||||||
|
this.cache.GetLiteralTemplate(text);
|
||||||
object model = this.CreateModelCallback!(entity);
|
object model = this.CreateModelCallback!(entity);
|
||||||
string result = template(model!);
|
string result = template(model!);
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,8 @@ using FluentValidation;
|
||||||
|
|
||||||
namespace MfGames.Nitride.Handlebars;
|
namespace MfGames.Nitride.Handlebars;
|
||||||
|
|
||||||
public class RenderContentTemplateValidator : AbstractValidator<RenderContentTemplate>
|
public class RenderContentTemplateValidator
|
||||||
|
: AbstractValidator<RenderContentTemplate>
|
||||||
{
|
{
|
||||||
public RenderContentTemplateValidator()
|
public RenderContentTemplateValidator()
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,7 +2,6 @@ using System.Collections.Generic;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
|
|
||||||
using MfGames.Gallium;
|
using MfGames.Gallium;
|
||||||
|
|
||||||
using MfGames.Nitride.Contents;
|
using MfGames.Nitride.Contents;
|
||||||
|
|
||||||
namespace MfGames.Nitride.Html;
|
namespace MfGames.Nitride.Html;
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\MfGames.Nitride\MfGames.Nitride.csproj" />
|
<ProjectReference Include="..\MfGames.Nitride\MfGames.Nitride.csproj"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<!-- Include the source generator -->
|
<!-- Include the source generator -->
|
||||||
|
@ -25,7 +25,7 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="MfGames.Gallium" Version="0.3.0" />
|
<PackageReference Include="MfGames.Gallium" Version="0.3.0"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -6,6 +6,7 @@ public static class NitrideHtmlBuilderExtensions
|
||||||
{
|
{
|
||||||
public static NitrideBuilder UseHtml(this NitrideBuilder builder)
|
public static NitrideBuilder UseHtml(this NitrideBuilder builder)
|
||||||
{
|
{
|
||||||
return builder.ConfigureContainer(x => x.RegisterModule<NitrideHtmlModule>());
|
return builder.ConfigureContainer(
|
||||||
|
x => x.RegisterModule<NitrideHtmlModule>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,9 @@ public class FileEntryTextContent : ITextContent, IBinaryContentConvertable
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public TextReader GetReader()
|
public TextReader GetReader()
|
||||||
{
|
{
|
||||||
return new StreamReader(this.entry.Open(FileMode.Open, FileAccess.Read, FileShare.Read), Encoding.UTF8);
|
return new StreamReader(
|
||||||
|
this.entry.Open(FileMode.Open, FileAccess.Read, FileShare.Read),
|
||||||
|
Encoding.UTF8);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
|
|
@ -8,7 +8,6 @@ using DotNet.Globbing;
|
||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
|
|
||||||
using MfGames.Gallium;
|
using MfGames.Gallium;
|
||||||
|
|
||||||
using MfGames.Nitride.Contents;
|
using MfGames.Nitride.Contents;
|
||||||
|
|
||||||
using Zio;
|
using Zio;
|
||||||
|
@ -59,7 +58,8 @@ public partial class ReadFiles : FileSystemOperationBase
|
||||||
|
|
||||||
var glob = Glob.Parse(this.Pattern);
|
var glob = Glob.Parse(this.Pattern);
|
||||||
|
|
||||||
IEnumerable<FileEntry> files = this.FileSystem.EnumerateFileEntries("/", "*", SearchOption.AllDirectories)
|
IEnumerable<FileEntry> files = this.FileSystem
|
||||||
|
.EnumerateFileEntries("/", "*", SearchOption.AllDirectories)
|
||||||
.Where(x => glob.IsMatch(x.Path.ToString()));
|
.Where(x => glob.IsMatch(x.Path.ToString()));
|
||||||
|
|
||||||
IEnumerable<Entity> entities = files.Select(this.ToEntity);
|
IEnumerable<Entity> entities = files.Select(this.ToEntity);
|
||||||
|
|
|
@ -7,7 +7,6 @@ using System.Text;
|
||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
|
|
||||||
using MfGames.Gallium;
|
using MfGames.Gallium;
|
||||||
|
|
||||||
using MfGames.Nitride.Contents;
|
using MfGames.Nitride.Contents;
|
||||||
|
|
||||||
using Serilog;
|
using Serilog;
|
||||||
|
@ -48,7 +47,8 @@ public partial class WriteFiles : FileSystemOperationBase, IOperation
|
||||||
public Dictionary<Type, Func<IContent, Stream>> StreamFactories
|
public Dictionary<Type, Func<IContent, Stream>> StreamFactories
|
||||||
{
|
{
|
||||||
get => this.factories;
|
get => this.factories;
|
||||||
set => this.factories = value ?? throw new ArgumentNullException(nameof(value));
|
set => this.factories =
|
||||||
|
value ?? throw new ArgumentNullException(nameof(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -102,7 +102,9 @@ public partial class WriteFiles : FileSystemOperationBase, IOperation
|
||||||
.ReadToEnd();
|
.ReadToEnd();
|
||||||
|
|
||||||
var stream = new MemoryStream();
|
var stream = new MemoryStream();
|
||||||
var writer = new StreamWriter(stream, this.TextEncoding ?? Encoding.UTF8);
|
var writer = new StreamWriter(
|
||||||
|
stream,
|
||||||
|
this.TextEncoding ?? Encoding.UTF8);
|
||||||
|
|
||||||
writer.Write(text);
|
writer.Write(text);
|
||||||
writer.Flush();
|
writer.Flush();
|
||||||
|
@ -133,7 +135,9 @@ public partial class WriteFiles : FileSystemOperationBase, IOperation
|
||||||
// First see if we have a factory for the exact type of content.
|
// First see if we have a factory for the exact type of content.
|
||||||
IContent content = entity.GetContent();
|
IContent content = entity.GetContent();
|
||||||
|
|
||||||
if (this.factories.TryGetValue(content.GetType(), out Func<IContent, Stream>? getStream))
|
if (this.factories.TryGetValue(
|
||||||
|
content.GetType(),
|
||||||
|
out Func<IContent, Stream>? getStream))
|
||||||
{
|
{
|
||||||
Stream stream = getStream(content);
|
Stream stream = getStream(content);
|
||||||
|
|
||||||
|
@ -143,7 +147,9 @@ public partial class WriteFiles : FileSystemOperationBase, IOperation
|
||||||
// If we have an easy conversion, then use that so we don't have to
|
// If we have an easy conversion, then use that so we don't have to
|
||||||
// walk up the tree looking for one we do have.
|
// walk up the tree looking for one we do have.
|
||||||
if (content is IBinaryContentConvertable binaryConvertable
|
if (content is IBinaryContentConvertable binaryConvertable
|
||||||
&& this.factories.TryGetValue(typeof(IBinaryContent), out Func<IContent, Stream>? binaryContent))
|
&& this.factories.TryGetValue(
|
||||||
|
typeof(IBinaryContent),
|
||||||
|
out Func<IContent, Stream>? binaryContent))
|
||||||
{
|
{
|
||||||
Stream stream = binaryContent(binaryConvertable.ToBinaryContent());
|
Stream stream = binaryContent(binaryConvertable.ToBinaryContent());
|
||||||
|
|
||||||
|
@ -151,7 +157,9 @@ public partial class WriteFiles : FileSystemOperationBase, IOperation
|
||||||
}
|
}
|
||||||
|
|
||||||
if (content is ITextContentConvertable textConvertable
|
if (content is ITextContentConvertable textConvertable
|
||||||
&& this.factories.TryGetValue(typeof(ITextContent), out Func<IContent, Stream>? textContent))
|
&& this.factories.TryGetValue(
|
||||||
|
typeof(ITextContent),
|
||||||
|
out Func<IContent, Stream>? textContent))
|
||||||
{
|
{
|
||||||
Stream stream = textContent(textConvertable.ToTextContent());
|
Stream stream = textContent(textConvertable.ToTextContent());
|
||||||
|
|
||||||
|
@ -167,7 +175,12 @@ public partial class WriteFiles : FileSystemOperationBase, IOperation
|
||||||
{
|
{
|
||||||
// Check to see if we have any of these types.
|
// Check to see if we have any of these types.
|
||||||
Func<IContent, Stream>? found = types
|
Func<IContent, Stream>? found = types
|
||||||
.Select(x => this.factories.TryGetValue(x, out Func<IContent, Stream>? factory) ? factory : null)
|
.Select(
|
||||||
|
x => this.factories.TryGetValue(
|
||||||
|
x,
|
||||||
|
out Func<IContent, Stream>? factory)
|
||||||
|
? factory
|
||||||
|
: null)
|
||||||
.FirstOrDefault(x => x != null);
|
.FirstOrDefault(x => x != null);
|
||||||
|
|
||||||
if (found != null)
|
if (found != null)
|
||||||
|
@ -179,7 +192,8 @@ public partial class WriteFiles : FileSystemOperationBase, IOperation
|
||||||
|
|
||||||
// We didn't find one, so add all the parent types and try
|
// We didn't find one, so add all the parent types and try
|
||||||
// again with the new list.
|
// again with the new list.
|
||||||
types = types.SelectMany(x => new[] { x.BaseType }.Union(x.GetInterfaces()))
|
types = types
|
||||||
|
.SelectMany(x => new[] { x.BaseType }.Union(x.GetInterfaces()))
|
||||||
.Where(x => x != null)
|
.Where(x => x != null)
|
||||||
.Select(x => x!)
|
.Select(x => x!)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
|
@ -71,7 +71,8 @@ public partial class ClearDirectory : FileSystemOperationBase, IOperation
|
||||||
|
|
||||||
// Clear out the contents.
|
// Clear out the contents.
|
||||||
IEnumerable<UPath> files = this.FileSystem.EnumerateFiles(path);
|
IEnumerable<UPath> files = this.FileSystem.EnumerateFiles(path);
|
||||||
IEnumerable<UPath> directories = this.FileSystem.EnumerateDirectories(path);
|
IEnumerable<UPath> directories =
|
||||||
|
this.FileSystem.EnumerateDirectories(path);
|
||||||
|
|
||||||
foreach (UPath file in files)
|
foreach (UPath file in files)
|
||||||
{
|
{
|
||||||
|
|
|
@ -8,17 +8,17 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Autofac" Version="6.4.0" />
|
<PackageReference Include="Autofac" Version="6.4.0"/>
|
||||||
<PackageReference Include="DotNet.Glob" Version="3.1.3" />
|
<PackageReference Include="DotNet.Glob" Version="3.1.3"/>
|
||||||
<PackageReference Include="FluentValidation" Version="11.2.1" />
|
<PackageReference Include="FluentValidation" Version="11.2.1"/>
|
||||||
<PackageReference Include="MfGames.Gallium" Version="0.3.0" />
|
<PackageReference Include="MfGames.Gallium" Version="0.3.0"/>
|
||||||
<PackageReference Include="MAB.DotIgnore" Version="3.0.2" />
|
<PackageReference Include="MAB.DotIgnore" Version="3.0.2"/>
|
||||||
<PackageReference Include="Serilog" Version="2.11.0" />
|
<PackageReference Include="Serilog" Version="2.11.0"/>
|
||||||
<PackageReference Include="Zio" Version="0.15.0" />
|
<PackageReference Include="Zio" Version="0.15.0"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\MfGames.Nitride\MfGames.Nitride.csproj" />
|
<ProjectReference Include="..\MfGames.Nitride\MfGames.Nitride.csproj"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<!-- Include the source generator -->
|
<!-- Include the source generator -->
|
||||||
|
|
|
@ -6,6 +6,7 @@ public static class NitrideIOBuilderExtensions
|
||||||
{
|
{
|
||||||
public static NitrideBuilder UseIO(this NitrideBuilder builder)
|
public static NitrideBuilder UseIO(this NitrideBuilder builder)
|
||||||
{
|
{
|
||||||
return builder.ConfigureContainer(x => x.RegisterModule<NitrideIOModule>());
|
return builder.ConfigureContainer(
|
||||||
|
x => x.RegisterModule<NitrideIOModule>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
using MfGames.Gallium;
|
|
||||||
|
|
||||||
using MAB.DotIgnore;
|
using MAB.DotIgnore;
|
||||||
|
|
||||||
|
using MfGames.Gallium;
|
||||||
|
|
||||||
using Zio;
|
using Zio;
|
||||||
|
|
||||||
namespace MfGames.Nitride.IO;
|
namespace MfGames.Nitride.IO;
|
||||||
|
|
|
@ -2,7 +2,8 @@ using FluentValidation;
|
||||||
|
|
||||||
namespace MfGames.Nitride.IO.Paths;
|
namespace MfGames.Nitride.IO.Paths;
|
||||||
|
|
||||||
public class ChangePathExtensionValidator : AbstractValidator<ChangePathExtension>
|
public class ChangePathExtensionValidator
|
||||||
|
: AbstractValidator<ChangePathExtension>
|
||||||
{
|
{
|
||||||
public ChangePathExtensionValidator()
|
public ChangePathExtensionValidator()
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,7 +3,6 @@ using System.Collections.Generic;
|
||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
|
|
||||||
using MfGames.Gallium;
|
using MfGames.Gallium;
|
||||||
|
|
||||||
using MfGames.Nitride.Entities;
|
using MfGames.Nitride.Entities;
|
||||||
|
|
||||||
using Zio;
|
using Zio;
|
||||||
|
@ -41,6 +40,8 @@ public partial class DirectChildPathScanner : EntityScanner
|
||||||
|
|
||||||
// If we are using directory indexes, skip when we have an index root.
|
// If we are using directory indexes, skip when we have an index root.
|
||||||
// Otherwise, get the parent and use that as the key.
|
// Otherwise, get the parent and use that as the key.
|
||||||
return path.GetDirectoryIndexPath() == "/" ? null : new[] { path.GetParentDirectoryIndexPath() };
|
return path.GetDirectoryIndexPath() == "/"
|
||||||
|
? null
|
||||||
|
: new[] { path.GetParentDirectoryIndexPath() };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ using System.Linq;
|
||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
|
|
||||||
using MfGames.Gallium;
|
using MfGames.Gallium;
|
||||||
|
|
||||||
using MfGames.Nitride.Entities;
|
using MfGames.Nitride.Entities;
|
||||||
|
|
||||||
using Serilog;
|
using Serilog;
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
|
|
@ -3,10 +3,9 @@ using System.Collections.Generic;
|
||||||
|
|
||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
|
|
||||||
using MfGames.Gallium;
|
|
||||||
|
|
||||||
using Markdig;
|
using Markdig;
|
||||||
|
|
||||||
|
using MfGames.Gallium;
|
||||||
using MfGames.Nitride.Contents;
|
using MfGames.Nitride.Contents;
|
||||||
|
|
||||||
namespace MfGames.Nitride.Markdown;
|
namespace MfGames.Nitride.Markdown;
|
||||||
|
|
|
@ -2,7 +2,8 @@ using FluentValidation;
|
||||||
|
|
||||||
namespace MfGames.Nitride.Markdown;
|
namespace MfGames.Nitride.Markdown;
|
||||||
|
|
||||||
public class ConvertMarkdownToBaseValidator : AbstractValidator<ConvertMarkdownToBase>
|
public class ConvertMarkdownToBaseValidator
|
||||||
|
: AbstractValidator<ConvertMarkdownToBase>
|
||||||
{
|
{
|
||||||
public ConvertMarkdownToBaseValidator()
|
public ConvertMarkdownToBaseValidator()
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,12 +2,10 @@ using System;
|
||||||
|
|
||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
|
|
||||||
using MfGames.Gallium;
|
|
||||||
|
|
||||||
using Markdig;
|
using Markdig;
|
||||||
|
|
||||||
|
using MfGames.Gallium;
|
||||||
using MfGames.Markdown.Gemtext;
|
using MfGames.Markdown.Gemtext;
|
||||||
|
|
||||||
using MfGames.Nitride.Contents;
|
using MfGames.Nitride.Contents;
|
||||||
using MfGames.Nitride.Gemtext;
|
using MfGames.Nitride.Gemtext;
|
||||||
|
|
||||||
|
@ -26,7 +24,8 @@ public class ConvertMarkdownToGemtext : ConvertMarkdownToBase
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override ConvertMarkdownToGemtext WithConfigureMarkdown(Action<MarkdownPipelineBuilder>? value)
|
public override ConvertMarkdownToGemtext WithConfigureMarkdown(
|
||||||
|
Action<MarkdownPipelineBuilder>? value)
|
||||||
{
|
{
|
||||||
base.WithConfigureMarkdown(value);
|
base.WithConfigureMarkdown(value);
|
||||||
|
|
||||||
|
|
|
@ -2,10 +2,9 @@ using System;
|
||||||
|
|
||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
|
|
||||||
using MfGames.Gallium;
|
|
||||||
|
|
||||||
using Markdig;
|
using Markdig;
|
||||||
|
|
||||||
|
using MfGames.Gallium;
|
||||||
using MfGames.Nitride.Contents;
|
using MfGames.Nitride.Contents;
|
||||||
using MfGames.Nitride.Html;
|
using MfGames.Nitride.Html;
|
||||||
|
|
||||||
|
@ -23,7 +22,8 @@ public class ConvertMarkdownToHtml : ConvertMarkdownToBase
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override ConvertMarkdownToHtml WithConfigureMarkdown(Action<MarkdownPipelineBuilder>? value)
|
public override ConvertMarkdownToHtml WithConfigureMarkdown(
|
||||||
|
Action<MarkdownPipelineBuilder>? value)
|
||||||
{
|
{
|
||||||
base.WithConfigureMarkdown(value);
|
base.WithConfigureMarkdown(value);
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@ using System.Collections.Generic;
|
||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
|
|
||||||
using MfGames.Gallium;
|
using MfGames.Gallium;
|
||||||
|
|
||||||
using MfGames.Nitride.Contents;
|
using MfGames.Nitride.Contents;
|
||||||
|
|
||||||
using Zio;
|
using Zio;
|
||||||
|
|
|
@ -18,11 +18,12 @@ public class IdentifyMarkdownFromPath : IdentifyMarkdown
|
||||||
Entity entity,
|
Entity entity,
|
||||||
UPath path)
|
UPath path)
|
||||||
{
|
{
|
||||||
return (path.GetExtensionWithDot() ?? string.Empty).ToLowerInvariant() switch
|
return (path.GetExtensionWithDot() ?? string.Empty).ToLowerInvariant()
|
||||||
{
|
switch
|
||||||
".md" => true,
|
{
|
||||||
".markdown" => true,
|
".md" => true,
|
||||||
_ => false,
|
".markdown" => true,
|
||||||
};
|
_ => false,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,9 +85,6 @@ public class MakeSingleLinkListItems : IOperation
|
||||||
match =>
|
match =>
|
||||||
{
|
{
|
||||||
string link1 = match.Groups["label"].ToString();
|
string link1 = match.Groups["label"].ToString();
|
||||||
string path1 = string.Format(
|
|
||||||
"/{0}/",
|
|
||||||
this.slugs.ToSlug(link1.Split('|').First()));
|
|
||||||
string label1 = link1.Split('|').Last();
|
string label1 = link1.Split('|').Last();
|
||||||
|
|
||||||
return label1;
|
return label1;
|
||||||
|
|
|
@ -10,17 +10,17 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\MfGames.Nitride.Gemtext\MfGames.Nitride.Gemtext.csproj" />
|
<ProjectReference Include="..\MfGames.Nitride.Gemtext\MfGames.Nitride.Gemtext.csproj"/>
|
||||||
<ProjectReference Include="..\MfGames.Nitride.Html\MfGames.Nitride.Html.csproj" />
|
<ProjectReference Include="..\MfGames.Nitride.Html\MfGames.Nitride.Html.csproj"/>
|
||||||
<ProjectReference Include="..\MfGames.Nitride.Slugs\MfGames.Nitride.Slugs.csproj" />
|
<ProjectReference Include="..\MfGames.Nitride.Slugs\MfGames.Nitride.Slugs.csproj"/>
|
||||||
<ProjectReference Include="..\MfGames.Nitride\MfGames.Nitride.csproj" />
|
<ProjectReference Include="..\MfGames.Nitride\MfGames.Nitride.csproj"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="MfGames.Gallium" Version="0.3.0" />
|
<PackageReference Include="MfGames.Gallium" Version="0.3.0"/>
|
||||||
<PackageReference Include="Markdig" Version="0.30.3" />
|
<PackageReference Include="Markdig" Version="0.30.3"/>
|
||||||
<PackageReference Include="MfGames.Markdown.Gemtext" Version="1.2.2" />
|
<PackageReference Include="MfGames.Markdown.Gemtext" Version="1.2.2"/>
|
||||||
<PackageReference Include="Zio" Version="0.15.0" />
|
<PackageReference Include="Zio" Version="0.15.0"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<!-- Include the source generator -->
|
<!-- Include the source generator -->
|
||||||
|
|
|
@ -6,6 +6,7 @@ public static class NitrideMarkdownBuilderExtensions
|
||||||
{
|
{
|
||||||
public static NitrideBuilder UseMarkdown(this NitrideBuilder builder)
|
public static NitrideBuilder UseMarkdown(this NitrideBuilder builder)
|
||||||
{
|
{
|
||||||
return builder.ConfigureContainer(x => x.RegisterModule<NitrideMarkdownModule>());
|
return builder.ConfigureContainer(
|
||||||
|
x => x.RegisterModule<NitrideMarkdownModule>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,8 @@ public class SimpleSlugConverter : ISlugConverter, IEnumerable<string>
|
||||||
|
|
||||||
public SimpleSlugConverter(
|
public SimpleSlugConverter(
|
||||||
IDictionary<string, string> replacements,
|
IDictionary<string, string> replacements,
|
||||||
StringComparison comparison = StringComparison.InvariantCultureIgnoreCase)
|
StringComparison comparison =
|
||||||
|
StringComparison.InvariantCultureIgnoreCase)
|
||||||
: this()
|
: this()
|
||||||
{
|
{
|
||||||
foreach (KeyValuePair<string, string> pair in replacements)
|
foreach (KeyValuePair<string, string> pair in replacements)
|
||||||
|
@ -44,7 +45,8 @@ public class SimpleSlugConverter : ISlugConverter, IEnumerable<string>
|
||||||
public void Add(
|
public void Add(
|
||||||
string search,
|
string search,
|
||||||
string replace,
|
string replace,
|
||||||
StringComparison comparison = StringComparison.InvariantCultureIgnoreCase)
|
StringComparison comparison =
|
||||||
|
StringComparison.InvariantCultureIgnoreCase)
|
||||||
{
|
{
|
||||||
this.replacements.Add((search, replace, comparison));
|
this.replacements.Add((search, replace, comparison));
|
||||||
}
|
}
|
||||||
|
@ -62,12 +64,15 @@ public class SimpleSlugConverter : ISlugConverter, IEnumerable<string>
|
||||||
// If we have null or whitespace, we have a problem.
|
// If we have null or whitespace, we have a problem.
|
||||||
if (string.IsNullOrWhiteSpace(input))
|
if (string.IsNullOrWhiteSpace(input))
|
||||||
{
|
{
|
||||||
throw new ArgumentException("Cannot have a blank or null input", nameof(input));
|
throw new ArgumentException(
|
||||||
|
"Cannot have a blank or null input",
|
||||||
|
nameof(input));
|
||||||
}
|
}
|
||||||
|
|
||||||
// We need to do the replacements before we slugify.
|
// We need to do the replacements before we slugify.
|
||||||
// Perform any additional replacements.
|
// Perform any additional replacements.
|
||||||
foreach ((string search, string replace, StringComparison comparison) in this.replacements)
|
foreach ((string search, string replace, StringComparison comparison) in
|
||||||
|
this.replacements)
|
||||||
{
|
{
|
||||||
input = input.Replace(search, replace, comparison);
|
input = input.Replace(search, replace, comparison);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,8 @@ public class UnicodeNormalizingSlugConverter : SimpleSlugConverter
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public UnicodeNormalizingSlugConverter(IDictionary<string, string> replacements)
|
public UnicodeNormalizingSlugConverter(
|
||||||
|
IDictionary<string, string> replacements)
|
||||||
: base(replacements)
|
: base(replacements)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -29,7 +30,9 @@ public class UnicodeNormalizingSlugConverter : SimpleSlugConverter
|
||||||
// If we have null or whitespace, we have a problem.
|
// If we have null or whitespace, we have a problem.
|
||||||
if (string.IsNullOrWhiteSpace(input))
|
if (string.IsNullOrWhiteSpace(input))
|
||||||
{
|
{
|
||||||
throw new ArgumentException("Cannot have a blank or null input", nameof(input));
|
throw new ArgumentException(
|
||||||
|
"Cannot have a blank or null input",
|
||||||
|
nameof(input));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Normalize the Unicode objects.
|
// Normalize the Unicode objects.
|
||||||
|
@ -38,7 +41,8 @@ public class UnicodeNormalizingSlugConverter : SimpleSlugConverter
|
||||||
.Where(this.IsNonSpacingMark)
|
.Where(this.IsNonSpacingMark)
|
||||||
.ToArray();
|
.ToArray();
|
||||||
|
|
||||||
string normalized = new string(chars).Normalize(NormalizationForm.FormC);
|
string normalized =
|
||||||
|
new string(chars).Normalize(NormalizationForm.FormC);
|
||||||
|
|
||||||
// Return the base implementation.
|
// Return the base implementation.
|
||||||
return base.ToSlug(normalized);
|
return base.ToSlug(normalized);
|
||||||
|
|
|
@ -44,14 +44,16 @@ public class DatePipelineCommandOption : IPipelineCommandOption
|
||||||
{
|
{
|
||||||
// If we got a date, then use NodaTime's fake clock to set it so
|
// If we got a date, then use NodaTime's fake clock to set it so
|
||||||
// everything will use that.
|
// everything will use that.
|
||||||
var value = (DateTime?)context.ParseResult.GetValueForOption(this.Option);
|
var value =
|
||||||
|
(DateTime?)context.ParseResult.GetValueForOption(this.Option);
|
||||||
|
|
||||||
if (value.HasValue && value.Value != DateTime.MinValue)
|
if (value.HasValue && value.Value != DateTime.MinValue)
|
||||||
{
|
{
|
||||||
// We have a date, so we need to create a fake clock that has this
|
// We have a date, so we need to create a fake clock that has this
|
||||||
// date for the entire run.
|
// date for the entire run.
|
||||||
var local = LocalDateTime.FromDateTime(value.Value);
|
var local = LocalDateTime.FromDateTime(value.Value);
|
||||||
ZonedDateTime zoned = local.InZoneStrictly(this.timekeeper.DateTimeZone);
|
ZonedDateTime zoned =
|
||||||
|
local.InZoneStrictly(this.timekeeper.DateTimeZone);
|
||||||
var instant = zoned.ToInstant();
|
var instant = zoned.ToInstant();
|
||||||
|
|
||||||
this.timekeeper.Clock = new FakeClock(instant);
|
this.timekeeper.Clock = new FakeClock(instant);
|
||||||
|
|
|
@ -32,7 +32,8 @@ public class ExpiresPipelineCommandOption : IPipelineCommandOption
|
||||||
|
|
||||||
this.Option = new Option<string?>("--expires", () => defaultValue)
|
this.Option = new Option<string?>("--expires", () => defaultValue)
|
||||||
{
|
{
|
||||||
Description = "Sets the expiration time as time before the current date",
|
Description =
|
||||||
|
"Sets the expiration time as time before the current date",
|
||||||
ArgumentHelpName = "TIMESPAN",
|
ArgumentHelpName = "TIMESPAN",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -46,7 +47,8 @@ public class ExpiresPipelineCommandOption : IPipelineCommandOption
|
||||||
// If we have a format, then we are going to set one. If the format
|
// If we have a format, then we are going to set one. If the format
|
||||||
// is blank or never, then we are going to treat it as not
|
// is blank or never, then we are going to treat it as not
|
||||||
// expiring anything.
|
// expiring anything.
|
||||||
string? value = (string?)context.ParseResult.GetValueForOption(this.Option);
|
string? value =
|
||||||
|
(string?)context.ParseResult.GetValueForOption(this.Option);
|
||||||
|
|
||||||
if (value != null && value.ToLowerInvariant() != "never")
|
if (value != null && value.ToLowerInvariant() != "never")
|
||||||
{
|
{
|
||||||
|
@ -65,7 +67,9 @@ public class ExpiresPipelineCommandOption : IPipelineCommandOption
|
||||||
// Figure out when we are going to be expiring.
|
// Figure out when we are going to be expiring.
|
||||||
Instant when = this.clock.Expiration.Value;
|
Instant when = this.clock.Expiration.Value;
|
||||||
ZonedDateTime dateTime = when.InZone(this.clock.DateTimeZone);
|
ZonedDateTime dateTime = when.InZone(this.clock.DateTimeZone);
|
||||||
string formatted = dateTime.ToString("yyyy-MM-dd HH:mm:ss x", CultureInfo.CurrentCulture);
|
string formatted = dateTime.ToString(
|
||||||
|
"yyyy-MM-dd HH:mm:ss x",
|
||||||
|
CultureInfo.CurrentCulture);
|
||||||
|
|
||||||
this.logger.Information("Expiring entries before {When:l}", formatted);
|
this.logger.Information("Expiring entries before {When:l}", formatted);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,21 +10,6 @@ using NodaTime;
|
||||||
|
|
||||||
namespace MfGames.Nitride.Temporal;
|
namespace MfGames.Nitride.Temporal;
|
||||||
|
|
||||||
public class CreateDateIndexesValidator : AbstractValidator<CreateDateIndexes>
|
|
||||||
{
|
|
||||||
public CreateDateIndexesValidator()
|
|
||||||
{
|
|
||||||
this.RuleFor(a => a.Timekeeper)
|
|
||||||
.NotNull();
|
|
||||||
|
|
||||||
this.RuleFor(a => a.CreateIndex)
|
|
||||||
.NotNull();
|
|
||||||
|
|
||||||
this.RuleFor(a => a.Formats)
|
|
||||||
.NotNull();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructs indexes for any arbitrary formatting of date time to allow for
|
/// Constructs indexes for any arbitrary formatting of date time to allow for
|
||||||
/// nested structures. This takes a list
|
/// nested structures. This takes a list
|
||||||
|
@ -116,17 +101,24 @@ public partial class CreateDateIndexes : OperationBase, IResolvingOperation
|
||||||
|
|
||||||
// The new entities are going to always be added, but if the new + seen is <= the threshold, we'll be
|
// The new entities are going to always be added, but if the new + seen is <= the threshold, we'll be
|
||||||
// including both of them.
|
// including both of them.
|
||||||
List<Entity>? childEntities = (newEntities.Count + seenEntities.Count) <= this.LessThanEqualCollapse
|
List<Entity>? childEntities =
|
||||||
? pair.Value
|
(newEntities.Count + seenEntities.Count)
|
||||||
: newEntities;
|
<= this.LessThanEqualCollapse
|
||||||
|
? pair.Value
|
||||||
|
: newEntities;
|
||||||
|
|
||||||
// Figure out which child indexes need to be included. If there isn't a list, then return an empty one.
|
// Figure out which child indexes need to be included. If there isn't a list, then return an empty one.
|
||||||
List<Entity>? childIndexes = indexes.TryGetValue(pair.Key, out List<Entity>? list)
|
List<Entity>? childIndexes =
|
||||||
? list
|
indexes.TryGetValue(pair.Key, out List<Entity>? list)
|
||||||
: new List<Entity>();
|
? list
|
||||||
|
: new List<Entity>();
|
||||||
|
|
||||||
// Create the index then add it to the output list.
|
// Create the index then add it to the output list.
|
||||||
var index = new DateIndex(pair.Key, this.Formats[i], childEntities, childIndexes);
|
var index = new DateIndex(
|
||||||
|
pair.Key,
|
||||||
|
this.Formats[i],
|
||||||
|
childEntities,
|
||||||
|
childIndexes);
|
||||||
Entity? indexEntity = this.CreateIndex!(index);
|
Entity? indexEntity = this.CreateIndex!(index);
|
||||||
|
|
||||||
output.Add(indexEntity);
|
output.Add(indexEntity);
|
||||||
|
@ -140,7 +132,8 @@ public partial class CreateDateIndexes : OperationBase, IResolvingOperation
|
||||||
|
|
||||||
Entity? first = pair.Value[0];
|
Entity? first = pair.Value[0];
|
||||||
|
|
||||||
string? nextKey = this.Timekeeper.ToDateTime(first.Get<Instant>())
|
string? nextKey = this.Timekeeper
|
||||||
|
.ToDateTime(first.Get<Instant>())
|
||||||
.ToString(this.Formats[i + 1]);
|
.ToString(this.Formats[i + 1]);
|
||||||
|
|
||||||
if (!indexes.ContainsKey(nextKey))
|
if (!indexes.ContainsKey(nextKey))
|
||||||
|
@ -176,7 +169,7 @@ public partial class CreateDateIndexes : OperationBase, IResolvingOperation
|
||||||
string? formatted = dateTime.ToString(this.Formats[i]);
|
string? formatted = dateTime.ToString(this.Formats[i]);
|
||||||
|
|
||||||
if (!grouped[i]
|
if (!grouped[i]
|
||||||
.ContainsKey(formatted))
|
.ContainsKey(formatted))
|
||||||
{
|
{
|
||||||
grouped[i][formatted] = new List<Entity>();
|
grouped[i][formatted] = new List<Entity>();
|
||||||
}
|
}
|
||||||
|
|
18
src/MfGames.Nitride.Temporal/CreateDateIndexesValidator.cs
Normal file
18
src/MfGames.Nitride.Temporal/CreateDateIndexesValidator.cs
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
using FluentValidation;
|
||||||
|
|
||||||
|
namespace MfGames.Nitride.Temporal;
|
||||||
|
|
||||||
|
public class CreateDateIndexesValidator : AbstractValidator<CreateDateIndexes>
|
||||||
|
{
|
||||||
|
public CreateDateIndexesValidator()
|
||||||
|
{
|
||||||
|
this.RuleFor(a => a.Timekeeper)
|
||||||
|
.NotNull();
|
||||||
|
|
||||||
|
this.RuleFor(a => a.CreateIndex)
|
||||||
|
.NotNull();
|
||||||
|
|
||||||
|
this.RuleFor(a => a.Formats)
|
||||||
|
.NotNull();
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,7 +2,8 @@ using FluentValidation;
|
||||||
|
|
||||||
namespace MfGames.Nitride.Temporal;
|
namespace MfGames.Nitride.Temporal;
|
||||||
|
|
||||||
public class FilterOutExpiredInstantValidator : AbstractValidator<FilterOutExpiredInstant>
|
public class FilterOutExpiredInstantValidator
|
||||||
|
: AbstractValidator<FilterOutExpiredInstant>
|
||||||
{
|
{
|
||||||
public FilterOutExpiredInstantValidator()
|
public FilterOutExpiredInstantValidator()
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,7 +2,8 @@ using FluentValidation;
|
||||||
|
|
||||||
namespace MfGames.Nitride.Temporal;
|
namespace MfGames.Nitride.Temporal;
|
||||||
|
|
||||||
public class FilterOutFutureInstantValidator : AbstractValidator<FilterOutFutureInstant>
|
public class FilterOutFutureInstantValidator
|
||||||
|
: AbstractValidator<FilterOutFutureInstant>
|
||||||
{
|
{
|
||||||
public FilterOutFutureInstantValidator()
|
public FilterOutFutureInstantValidator()
|
||||||
{
|
{
|
||||||
|
|
|
@ -11,18 +11,18 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Autofac" Version="6.4.0" />
|
<PackageReference Include="Autofac" Version="6.4.0"/>
|
||||||
<PackageReference Include="MfGames.Gallium" Version="0.3.0" />
|
<PackageReference Include="MfGames.Gallium" Version="0.3.0"/>
|
||||||
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="6.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="6.0.0"/>
|
||||||
<PackageReference Include="NodaTime" Version="3.1.2" />
|
<PackageReference Include="NodaTime" Version="3.1.2"/>
|
||||||
<PackageReference Include="NodaTime.Testing" Version="3.1.2" />
|
<PackageReference Include="NodaTime.Testing" Version="3.1.2"/>
|
||||||
<PackageReference Include="Serilog" Version="2.11.0" />
|
<PackageReference Include="Serilog" Version="2.11.0"/>
|
||||||
<PackageReference Include="TimeSpanParserUtil" Version="1.2.0" />
|
<PackageReference Include="TimeSpanParserUtil" Version="1.2.0"/>
|
||||||
<PackageReference Include="Zio" Version="0.15.0" />
|
<PackageReference Include="Zio" Version="0.15.0"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\MfGames.Nitride\MfGames.Nitride.csproj" />
|
<ProjectReference Include="..\MfGames.Nitride\MfGames.Nitride.csproj"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<!-- Include the source generator -->
|
<!-- Include the source generator -->
|
||||||
|
|
|
@ -7,8 +7,6 @@ using MfGames.Nitride.Temporal.Cli;
|
||||||
|
|
||||||
using Serilog;
|
using Serilog;
|
||||||
|
|
||||||
using Expires = MfGames.Nitride.Temporal.Cli.ExpiresPipelineCommandOption;
|
|
||||||
|
|
||||||
namespace MfGames.Nitride.Temporal;
|
namespace MfGames.Nitride.Temporal;
|
||||||
|
|
||||||
public static class NitrideTemporalBuilderExtensions
|
public static class NitrideTemporalBuilderExtensions
|
||||||
|
@ -40,15 +38,20 @@ public static class NitrideTemporalBuilderExtensions
|
||||||
.As<IPipelineCommandOption>();
|
.As<IPipelineCommandOption>();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.AddExpireOptionToCommandLine && config.Expiration != null)
|
if (config.AddExpireOptionToCommandLine
|
||||||
|
&& config.Expiration != null)
|
||||||
{
|
{
|
||||||
x.Register(
|
x.Register(
|
||||||
context =>
|
context =>
|
||||||
{
|
{
|
||||||
ILogger logger = context.Resolve<ILogger>();
|
ILogger logger = context.Resolve<ILogger>();
|
||||||
Timekeeper clock = context.Resolve<Timekeeper>();
|
Timekeeper
|
||||||
|
clock = context.Resolve<Timekeeper>();
|
||||||
|
|
||||||
return new Expires(logger, clock, config.Expiration);
|
return new ExpiresPipelineCommandOption(
|
||||||
|
logger,
|
||||||
|
clock,
|
||||||
|
config.Expiration);
|
||||||
})
|
})
|
||||||
.As<IPipelineCommandOption>();
|
.As<IPipelineCommandOption>();
|
||||||
}
|
}
|
||||||
|
@ -65,7 +68,9 @@ public static class NitrideTemporalBuilderExtensions
|
||||||
Timekeeper timekeeper = scope.Resolve<Timekeeper>();
|
Timekeeper timekeeper = scope.Resolve<Timekeeper>();
|
||||||
|
|
||||||
timekeeper.DateTimeZone = config.DateTimeZone;
|
timekeeper.DateTimeZone = config.DateTimeZone;
|
||||||
logger.Verbose("Setting time zone to {Zone:l}", timekeeper.DateTimeZone);
|
logger.Verbose(
|
||||||
|
"Setting time zone to {Zone:l}",
|
||||||
|
timekeeper.DateTimeZone);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,8 @@ public partial class NitrideTemporalConfiguration
|
||||||
/// such
|
/// such
|
||||||
/// as "500000:00:00.0".
|
/// as "500000:00:00.0".
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public NitrideTemporalConfiguration WithExpiresCommandLineOption(TimeSpan? timeSpan)
|
public NitrideTemporalConfiguration WithExpiresCommandLineOption(
|
||||||
|
TimeSpan? timeSpan)
|
||||||
{
|
{
|
||||||
return this.WithExpiresCommandLineOption(timeSpan?.ToString());
|
return this.WithExpiresCommandLineOption(timeSpan?.ToString());
|
||||||
}
|
}
|
||||||
|
@ -54,7 +55,8 @@ public partial class NitrideTemporalConfiguration
|
||||||
/// "XXX" is a format like "5y" or "500000:00:00.0". This is parsed by
|
/// "XXX" is a format like "5y" or "500000:00:00.0". This is parsed by
|
||||||
/// TimeSpanParser which gives an easy format.
|
/// TimeSpanParser which gives an easy format.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public NitrideTemporalConfiguration WithExpiresCommandLineOption(string? defaultValue)
|
public NitrideTemporalConfiguration WithExpiresCommandLineOption(
|
||||||
|
string? defaultValue)
|
||||||
{
|
{
|
||||||
this.AddExpireOptionToCommandLine = defaultValue != null;
|
this.AddExpireOptionToCommandLine = defaultValue != null;
|
||||||
this.Expiration = defaultValue;
|
this.Expiration = defaultValue;
|
||||||
|
|
|
@ -50,7 +50,8 @@ public class SetInstantFromComponent<TComponent> : OperationBase
|
||||||
/// into an Instant automatically. This can handle DateTime,
|
/// into an Instant automatically. This can handle DateTime,
|
||||||
/// DateTimeOffset, LocalDate, and Instant. Nulls are skipped.
|
/// DateTimeOffset, LocalDate, and Instant. Nulls are skipped.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public SetInstantFromComponent<TComponent> WithGetDateTimeObject(Func<Entity, TComponent, object?>? callback)
|
public SetInstantFromComponent<TComponent> WithGetDateTimeObject(
|
||||||
|
Func<Entity, TComponent, object?>? callback)
|
||||||
{
|
{
|
||||||
this.GetDateTimeObject = callback;
|
this.GetDateTimeObject = callback;
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,8 @@ using FluentValidation;
|
||||||
|
|
||||||
namespace MfGames.Nitride.Temporal;
|
namespace MfGames.Nitride.Temporal;
|
||||||
|
|
||||||
public class SetInstantFromComponentValidator<TComponent> : AbstractValidator<SetInstantFromComponent<TComponent>>
|
public class SetInstantFromComponentValidator
|
||||||
|
<TComponent> : AbstractValidator<SetInstantFromComponent<TComponent>>
|
||||||
{
|
{
|
||||||
public SetInstantFromComponentValidator()
|
public SetInstantFromComponentValidator()
|
||||||
{
|
{
|
||||||
|
|
|
@ -31,7 +31,8 @@ public partial class SetInstantFromPath : OperationBase
|
||||||
{
|
{
|
||||||
this.validator = validator;
|
this.validator = validator;
|
||||||
this.clock = clock;
|
this.clock = clock;
|
||||||
this.PathRegex = new Regex(@"(?<year>\d{4})[/-](?<month>\d{2})[/-](?<day>\d{2})");
|
this.PathRegex = new Regex(
|
||||||
|
@"(?<year>\d{4})[/-](?<month>\d{2})[/-](?<day>\d{2})");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -10,12 +10,12 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\MfGames.Nitride\MfGames.Nitride.csproj" />
|
<ProjectReference Include="..\MfGames.Nitride\MfGames.Nitride.csproj"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="MfGames.Gallium" Version="0.3.0" />
|
<PackageReference Include="MfGames.Gallium" Version="0.3.0"/>
|
||||||
<PackageReference Include="YamlDotNet" Version="12.0.0" />
|
<PackageReference Include="YamlDotNet" Version="12.0.0"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<!-- Include the source generator -->
|
<!-- Include the source generator -->
|
||||||
|
|
|
@ -6,6 +6,7 @@ public static class NitrideYamlBuilderExtensions
|
||||||
{
|
{
|
||||||
public static NitrideBuilder UseYaml(this NitrideBuilder builder)
|
public static NitrideBuilder UseYaml(this NitrideBuilder builder)
|
||||||
{
|
{
|
||||||
return builder.ConfigureContainer(x => x.RegisterModule<NitrideYamlModule>());
|
return builder.ConfigureContainer(
|
||||||
|
x => x.RegisterModule<NitrideYamlModule>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
using MfGames.Gallium;
|
using MfGames.Gallium;
|
||||||
|
|
||||||
using MfGames.Nitride.Contents;
|
using MfGames.Nitride.Contents;
|
||||||
|
|
||||||
using YamlDotNet.Serialization;
|
using YamlDotNet.Serialization;
|
||||||
|
|
|
@ -4,7 +4,6 @@ using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
using MfGames.Gallium;
|
using MfGames.Gallium;
|
||||||
|
|
||||||
using MfGames.Nitride.Contents;
|
using MfGames.Nitride.Contents;
|
||||||
|
|
||||||
using YamlDotNet.Serialization;
|
using YamlDotNet.Serialization;
|
||||||
|
@ -31,7 +30,8 @@ public class ParseYamlHeader<TModel> : OperationBase
|
||||||
this.RemoveHeader = true;
|
this.RemoveHeader = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Func<Entity, string, Exception, ParseYamlHeaderErrorHandling>? EntityError { get; set; }
|
public Func<Entity, string, Exception, ParseYamlHeaderErrorHandling>?
|
||||||
|
EntityError { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets a value indicating whether the header should be removed
|
/// Gets or sets a value indicating whether the header should be removed
|
||||||
|
@ -43,7 +43,9 @@ public class ParseYamlHeader<TModel> : OperationBase
|
||||||
public override IEnumerable<Entity> Run(IEnumerable<Entity> input)
|
public override IEnumerable<Entity> Run(IEnumerable<Entity> input)
|
||||||
{
|
{
|
||||||
// Set up the YAML parsing.
|
// Set up the YAML parsing.
|
||||||
DeserializerBuilder builder = new DeserializerBuilder().WithNamingConvention(this.namingConvention);
|
DeserializerBuilder builder =
|
||||||
|
new DeserializerBuilder().WithNamingConvention(
|
||||||
|
this.namingConvention);
|
||||||
|
|
||||||
if (this.ignoreUnmatchedProperties)
|
if (this.ignoreUnmatchedProperties)
|
||||||
{
|
{
|
||||||
|
@ -62,7 +64,8 @@ public class ParseYamlHeader<TModel> : OperationBase
|
||||||
content) => this.Parse(entity, content, deserializer));
|
content) => this.Parse(entity, content, deserializer));
|
||||||
}
|
}
|
||||||
|
|
||||||
public ParseYamlHeader<TModel> WithEntityError(Func<Entity, string, Exception, ParseYamlHeaderErrorHandling>? value)
|
public ParseYamlHeader<TModel> WithEntityError(
|
||||||
|
Func<Entity, string, Exception, ParseYamlHeaderErrorHandling>? value)
|
||||||
{
|
{
|
||||||
this.EntityError = value;
|
this.EntityError = value;
|
||||||
|
|
||||||
|
@ -157,7 +160,8 @@ public class ParseYamlHeader<TModel> : OperationBase
|
||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
{
|
{
|
||||||
ParseYamlHeaderErrorHandling disposition = this.EntityError?.Invoke(entity, yaml, exception)
|
ParseYamlHeaderErrorHandling disposition =
|
||||||
|
this.EntityError?.Invoke(entity, yaml, exception)
|
||||||
?? ParseYamlHeaderErrorHandling.Throw;
|
?? ParseYamlHeaderErrorHandling.Throw;
|
||||||
|
|
||||||
if (disposition == ParseYamlHeaderErrorHandling.Ignore)
|
if (disposition == ParseYamlHeaderErrorHandling.Ignore)
|
||||||
|
|
|
@ -49,7 +49,9 @@ public class BuildCommand : Command, ICommandHandler
|
||||||
public async Task<int> InvokeAsync(InvocationContext context)
|
public async Task<int> InvokeAsync(InvocationContext context)
|
||||||
{
|
{
|
||||||
// Process any injected options.
|
// Process any injected options.
|
||||||
this.logger.Debug("Processing {Count:N0} pipeline options", this.pipelineOptions.Count);
|
this.logger.Debug(
|
||||||
|
"Processing {Count:N0} pipeline options",
|
||||||
|
this.pipelineOptions.Count);
|
||||||
|
|
||||||
foreach (IPipelineCommandOption? option in this.pipelineOptions)
|
foreach (IPipelineCommandOption? option in this.pipelineOptions)
|
||||||
{
|
{
|
||||||
|
|
|
@ -28,7 +28,11 @@ public class FileBinaryContent : IBinaryContent, ITextContentConvertable
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public Stream GetStream()
|
public Stream GetStream()
|
||||||
{
|
{
|
||||||
return File.Open(this.path, FileMode.Open, FileAccess.Read, FileShare.Read);
|
return File.Open(
|
||||||
|
this.path,
|
||||||
|
FileMode.Open,
|
||||||
|
FileAccess.Read,
|
||||||
|
FileShare.Read);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
|
|
@ -29,7 +29,13 @@ public class FileTextContent : ITextContent, IBinaryContentConvertable
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public TextReader GetReader()
|
public TextReader GetReader()
|
||||||
{
|
{
|
||||||
return new StreamReader(File.Open(this.path, FileMode.Open, FileAccess.Read, FileShare.Read), Encoding.UTF8);
|
return new StreamReader(
|
||||||
|
File.Open(
|
||||||
|
this.path,
|
||||||
|
FileMode.Open,
|
||||||
|
FileAccess.Read,
|
||||||
|
FileShare.Read),
|
||||||
|
Encoding.UTF8);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
|
|
@ -41,7 +41,8 @@ public partial class CreateOrUpdateIndex : OperationBase
|
||||||
/// index that has been already created. If this is null, no new indexes
|
/// index that has been already created. If this is null, no new indexes
|
||||||
/// will be made.
|
/// will be made.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Func<string, IList<Entity>, Entity>? CreateIndex { get; set; } = null!;
|
public Func<string, IList<Entity>, Entity>? CreateIndex { get; set; } =
|
||||||
|
null!;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the function to retrieve the key from an existing
|
/// Gets or sets the function to retrieve the key from an existing
|
||||||
|
@ -58,7 +59,11 @@ public partial class CreateOrUpdateIndex : OperationBase
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Updates an existing index entity to include new information.
|
/// Updates an existing index entity to include new information.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Func<Entity, string, IEnumerable<Entity>, Entity> UpdateIndex { get; set; } = null!;
|
public Func<Entity, string, IEnumerable<Entity>, Entity> UpdateIndex
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
} = null!;
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override IEnumerable<Entity> Run(IEnumerable<Entity> input)
|
public override IEnumerable<Entity> Run(IEnumerable<Entity> input)
|
||||||
|
@ -89,7 +94,9 @@ public partial class CreateOrUpdateIndex : OperationBase
|
||||||
{
|
{
|
||||||
// This is an existing entity page that needs to be updated.
|
// This is an existing entity page that needs to be updated.
|
||||||
IEnumerable<Entity> entries =
|
IEnumerable<Entity> entries =
|
||||||
scanned.TryGetValue(key, out List<Entity>? list) ? list : Array.Empty<Entity>();
|
scanned.TryGetValue(key, out List<Entity>? list)
|
||||||
|
? list
|
||||||
|
: Array.Empty<Entity>();
|
||||||
|
|
||||||
existing.Add(key);
|
existing.Add(key);
|
||||||
|
|
||||||
|
@ -100,7 +107,8 @@ public partial class CreateOrUpdateIndex : OperationBase
|
||||||
// Once we're done with the list, we need to create the missing indexes.
|
// Once we're done with the list, we need to create the missing indexes.
|
||||||
if (this.CreateIndex != null)
|
if (this.CreateIndex != null)
|
||||||
{
|
{
|
||||||
foreach (string key in scanned.Keys.Where(key => !existing.Contains(key)))
|
foreach (string key in scanned.Keys.Where(
|
||||||
|
key => !existing.Contains(key)))
|
||||||
{
|
{
|
||||||
yield return this.CreateIndex(key, scanned[key]);
|
yield return this.CreateIndex(key, scanned[key]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,8 @@ using FluentValidation;
|
||||||
|
|
||||||
namespace MfGames.Nitride.Entities;
|
namespace MfGames.Nitride.Entities;
|
||||||
|
|
||||||
public class CreateOrUpdateIndexValidator : AbstractValidator<CreateOrUpdateIndex>
|
public class CreateOrUpdateIndexValidator
|
||||||
|
: AbstractValidator<CreateOrUpdateIndex>
|
||||||
{
|
{
|
||||||
public CreateOrUpdateIndexValidator()
|
public CreateOrUpdateIndexValidator()
|
||||||
{
|
{
|
||||||
|
|
|
@ -39,7 +39,8 @@ public partial class EntityScanner : OperationBase
|
||||||
/// Gets or sets a callback function that gets the keys associated with
|
/// Gets or sets a callback function that gets the keys associated with
|
||||||
/// the given entity.
|
/// the given entity.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Func<Entity, IEnumerable<string>?> GetKeysFromEntity { get; set; } = null!;
|
public Func<Entity, IEnumerable<string>?> GetKeysFromEntity { get; set; } =
|
||||||
|
null!;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the list of entities associated with the given key. if the key has not
|
/// Gets the list of entities associated with the given key. if the key has not
|
||||||
|
@ -106,7 +107,8 @@ public partial class EntityScanner : OperationBase
|
||||||
{
|
{
|
||||||
// Scan the given entity and see where it needs to be included.
|
// Scan the given entity and see where it needs to be included.
|
||||||
// The entity is added to each of the keys returned by this class.
|
// The entity is added to each of the keys returned by this class.
|
||||||
IEnumerable<string>? keysFromEntity = this.GetKeysFromEntity(entity);
|
IEnumerable<string>? keysFromEntity =
|
||||||
|
this.GetKeysFromEntity(entity);
|
||||||
|
|
||||||
if (keysFromEntity != null)
|
if (keysFromEntity != null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,11 +25,13 @@ public class EntitySequence
|
||||||
|
|
||||||
public bool IsFirst => this.Sequence.Count > 0 && this.Index == 0;
|
public bool IsFirst => this.Sequence.Count > 0 && this.Index == 0;
|
||||||
|
|
||||||
public bool IsLast => this.Sequence.Count > 0 && this.Index == this.Sequence.Count - 1;
|
public bool IsLast => this.Sequence.Count > 0
|
||||||
|
&& this.Index == this.Sequence.Count - 1;
|
||||||
|
|
||||||
public Entity? Next => this.HasNext ? this.Sequence[this.Index + 1] : null;
|
public Entity? Next => this.HasNext ? this.Sequence[this.Index + 1] : null;
|
||||||
|
|
||||||
public Entity? Previous => this.HasPrevious ? this.Sequence[this.Index - 1] : null;
|
public Entity? Previous =>
|
||||||
|
this.HasPrevious ? this.Sequence[this.Index - 1] : null;
|
||||||
|
|
||||||
public IReadOnlyList<Entity> Sequence { get; }
|
public IReadOnlyList<Entity> Sequence { get; }
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,11 @@ public partial class LinkEntitySequence : OperationBase, IResolvingOperation
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the function used to create the sequence index.
|
/// Gets or sets the function used to create the sequence index.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Func<IReadOnlyList<Entity>, int, EntitySequence> CreateSequenceIndex { get; set; }
|
public Func<IReadOnlyList<Entity>, int, EntitySequence> CreateSequenceIndex
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override IEnumerable<Entity> Run(IEnumerable<Entity> input)
|
public override IEnumerable<Entity> Run(IEnumerable<Entity> input)
|
||||||
|
@ -56,7 +60,9 @@ public partial class LinkEntitySequence : OperationBase, IResolvingOperation
|
||||||
for (int i = 0; i < list.Count; i++)
|
for (int i = 0; i < list.Count; i++)
|
||||||
{
|
{
|
||||||
Entity entity = list[i];
|
Entity entity = list[i];
|
||||||
EntitySequence index = this.CreateSequenceIndex(list.AsReadOnly(), i);
|
EntitySequence index = this.CreateSequenceIndex(
|
||||||
|
list.AsReadOnly(),
|
||||||
|
i);
|
||||||
|
|
||||||
yield return this.AddSequenceIndex(entity, index);
|
yield return this.AddSequenceIndex(entity, index);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,12 +10,14 @@ namespace MfGames.Nitride;
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class ExpressionHelper
|
public static class ExpressionHelper
|
||||||
{
|
{
|
||||||
public static string GetMemberName<T>(Expression<Func<T, object?>> expression)
|
public static string GetMemberName<T>(
|
||||||
|
Expression<Func<T, object?>> expression)
|
||||||
{
|
{
|
||||||
return GetMemberName(expression.Body);
|
return GetMemberName(expression.Body);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IEnumerable<string> GetMemberNames<T>(params Expression<Func<T, object?>>[] expressions)
|
public static IEnumerable<string> GetMemberNames<T>(
|
||||||
|
params Expression<Func<T, object?>>[] expressions)
|
||||||
{
|
{
|
||||||
return expressions.Select(x => GetMemberName(x.Body));
|
return expressions.Select(x => GetMemberName(x.Body));
|
||||||
}
|
}
|
||||||
|
@ -54,7 +56,8 @@ public static class ExpressionHelper
|
||||||
|
|
||||||
private static string GetMemberName(UnaryExpression unaryExpression)
|
private static string GetMemberName(UnaryExpression unaryExpression)
|
||||||
{
|
{
|
||||||
if (unaryExpression.Operand is MethodCallExpression methodCallExpression)
|
if (unaryExpression.Operand is MethodCallExpression
|
||||||
|
methodCallExpression)
|
||||||
{
|
{
|
||||||
return methodCallExpression.Method.Name;
|
return methodCallExpression.Method.Name;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,22 +15,22 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Autofac" Version="6.4.0" />
|
<PackageReference Include="Autofac" Version="6.4.0"/>
|
||||||
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="8.0.0" />
|
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="8.0.0"/>
|
||||||
<PackageReference Include="FluentValidation" Version="11.2.1" />
|
<PackageReference Include="FluentValidation" Version="11.2.1"/>
|
||||||
<PackageReference Include="MfGames.Gallium" Version="0.3.0" />
|
<PackageReference Include="MfGames.Gallium" Version="0.3.0"/>
|
||||||
<PackageReference Include="Humanizer.Core" Version="2.14.1" />
|
<PackageReference Include="Humanizer.Core" Version="2.14.1"/>
|
||||||
<PackageReference Include="MfGames.ToolBuilder" Version="1.0.0" />
|
<PackageReference Include="MfGames.ToolBuilder" Version="1.0.0"/>
|
||||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.1" />
|
<PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.1"/>
|
||||||
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="6.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="6.0.0"/>
|
||||||
<PackageReference Include="Serilog" Version="2.11.0" />
|
<PackageReference Include="Serilog" Version="2.11.0"/>
|
||||||
<PackageReference Include="Serilog.Extensions.Autofac.DependencyInjection" Version="5.0.0" />
|
<PackageReference Include="Serilog.Extensions.Autofac.DependencyInjection" Version="5.0.0"/>
|
||||||
<PackageReference Include="Serilog.Extensions.Hosting" Version="5.0.1" />
|
<PackageReference Include="Serilog.Extensions.Hosting" Version="5.0.1"/>
|
||||||
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
|
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0"/>
|
||||||
<PackageReference Include="SerilogAnalyzer" Version="0.15.0" />
|
<PackageReference Include="SerilogAnalyzer" Version="0.15.0"/>
|
||||||
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
|
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1"/>
|
||||||
<PackageReference Include="System.Linq.Async" Version="6.0.1" />
|
<PackageReference Include="System.Linq.Async" Version="6.0.1"/>
|
||||||
<PackageReference Include="Zio" Version="0.15.0" />
|
<PackageReference Include="Zio" Version="0.15.0"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<!-- Include the source generator -->
|
<!-- Include the source generator -->
|
||||||
|
|
|
@ -32,14 +32,16 @@ public class NitrideBuilder
|
||||||
/// An event that is called after the container is built but before
|
/// An event that is called after the container is built but before
|
||||||
/// the application runs.
|
/// the application runs.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly List<Action<NitrideBuilder, ILifetimeScope>> configureSiteCallbacks;
|
private readonly List<Action<NitrideBuilder, ILifetimeScope>>
|
||||||
|
configureSiteCallbacks;
|
||||||
|
|
||||||
private readonly NitrideModule nitrideModule;
|
private readonly NitrideModule nitrideModule;
|
||||||
|
|
||||||
public NitrideBuilder(string[] arguments)
|
public NitrideBuilder(string[] arguments)
|
||||||
{
|
{
|
||||||
this.arguments = arguments;
|
this.arguments = arguments;
|
||||||
this.configureSiteCallbacks = new List<Action<NitrideBuilder, ILifetimeScope>>();
|
this.configureSiteCallbacks =
|
||||||
|
new List<Action<NitrideBuilder, ILifetimeScope>>();
|
||||||
this.configureContainerCallbacks = new List<Action<ContainerBuilder>>();
|
this.configureContainerCallbacks = new List<Action<ContainerBuilder>>();
|
||||||
this.nitrideModule = new NitrideModule();
|
this.nitrideModule = new NitrideModule();
|
||||||
|
|
||||||
|
@ -74,7 +76,8 @@ public class NitrideBuilder
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="callback">The callback to register.</param>
|
/// <param name="callback">The callback to register.</param>
|
||||||
/// <returns>The builder for chaining.</returns>
|
/// <returns>The builder for chaining.</returns>
|
||||||
public NitrideBuilder ConfigureSite(Action<NitrideBuilder, ILifetimeScope> callback)
|
public NitrideBuilder ConfigureSite(
|
||||||
|
Action<NitrideBuilder, ILifetimeScope> callback)
|
||||||
{
|
{
|
||||||
this.configureSiteCallbacks.Add(callback);
|
this.configureSiteCallbacks.Add(callback);
|
||||||
|
|
||||||
|
@ -173,12 +176,14 @@ public class NitrideBuilder
|
||||||
this.RegisterRootDirectory(Log.Logger, builder);
|
this.RegisterRootDirectory(Log.Logger, builder);
|
||||||
|
|
||||||
// Finish up the registration by running our events.
|
// Finish up the registration by running our events.
|
||||||
foreach (Action<NitrideBuilder, ILifetimeScope>? callback in this.configureSiteCallbacks)
|
foreach (Action<NitrideBuilder, ILifetimeScope>? callback in this
|
||||||
|
.configureSiteCallbacks)
|
||||||
{
|
{
|
||||||
builder.RegisterBuildCallback(scope => callback(this, scope));
|
builder.RegisterBuildCallback(scope => callback(this, scope));
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (Action<ContainerBuilder>? configureContainer in this.configureContainerCallbacks)
|
foreach (Action<ContainerBuilder>? configureContainer in this
|
||||||
|
.configureContainerCallbacks)
|
||||||
{
|
{
|
||||||
configureContainer.Invoke(builder);
|
configureContainer.Invoke(builder);
|
||||||
}
|
}
|
||||||
|
@ -195,10 +200,14 @@ public class NitrideBuilder
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.Debug("Setting root directory to {Path}", this.RootDirectory.FullName);
|
logger.Debug(
|
||||||
|
"Setting root directory to {Path}",
|
||||||
|
this.RootDirectory.FullName);
|
||||||
|
|
||||||
var rootFileSystem = new PhysicalFileSystem();
|
var rootFileSystem = new PhysicalFileSystem();
|
||||||
var subFileSystem = new SubFileSystem(rootFileSystem, this.RootDirectory.FullName);
|
var subFileSystem = new SubFileSystem(
|
||||||
|
rootFileSystem,
|
||||||
|
this.RootDirectory.FullName);
|
||||||
|
|
||||||
builder.RegisterInstance(subFileSystem)
|
builder.RegisterInstance(subFileSystem)
|
||||||
.As<IFileSystem>()
|
.As<IFileSystem>()
|
||||||
|
|
|
@ -59,7 +59,8 @@ public class NitrideModule : Module
|
||||||
;
|
;
|
||||||
|
|
||||||
// Add in the commands.
|
// Add in the commands.
|
||||||
IEnumerable<Command> commands = c.Resolve<IEnumerable<Command>>();
|
IEnumerable<Command> commands =
|
||||||
|
c.Resolve<IEnumerable<Command>>();
|
||||||
|
|
||||||
foreach (Command command in commands)
|
foreach (Command command in commands)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
using MfGames.Gallium;
|
using MfGames.Gallium;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
using MfGames.Gallium;
|
using MfGames.Gallium;
|
||||||
|
|
||||||
|
@ -31,7 +30,8 @@ public abstract class PipelineBase : IPipeline
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public abstract IAsyncEnumerable<Entity> RunAsync(IEnumerable<Entity> entities);
|
public abstract IAsyncEnumerable<Entity> RunAsync(
|
||||||
|
IEnumerable<Entity> entities);
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
|
|
|
@ -40,7 +40,8 @@ public class PipelineManager
|
||||||
public ICollection<IPipeline> Pipelines
|
public ICollection<IPipeline> Pipelines
|
||||||
{
|
{
|
||||||
get => this.pipelines;
|
get => this.pipelines;
|
||||||
set => this.pipelines = value ?? throw new ArgumentNullException(nameof(value));
|
set => this.pipelines =
|
||||||
|
value ?? throw new ArgumentNullException(nameof(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -60,9 +61,12 @@ public class PipelineManager
|
||||||
|
|
||||||
// Go through all the entries and start each one. We gather the
|
// Go through all the entries and start each one. We gather the
|
||||||
// resulting tasks and then wait for all of them to end.
|
// resulting tasks and then wait for all of them to end.
|
||||||
this.logger.Verbose("Starting {Count:l}", "pipeline".ToQuantity(this.pipelines.Count));
|
this.logger.Verbose(
|
||||||
|
"Starting {Count:l}",
|
||||||
|
"pipeline".ToQuantity(this.pipelines.Count));
|
||||||
|
|
||||||
Task[] tasks = this.entries.Select(x => Task.Run(async () => await x.RunAsync()))
|
Task[] tasks = this.entries
|
||||||
|
.Select(x => Task.Run(async () => await x.RunAsync()))
|
||||||
.ToArray();
|
.ToArray();
|
||||||
|
|
||||||
var report = TimeSpan.FromSeconds(15);
|
var report = TimeSpan.FromSeconds(15);
|
||||||
|
@ -72,13 +76,17 @@ public class PipelineManager
|
||||||
var waiting = this.entries.Where(x => !x.IsFinished)
|
var waiting = this.entries.Where(x => !x.IsFinished)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
this.logger.Debug("Waiting for {Count:l} to finish running", "pipeline".ToQuantity(waiting.Count));
|
this.logger.Debug(
|
||||||
|
"Waiting for {Count:l} to finish running",
|
||||||
|
"pipeline".ToQuantity(waiting.Count));
|
||||||
|
|
||||||
IOrderedEnumerable<IGrouping<PipelineRunnerState, PipelineRunner>> states =
|
IOrderedEnumerable<IGrouping<PipelineRunnerState, PipelineRunner>>
|
||||||
waiting.GroupBy(x => x.State, x => x)
|
states =
|
||||||
.OrderBy(x => (int)x.Key);
|
waiting.GroupBy(x => x.State, x => x)
|
||||||
|
.OrderBy(x => (int)x.Key);
|
||||||
|
|
||||||
foreach (IGrouping<PipelineRunnerState, PipelineRunner>? state in states)
|
foreach (IGrouping<PipelineRunnerState, PipelineRunner>? state in
|
||||||
|
states)
|
||||||
{
|
{
|
||||||
var statePipelines = state.OrderBy(x => x.Pipeline.ToString())
|
var statePipelines = state.OrderBy(x => x.Pipeline.ToString())
|
||||||
.ToList();
|
.ToList();
|
||||||
|
@ -90,15 +98,20 @@ public class PipelineManager
|
||||||
string.Join(
|
string.Join(
|
||||||
", ",
|
", ",
|
||||||
state.Key == PipelineRunnerState.Started
|
state.Key == PipelineRunnerState.Started
|
||||||
? statePipelines.Select(x => $"{x.Pipeline} ({x.ElapsedFromState})")
|
? statePipelines.Select(
|
||||||
: statePipelines.Select(x => x.Pipeline.ToString())));
|
x => $"{x.Pipeline} ({x.ElapsedFromState})")
|
||||||
|
: statePipelines.Select(
|
||||||
|
x => x.Pipeline.ToString())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Figure out our return code.
|
// Figure out our return code.
|
||||||
bool hasErrors = this.entries.Any(x => x.State == PipelineRunnerState.Errored);
|
bool hasErrors =
|
||||||
|
this.entries.Any(x => x.State == PipelineRunnerState.Errored);
|
||||||
|
|
||||||
this.logger.Information("Completed in {Elapsed}", DateTime.UtcNow - started);
|
this.logger.Information(
|
||||||
|
"Completed in {Elapsed}",
|
||||||
|
DateTime.UtcNow - started);
|
||||||
|
|
||||||
return Task.FromResult(hasErrors ? 2 : 0);
|
return Task.FromResult(hasErrors ? 2 : 0);
|
||||||
}
|
}
|
||||||
|
@ -119,12 +132,15 @@ public class PipelineManager
|
||||||
if (this.pipelines.Count == 0)
|
if (this.pipelines.Count == 0)
|
||||||
{
|
{
|
||||||
this.logger.Error(
|
this.logger.Error(
|
||||||
"There are no registered pipelines run, use" + " ConfigureContainer to include IPipeline instances");
|
"There are no registered pipelines run, use"
|
||||||
|
+ " ConfigureContainer to include IPipeline instances");
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.logger.Verbose("Setting up {Count:l}", "pipeline".ToQuantity(this.pipelines.Count));
|
this.logger.Verbose(
|
||||||
|
"Setting up {Count:l}",
|
||||||
|
"pipeline".ToQuantity(this.pipelines.Count));
|
||||||
|
|
||||||
// Wrap all the pipelines into entries. We do this before the next
|
// Wrap all the pipelines into entries. We do this before the next
|
||||||
// step so we can have the entries depend on the entries.
|
// step so we can have the entries depend on the entries.
|
||||||
|
@ -140,7 +156,8 @@ public class PipelineManager
|
||||||
foreach (IPipeline? dependency in dependencies)
|
foreach (IPipeline? dependency in dependencies)
|
||||||
{
|
{
|
||||||
// Get the entry for the dependency.
|
// Get the entry for the dependency.
|
||||||
PipelineRunner dependencyPipeline = this.entries.Single(x => x.Pipeline == dependency);
|
PipelineRunner dependencyPipeline =
|
||||||
|
this.entries.Single(x => x.Pipeline == dependency);
|
||||||
|
|
||||||
// Set up the bi-directional connection.
|
// Set up the bi-directional connection.
|
||||||
entry.Incoming.Add(dependencyPipeline);
|
entry.Incoming.Add(dependencyPipeline);
|
||||||
|
|
|
@ -4,10 +4,10 @@ using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
using MfGames.Gallium;
|
|
||||||
|
|
||||||
using Humanizer;
|
using Humanizer;
|
||||||
|
|
||||||
|
using MfGames.Gallium;
|
||||||
|
|
||||||
using Serilog;
|
using Serilog;
|
||||||
|
|
||||||
namespace MfGames.Nitride.Pipelines;
|
namespace MfGames.Nitride.Pipelines;
|
||||||
|
@ -50,7 +50,8 @@ public class PipelineRunner
|
||||||
ILogger logger,
|
ILogger logger,
|
||||||
IPipeline pipeline)
|
IPipeline pipeline)
|
||||||
{
|
{
|
||||||
this.Pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline));
|
this.Pipeline =
|
||||||
|
pipeline ?? throw new ArgumentNullException(nameof(pipeline));
|
||||||
this.Incoming = new List<PipelineRunner>();
|
this.Incoming = new List<PipelineRunner>();
|
||||||
this.Outgoing = new List<PipelineRunner>();
|
this.Outgoing = new List<PipelineRunner>();
|
||||||
this.Outputs = new List<Entity>();
|
this.Outputs = new List<Entity>();
|
||||||
|
@ -84,7 +85,8 @@ public class PipelineRunner
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a value indicating whether this pipeline is done running.
|
/// Gets a value indicating whether this pipeline is done running.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsFinished => this.State is PipelineRunnerState.Finalized or PipelineRunnerState.Errored;
|
public bool IsFinished => this.State is PipelineRunnerState.Finalized
|
||||||
|
or PipelineRunnerState.Errored;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a value indicating whether this entry is a starting one
|
/// Gets a value indicating whether this entry is a starting one
|
||||||
|
@ -123,7 +125,10 @@ public class PipelineRunner
|
||||||
{
|
{
|
||||||
int current = Interlocked.Decrement(ref this.waitingOnConsumers);
|
int current = Interlocked.Decrement(ref this.waitingOnConsumers);
|
||||||
|
|
||||||
this.logger.Verbose("{Pipeline:l}: Consumer signalled, waiting for {Count:n0}", this.Pipeline, current);
|
this.logger.Verbose(
|
||||||
|
"{Pipeline:l}: Consumer signalled, waiting for {Count:n0}",
|
||||||
|
this.Pipeline,
|
||||||
|
current);
|
||||||
|
|
||||||
if (current == 0)
|
if (current == 0)
|
||||||
{
|
{
|
||||||
|
@ -205,7 +210,10 @@ public class PipelineRunner
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
{
|
{
|
||||||
// Report the exception.
|
// Report the exception.
|
||||||
this.logger.Error(exception, "{Pipeline:l}: There was an exception running pipeline", this.Pipeline);
|
this.logger.Error(
|
||||||
|
exception,
|
||||||
|
"{Pipeline:l}: There was an exception running pipeline",
|
||||||
|
this.Pipeline);
|
||||||
|
|
||||||
// Change our state and then release any pipeline waiting for us
|
// Change our state and then release any pipeline waiting for us
|
||||||
// so they can pick up the error and fail themselves.
|
// so they can pick up the error and fail themselves.
|
||||||
|
@ -287,7 +295,9 @@ public class PipelineRunner
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure our internal wait for the consumers it set.
|
// Make sure our internal wait for the consumers it set.
|
||||||
this.logger.Verbose("{Pipeline:l}: Setting up internal thread controls", this.Pipeline);
|
this.logger.Verbose(
|
||||||
|
"{Pipeline:l}: Setting up internal thread controls",
|
||||||
|
this.Pipeline);
|
||||||
this.waitingOnConsumers = this.Outgoing.Count;
|
this.waitingOnConsumers = this.Outgoing.Count;
|
||||||
this.consumersDone.Reset();
|
this.consumersDone.Reset();
|
||||||
|
|
||||||
|
@ -300,7 +310,9 @@ public class PipelineRunner
|
||||||
|
|
||||||
// Release our manual reset to allow operations to continue.
|
// Release our manual reset to allow operations to continue.
|
||||||
this.ChangeState(PipelineRunnerState.Providing);
|
this.ChangeState(PipelineRunnerState.Providing);
|
||||||
this.logger.Verbose("{Pipeline:l}: Release manual reset for consumers", this.Pipeline);
|
this.logger.Verbose(
|
||||||
|
"{Pipeline:l}: Release manual reset for consumers",
|
||||||
|
this.Pipeline);
|
||||||
this.blockDependencies.Set();
|
this.blockDependencies.Set();
|
||||||
|
|
||||||
// Wait until all consumers have finished processing.
|
// Wait until all consumers have finished processing.
|
||||||
|
@ -316,7 +328,10 @@ public class PipelineRunner
|
||||||
|
|
||||||
this.signaledDoneWithInputs = true;
|
this.signaledDoneWithInputs = true;
|
||||||
|
|
||||||
this.logger.Debug("{Pipeline:l}: Signaling {Count:n0} dependencies done", this.Pipeline, this.Incoming.Count);
|
this.logger.Debug(
|
||||||
|
"{Pipeline:l}: Signaling {Count:n0} dependencies done",
|
||||||
|
this.Pipeline,
|
||||||
|
this.Incoming.Count);
|
||||||
|
|
||||||
foreach (PipelineRunner? dependency in this.Incoming)
|
foreach (PipelineRunner? dependency in this.Incoming)
|
||||||
{
|
{
|
||||||
|
@ -346,14 +361,17 @@ public class PipelineRunner
|
||||||
|
|
||||||
// Check for any error state in the dependency, if we have one,
|
// Check for any error state in the dependency, if we have one,
|
||||||
// then we need to stop ourselves.
|
// then we need to stop ourselves.
|
||||||
bool hasError = this.Incoming.Any(x => x.State == PipelineRunnerState.Errored);
|
bool hasError =
|
||||||
|
this.Incoming.Any(x => x.State == PipelineRunnerState.Errored);
|
||||||
|
|
||||||
if (!hasError)
|
if (!hasError)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.logger.Error("{Pipeline:l}: There was an exception in an dependency", this.Pipeline);
|
this.logger.Error(
|
||||||
|
"{Pipeline:l}: There was an exception in an dependency",
|
||||||
|
this.Pipeline);
|
||||||
this.ChangeState(PipelineRunnerState.Errored);
|
this.ChangeState(PipelineRunnerState.Errored);
|
||||||
this.blockDependencies.Set();
|
this.blockDependencies.Set();
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ A pipeline implements the `IPipeline` interface or extends the convenience
|
||||||
class `Pipeline`.
|
class `Pipeline`.
|
||||||
|
|
||||||
```c#
|
```c#
|
||||||
using Nitride.Pipelines;
|
using MfGames.Nitride.Pipelines;
|
||||||
|
|
||||||
public class LoadFilesPipeline : Pipeline {}
|
public class LoadFilesPipeline : Pipeline {}
|
||||||
```
|
```
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -6,22 +6,22 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\..\src\MfGames.Nitride.IO\MfGames.Nitride.IO.csproj" />
|
<ProjectReference Include="..\..\src\MfGames.Nitride.IO\MfGames.Nitride.IO.csproj"/>
|
||||||
<ProjectReference Include="..\MfGames.Nitride.Tests\MfGames.Nitride.Tests.csproj" />
|
<ProjectReference Include="..\MfGames.Nitride.Tests\MfGames.Nitride.Tests.csproj"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="CompareNETObjects" Version="4.78.0" />
|
<PackageReference Include="CompareNETObjects" Version="4.78.0"/>
|
||||||
<PackageReference Include="MfGames.Gallium" Version="0.3.0" />
|
<PackageReference Include="MfGames.Gallium" Version="0.3.0"/>
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.1" />
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.1"/>
|
||||||
<PackageReference Include="JunitXml.TestLogger" Version="3.0.114" />
|
<PackageReference Include="JunitXml.TestLogger" Version="3.0.114"/>
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.1"/>
|
||||||
<PackageReference Include="xunit" Version="2.4.2" />
|
<PackageReference Include="xunit" Version="2.4.2"/>
|
||||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
|
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Zio" Version="0.15.0" />
|
<PackageReference Include="Zio" Version="0.15.0"/>
|
||||||
<PackageReference Include="coverlet.collector" Version="3.1.2">
|
<PackageReference Include="coverlet.collector" Version="3.1.2">
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
|
|
@ -8,7 +8,7 @@ using Xunit.Abstractions;
|
||||||
|
|
||||||
using Zio;
|
using Zio;
|
||||||
|
|
||||||
namespace MfGames.Nitride.IO.Tests;
|
namespace MfGames.Nitride.IO.Tests.Paths;
|
||||||
|
|
||||||
public class AddPathPrefixTest : NitrideIOTestBase
|
public class AddPathPrefixTest : NitrideIOTestBase
|
||||||
{
|
{
|
||||||
|
@ -36,9 +36,10 @@ public class AddPathPrefixTest : NitrideIOTestBase
|
||||||
.WithPathPrefix("/prefix");
|
.WithPathPrefix("/prefix");
|
||||||
|
|
||||||
// Read and replace the paths.
|
// Read and replace the paths.
|
||||||
IOrderedEnumerable<string> output = readFiles.WithPattern("/**")
|
IOrderedEnumerable<string> output = NitrideOperationExtensions.Run(
|
||||||
.Run()
|
readFiles.WithPattern("/**")
|
||||||
.Run(op)
|
.Run(),
|
||||||
|
op)
|
||||||
.Select(
|
.Select(
|
||||||
x => x.Get<UPath>()
|
x => x.Get<UPath>()
|
||||||
.ToString())
|
.ToString())
|
||||||
|
|
|
@ -10,7 +10,7 @@ using Xunit.Abstractions;
|
||||||
|
|
||||||
using Zio;
|
using Zio;
|
||||||
|
|
||||||
namespace MfGames.Nitride.IO.Tests;
|
namespace MfGames.Nitride.IO.Tests.Paths;
|
||||||
|
|
||||||
public class DirectChildPathScannerTests : NitrideIOTestBase
|
public class DirectChildPathScannerTests : NitrideIOTestBase
|
||||||
{
|
{
|
||||||
|
@ -45,9 +45,10 @@ public class DirectChildPathScannerTests : NitrideIOTestBase
|
||||||
DirectChildPathScanner op = context.Resolve<DirectChildPathScanner>();
|
DirectChildPathScanner op = context.Resolve<DirectChildPathScanner>();
|
||||||
|
|
||||||
// Read and replace the paths.
|
// Read and replace the paths.
|
||||||
var _ = readFiles.WithPattern("/**")
|
var _ = NitrideOperationExtensions.Run(
|
||||||
.Run()
|
readFiles.WithPattern("/**")
|
||||||
.Run(op)
|
.Run(),
|
||||||
|
op)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
KeyValuePair<string, string[]>[] actual = op.GetScannedResults()
|
KeyValuePair<string, string[]>[] actual = op.GetScannedResults()
|
||||||
|
@ -64,9 +65,15 @@ public class DirectChildPathScannerTests : NitrideIOTestBase
|
||||||
// Verify the results.
|
// Verify the results.
|
||||||
KeyValuePair<string, string[]>[] expected = new[]
|
KeyValuePair<string, string[]>[] expected = new[]
|
||||||
{
|
{
|
||||||
new KeyValuePair<string, string[]>("/", new[] { "/a/index.md", "/b/index.md" }),
|
new KeyValuePair<string, string[]>(
|
||||||
new KeyValuePair<string, string[]>("/a/", new[] { "/a/c/index.md", "/a/d/index.md" }),
|
"/",
|
||||||
new KeyValuePair<string, string[]>("/a/d/", new[] { "/a/d/e/index.md" }),
|
new[] { "/a/index.md", "/b/index.md" }),
|
||||||
|
new KeyValuePair<string, string[]>(
|
||||||
|
"/a/",
|
||||||
|
new[] { "/a/c/index.md", "/a/d/index.md" }),
|
||||||
|
new KeyValuePair<string, string[]>(
|
||||||
|
"/a/d/",
|
||||||
|
new[] { "/a/d/e/index.md" }),
|
||||||
};
|
};
|
||||||
|
|
||||||
TestHelper.CompareObjects(expected, actual);
|
TestHelper.CompareObjects(expected, actual);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
using MfGames.Gallium;
|
using MfGames.Gallium;
|
||||||
|
|
||||||
using MfGames.Nitride.IO.Contents;
|
using MfGames.Nitride.IO.Contents;
|
||||||
|
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
@ -9,7 +9,7 @@ using Xunit.Abstractions;
|
||||||
|
|
||||||
using Zio;
|
using Zio;
|
||||||
|
|
||||||
namespace MfGames.Nitride.IO.Tests;
|
namespace MfGames.Nitride.IO.Tests.Paths;
|
||||||
|
|
||||||
public class GetEntityByPathTests : NitrideIOTestBase
|
public class GetEntityByPathTests : NitrideIOTestBase
|
||||||
{
|
{
|
||||||
|
@ -34,9 +34,12 @@ public class GetEntityByPathTests : NitrideIOTestBase
|
||||||
ReadFiles readFiles = context.Resolve<ReadFiles>();
|
ReadFiles readFiles = context.Resolve<ReadFiles>();
|
||||||
|
|
||||||
// Read and replace the paths.
|
// Read and replace the paths.
|
||||||
IOrderedEnumerable<string> output = readFiles.WithPattern("/**")
|
IOrderedEnumerable<string> output = NitrideIOEnumerableEntityExtensions
|
||||||
.Run()
|
.GetEntityByPath(
|
||||||
.GetEntityByPath("/c1.md", out Entity? found)
|
readFiles.WithPattern("/**")
|
||||||
|
.Run(),
|
||||||
|
"/c1.md",
|
||||||
|
out Entity? found)
|
||||||
.Select(
|
.Select(
|
||||||
x => x.Get<UPath>()
|
x => x.Get<UPath>()
|
||||||
.ToString())
|
.ToString())
|
||||||
|
@ -70,9 +73,13 @@ public class GetEntityByPathTests : NitrideIOTestBase
|
||||||
ReadFiles readFiles = context.Resolve<ReadFiles>();
|
ReadFiles readFiles = context.Resolve<ReadFiles>();
|
||||||
|
|
||||||
// Read and replace the paths.
|
// Read and replace the paths.
|
||||||
IOrderedEnumerable<string> output = readFiles.WithPattern("/**")
|
IOrderedEnumerable<string> output = NitrideIOEnumerableEntityExtensions
|
||||||
.Run()
|
.GetEntityByPath(
|
||||||
.GetEntityByPath("/c1.md", out Entity? found, IfFoundOutput.ReturnInOutput)
|
(IEnumerable<Entity>)readFiles.WithPattern("/**")
|
||||||
|
.Run(),
|
||||||
|
(UPath)"/c1.md",
|
||||||
|
out Entity? found,
|
||||||
|
(IfFoundOutput)IfFoundOutput.ReturnInOutput)
|
||||||
.Select(
|
.Select(
|
||||||
x => x.Get<UPath>()
|
x => x.Get<UPath>()
|
||||||
.ToString())
|
.ToString())
|
||||||
|
@ -107,9 +114,12 @@ public class GetEntityByPathTests : NitrideIOTestBase
|
||||||
ReadFiles readFiles = context.Resolve<ReadFiles>();
|
ReadFiles readFiles = context.Resolve<ReadFiles>();
|
||||||
|
|
||||||
// Read and replace the paths.
|
// Read and replace the paths.
|
||||||
IOrderedEnumerable<string> output = readFiles.WithPattern("/**")
|
IOrderedEnumerable<string> output = NitrideIOEnumerableEntityExtensions
|
||||||
.Run()
|
.GetEntityByPath(
|
||||||
.GetEntityByPath("/not-found.md", out Entity? found)
|
readFiles.WithPattern("/**")
|
||||||
|
.Run(),
|
||||||
|
"/not-found.md",
|
||||||
|
out Entity? found)
|
||||||
.Select(
|
.Select(
|
||||||
x => x.Get<UPath>()
|
x => x.Get<UPath>()
|
||||||
.ToString())
|
.ToString())
|
||||||
|
|
|
@ -11,7 +11,7 @@ using Xunit.Abstractions;
|
||||||
|
|
||||||
using Zio;
|
using Zio;
|
||||||
|
|
||||||
namespace MfGames.Nitride.IO.Tests;
|
namespace MfGames.Nitride.IO.Tests.Paths;
|
||||||
|
|
||||||
public class LinkDirectChildrenTests : NitrideIOTestBase
|
public class LinkDirectChildrenTests : NitrideIOTestBase
|
||||||
{
|
{
|
||||||
|
@ -43,15 +43,17 @@ public class LinkDirectChildrenTests : NitrideIOTestBase
|
||||||
|
|
||||||
// Set up the operation.
|
// Set up the operation.
|
||||||
ReadFiles readFiles = context.Resolve<ReadFiles>();
|
ReadFiles readFiles = context.Resolve<ReadFiles>();
|
||||||
DirectChildPathScanner scanner = context.Resolve<DirectChildPathScanner>();
|
DirectChildPathScanner scanner =
|
||||||
|
context.Resolve<DirectChildPathScanner>();
|
||||||
|
|
||||||
CreateOrUpdateIndex op = context.Resolve<LinkDirectChildren>()
|
CreateOrUpdateIndex op = context.Resolve<LinkDirectChildren>()
|
||||||
.WithScanner(scanner);
|
.WithScanner(scanner);
|
||||||
|
|
||||||
// Read and replace the paths.
|
// Read and replace the paths.
|
||||||
Tuple<string, string[]?>[]? actual = readFiles.WithPattern("/**")
|
Tuple<string, string[]?>[]? actual = NitrideOperationExtensions.Run(
|
||||||
.Run()
|
readFiles.WithPattern("/**")
|
||||||
.Run(scanner)
|
.Run(),
|
||||||
|
scanner)
|
||||||
.ToList()
|
.ToList()
|
||||||
.Run(op)
|
.Run(op)
|
||||||
.Select(
|
.Select(
|
||||||
|
@ -72,10 +74,16 @@ public class LinkDirectChildrenTests : NitrideIOTestBase
|
||||||
{
|
{
|
||||||
new Tuple<string, string[]?>("/a/c/index.md", new string[] { }),
|
new Tuple<string, string[]?>("/a/c/index.md", new string[] { }),
|
||||||
new Tuple<string, string[]?>("/a/d/e/index.md", new string[] { }),
|
new Tuple<string, string[]?>("/a/d/e/index.md", new string[] { }),
|
||||||
new Tuple<string, string[]?>("/a/d/index.md", new[] { "/a/d/e/index.md" }),
|
new Tuple<string, string[]?>(
|
||||||
new Tuple<string, string[]?>("/a/index.md", new[] { "/a/c/index.md", "/a/d/index.md" }),
|
"/a/d/index.md",
|
||||||
|
new[] { "/a/d/e/index.md" }),
|
||||||
|
new Tuple<string, string[]?>(
|
||||||
|
"/a/index.md",
|
||||||
|
new[] { "/a/c/index.md", "/a/d/index.md" }),
|
||||||
new Tuple<string, string[]?>("/b/index.md", new string[] { }),
|
new Tuple<string, string[]?>("/b/index.md", new string[] { }),
|
||||||
new Tuple<string, string[]?>("/index.md", new[] { "/a/index.md", "/b/index.md" }),
|
new Tuple<string, string[]?>(
|
||||||
|
"/index.md",
|
||||||
|
new[] { "/a/index.md", "/b/index.md" }),
|
||||||
};
|
};
|
||||||
|
|
||||||
TestHelper.CompareObjects(expected, actual);
|
TestHelper.CompareObjects(expected, actual);
|
||||||
|
|
|
@ -8,7 +8,7 @@ using Xunit.Abstractions;
|
||||||
|
|
||||||
using Zio;
|
using Zio;
|
||||||
|
|
||||||
namespace MfGames.Nitride.IO.Tests;
|
namespace MfGames.Nitride.IO.Tests.Paths;
|
||||||
|
|
||||||
public class MoveToIndexPathsTest : NitrideIOTestBase
|
public class MoveToIndexPathsTest : NitrideIOTestBase
|
||||||
{
|
{
|
||||||
|
@ -30,9 +30,10 @@ public class MoveToIndexPathsTest : NitrideIOTestBase
|
||||||
MoveToIndexPath op = context.Resolve<MoveToIndexPath>();
|
MoveToIndexPath op = context.Resolve<MoveToIndexPath>();
|
||||||
|
|
||||||
// Read and replace the paths.
|
// Read and replace the paths.
|
||||||
IOrderedEnumerable<string> output = readFiles.WithPattern("/**")
|
IOrderedEnumerable<string> output = NitrideOperationExtensions.Run(
|
||||||
.Run()
|
readFiles.WithPattern("/**")
|
||||||
.Run(op)
|
.Run(),
|
||||||
|
op)
|
||||||
.Select(
|
.Select(
|
||||||
x => x.Get<UPath>()
|
x => x.Get<UPath>()
|
||||||
.ToString())
|
.ToString())
|
||||||
|
@ -67,9 +68,10 @@ public class MoveToIndexPathsTest : NitrideIOTestBase
|
||||||
.Contains("a1"));
|
.Contains("a1"));
|
||||||
|
|
||||||
// Read and replace the paths.
|
// Read and replace the paths.
|
||||||
IOrderedEnumerable<string> output = readFiles.WithPattern("/**")
|
IOrderedEnumerable<string> output = NitrideOperationExtensions.Run(
|
||||||
.Run()
|
readFiles.WithPattern("/**")
|
||||||
.Run(op)
|
.Run(),
|
||||||
|
op)
|
||||||
.Select(
|
.Select(
|
||||||
x => x.Get<UPath>()
|
x => x.Get<UPath>()
|
||||||
.ToString())
|
.ToString())
|
||||||
|
|
|
@ -8,7 +8,7 @@ using Xunit.Abstractions;
|
||||||
|
|
||||||
using Zio;
|
using Zio;
|
||||||
|
|
||||||
namespace MfGames.Nitride.IO.Tests;
|
namespace MfGames.Nitride.IO.Tests.Paths;
|
||||||
|
|
||||||
public class RemovePathPrefixTest : NitrideIOTestBase
|
public class RemovePathPrefixTest : NitrideIOTestBase
|
||||||
{
|
{
|
||||||
|
@ -38,9 +38,10 @@ public class RemovePathPrefixTest : NitrideIOTestBase
|
||||||
.WithPathPrefix("/a");
|
.WithPathPrefix("/a");
|
||||||
|
|
||||||
// Read and replace the paths.
|
// Read and replace the paths.
|
||||||
IOrderedEnumerable<string> output = readFiles.WithPattern("/**")
|
IOrderedEnumerable<string> output = NitrideOperationExtensions.Run(
|
||||||
.Run()
|
readFiles.WithPattern("/**")
|
||||||
.Run(op)
|
.Run(),
|
||||||
|
op)
|
||||||
.Select(
|
.Select(
|
||||||
x => x.Get<UPath>()
|
x => x.Get<UPath>()
|
||||||
.ToString())
|
.ToString())
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
using MAB.DotIgnore;
|
using MAB.DotIgnore;
|
||||||
|
|
||||||
|
using MfGames.Gallium;
|
||||||
using MfGames.Nitride.IO.Contents;
|
using MfGames.Nitride.IO.Contents;
|
||||||
|
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
@ -9,7 +11,7 @@ using Xunit.Abstractions;
|
||||||
|
|
||||||
using Zio;
|
using Zio;
|
||||||
|
|
||||||
namespace MfGames.Nitride.IO.Tests;
|
namespace MfGames.Nitride.IO.Tests.Paths;
|
||||||
|
|
||||||
public class WhereNotIgnoredTests : NitrideIOTestBase
|
public class WhereNotIgnoredTests : NitrideIOTestBase
|
||||||
{
|
{
|
||||||
|
@ -39,9 +41,11 @@ public class WhereNotIgnoredTests : NitrideIOTestBase
|
||||||
ReadFiles readFiles = context.Resolve<ReadFiles>();
|
ReadFiles readFiles = context.Resolve<ReadFiles>();
|
||||||
|
|
||||||
// Read and replace the paths.
|
// Read and replace the paths.
|
||||||
IOrderedEnumerable<string> output = readFiles.WithPattern("/**")
|
IOrderedEnumerable<string> output = NitrideIOEnumerableEntityExtensions
|
||||||
.Run()
|
.WhereNotIgnored(
|
||||||
.WhereNotIgnored(ignore)
|
(IEnumerable<Entity>)readFiles.WithPattern("/**")
|
||||||
|
.Run(),
|
||||||
|
ignore)
|
||||||
.Select(
|
.Select(
|
||||||
x => x.Get<UPath>()
|
x => x.Get<UPath>()
|
||||||
.ToString())
|
.ToString())
|
||||||
|
|
|
@ -51,7 +51,9 @@ public class WriteFilesTest : NitrideIOTestBase
|
||||||
.Run()
|
.Run()
|
||||||
.Select(
|
.Select(
|
||||||
x => x.Get<UPath>() == "/b1/b.md"
|
x => x.Get<UPath>() == "/b1/b.md"
|
||||||
? x.SetTextContent(((ITextContentConvertable)x.GetBinaryContent()).ToTextContent())
|
? x.SetTextContent(
|
||||||
|
((ITextContentConvertable)x.GetBinaryContent())
|
||||||
|
.ToTextContent())
|
||||||
: x)
|
: x)
|
||||||
.Run(op);
|
.Run(op);
|
||||||
|
|
||||||
|
|
|
@ -3,14 +3,12 @@ using System.Linq;
|
||||||
|
|
||||||
using MfGames.Gallium;
|
using MfGames.Gallium;
|
||||||
using MfGames.Nitride.Contents;
|
using MfGames.Nitride.Contents;
|
||||||
using MfGames.Nitride.Markdown;
|
|
||||||
using MfGames.Nitride.Tests;
|
|
||||||
using MfGames.TestSetup;
|
using MfGames.TestSetup;
|
||||||
|
|
||||||
using Xunit;
|
using Xunit;
|
||||||
using Xunit.Abstractions;
|
using Xunit.Abstractions;
|
||||||
|
|
||||||
namespace MfGames.Nitride.Slugs.Tests;
|
namespace MfGames.Nitride.Markdown.Tests;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tests the functionality of the WriteFiles().
|
/// Tests the functionality of the WriteFiles().
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
using Autofac;
|
using Autofac;
|
||||||
|
|
||||||
using MfGames.Nitride.Markdown;
|
using MfGames.Nitride.Slugs;
|
||||||
using MfGames.Nitride.Tests;
|
using MfGames.Nitride.Tests;
|
||||||
|
|
||||||
namespace MfGames.Nitride.Slugs.Tests;
|
namespace MfGames.Nitride.Markdown.Tests;
|
||||||
|
|
||||||
public class MarkdownTestContext : NitrideTestContext
|
public class MarkdownTestContext : NitrideTestContext
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,18 +6,18 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\..\src\MfGames.Nitride.Markdown\MfGames.Nitride.Markdown.csproj" />
|
<ProjectReference Include="..\..\src\MfGames.Nitride.Markdown\MfGames.Nitride.Markdown.csproj"/>
|
||||||
<ProjectReference Include="..\MfGames.Nitride.Tests\MfGames.Nitride.Tests.csproj" />
|
<ProjectReference Include="..\MfGames.Nitride.Tests\MfGames.Nitride.Tests.csproj"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Markdig" Version="0.30.4" />
|
<PackageReference Include="Markdig" Version="0.30.4"/>
|
||||||
<PackageReference Include="MfGames.Gallium" Version="0.3.0" />
|
<PackageReference Include="MfGames.Gallium" Version="0.3.0"/>
|
||||||
<PackageReference Include="MfGames.Markdown.Gemtext" Version="1.2.2" />
|
<PackageReference Include="MfGames.Markdown.Gemtext" Version="1.2.2"/>
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.1" />
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.1"/>
|
||||||
<PackageReference Include="JunitXml.TestLogger" Version="3.0.114" />
|
<PackageReference Include="JunitXml.TestLogger" Version="3.0.114"/>
|
||||||
<PackageReference Include="Slugify.Core" Version="3.0.0" />
|
<PackageReference Include="Slugify.Core" Version="3.0.0"/>
|
||||||
<PackageReference Include="xunit" Version="2.4.2" />
|
<PackageReference Include="xunit" Version="2.4.2"/>
|
||||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
|
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
|
|
@ -6,21 +6,21 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\..\src\MfGames.Nitride.IO\MfGames.Nitride.IO.csproj" />
|
<ProjectReference Include="..\..\src\MfGames.Nitride.IO\MfGames.Nitride.IO.csproj"/>
|
||||||
<ProjectReference Include="..\..\src\MfGames.Nitride.Slugs\MfGames.Nitride.Slugs.csproj" />
|
<ProjectReference Include="..\..\src\MfGames.Nitride.Slugs\MfGames.Nitride.Slugs.csproj"/>
|
||||||
<ProjectReference Include="..\MfGames.Nitride.Tests\MfGames.Nitride.Tests.csproj" />
|
<ProjectReference Include="..\MfGames.Nitride.Tests\MfGames.Nitride.Tests.csproj"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="MfGames.Gallium" Version="0.3.0" />
|
<PackageReference Include="MfGames.Gallium" Version="0.3.0"/>
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.1" />
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.1"/>
|
||||||
<PackageReference Include="JunitXml.TestLogger" Version="3.0.114" />
|
<PackageReference Include="JunitXml.TestLogger" Version="3.0.114"/>
|
||||||
<PackageReference Include="xunit" Version="2.4.2" />
|
<PackageReference Include="xunit" Version="2.4.2"/>
|
||||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
|
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Zio" Version="0.15.0" />
|
<PackageReference Include="Zio" Version="0.15.0"/>
|
||||||
<PackageReference Include="coverlet.collector" Version="3.1.2">
|
<PackageReference Include="coverlet.collector" Version="3.1.2">
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Reference in a new issue