Skip to content

Commit

Permalink
#72 Fix up issues in Stravaig.FamilyTreeGenerator
Browse files Browse the repository at this point in the history
  • Loading branch information
colinangusmackay committed Jan 9, 2021
1 parent ff4743d commit aeeb295
Show file tree
Hide file tree
Showing 29 changed files with 36 additions and 46 deletions.
1 change: 1 addition & 0 deletions src/.idea/.idea.Gedcom/.idea/contentModel.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/Gedcom.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=Namer/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Naturalisation/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Organiser/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Paramore/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Serialiser/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Standardiser/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Stravaig/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
2 changes: 1 addition & 1 deletion src/Stravaig.FamilyTree.Blazor/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Stravaig.FamilyTree.Blazor.Services;
using Stravaig.FamilyTreeGenerator.Requests.Handlers.Services;
using Stravaig.FamilyTree.Common.Humaniser;

namespace Stravaig.FamilyTree.Blazor
{
Expand Down
2 changes: 1 addition & 1 deletion src/Stravaig.FamilyTree.Blazor/Shared/Relationship.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@using Stravaig.FamilyTreeGenerator.Requests.Handlers.Services
@using Stravaig.FamilyTree.Common.Humaniser
@RelationshipName
@code {
[Parameter]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
@using Stravaig.FamilyTree.Blazor.Shared.Date
@using Stravaig.FamilyTree.Blazor.Shared.Timeline
@using Stravaig.FamilyTree.Common.Footnotes
@using Stravaig.FamilyTreeGenerator.Requests.Handlers.Services
@using Stravaig.FamilyTree.Blazor.Services

<h1>@Subject.NameWithoutMarker</h1>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace Stravaig.FamilyTree.Common.Extensions
{
// ReSharper disable once InconsistentNaming
// It is named after the interface it is extending.
public static class IEnumerableGedcomIndividualRecordExtensions
{
public static IEnumerable<GedcomIndividualRecord> OrderByStandardSort(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Stravaig.Gedcom.Model;

namespace Stravaig.FamilyTreeGenerator.Requests.Handlers.Services
namespace Stravaig.FamilyTree.Common.Humaniser
{
public class EnglishLanguageRelationshipRenderer : IRelationshipRenderer
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Stravaig.Gedcom.Model;

namespace Stravaig.FamilyTreeGenerator.Requests.Handlers.Services
namespace Stravaig.FamilyTree.Common.Humaniser
{
public interface IRelationshipRenderer
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using System.Text;
using Stravaig.Gedcom.Model;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using Stravaig.Gedcom.Extensions;
Expand All @@ -11,7 +10,7 @@ namespace Stravaig.FamilyTreeGenerator.Extensions
{
public static class StringExtensions
{
private const char ellipsis = (char) 0x2026; // …
private const char Ellipsis = (char) 0x2026; // …
public static string MakeFileNameSafe(this string target)
{
if (target == null)
Expand All @@ -36,7 +35,7 @@ public static string MakeFileNameSafe(this string target)
result = result.Replace("--", "-");
} while (result.Length < len);
if (len > 100)
result = result.Substring(0, 99) + ellipsis;
result = result.Substring(0, 99) + Ellipsis;
return result;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.IO;
using System.IO.Compression;
using Stravaig.Gedcom.Extensions;

namespace Stravaig.FamilyTreeGenerator.Extensions
Expand Down
7 changes: 3 additions & 4 deletions src/Stravaig.FamilyTreeGenerator/Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.IO;
using System.Text;
using CommandLine;
using Humanizer;
using Microsoft.Extensions.DependencyInjection;
Expand All @@ -9,7 +8,7 @@
using Paramore.Brighter.Extensions.DependencyInjection;
using Paramore.Brighter.Policies.Handlers;
using Polly;
using Polly.Registry;
using Stravaig.FamilyTree.Common.Humaniser;
using Stravaig.FamilyTreeGenerator.Requests;
using Stravaig.FamilyTreeGenerator.Requests.Handlers;
using Stravaig.FamilyTreeGenerator.Requests.Handlers.Services;
Expand Down Expand Up @@ -105,8 +104,8 @@ private static void AddApplicationServices(ServiceCollection services, CommandLi
services.AddTransient<IResidenceRenderer, ResidenceMarkdownRenderer>();
services.AddTransient<IOccupationRenderer, OccupationMarkdownRenderer>();

services.AddSingleton<CommandLineOptions>(options);
services.AddSingleton<GedcomDatabase>(p=>
services.AddSingleton(options);
services.AddSingleton(p=>
{
CommandLineOptions opts = p.GetRequiredService<CommandLineOptions>();
return GetDatabase(opts.SourceFile);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,19 @@ namespace Stravaig.FamilyTreeGenerator.Requests.Handlers
{
public class ApplicationHandler : RequestHandler<Application>
{

private readonly ILogger<ApplicationHandler> _logger;
private readonly GedcomDatabase _database;
private readonly CommandLineOptions _options;
private readonly IAmACommandProcessor _commander;
private readonly Dictionary<GedcomPointer, SourceEntry> _sources;



public ApplicationHandler(
ILogger<ApplicationHandler> logger,
IAmACommandProcessor commander,
GedcomDatabase database,
CommandLineOptions options)
GedcomDatabase database)
{
_logger = logger;
_commander = commander;
_database = database;
_options = options;
_sources = new Dictionary<GedcomPointer, SourceEntry>();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Paramore.Brighter;
using Stravaig.FamilyTreeGenerator.Extensions;
using Stravaig.FamilyTreeGenerator.Services;
using Stravaig.Gedcom;
using Stravaig.Gedcom.Model;
using Stravaig.Gedcom.Model.Extensions;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
Expand Down Expand Up @@ -59,7 +58,7 @@ protected override void WriteIndex(TextWriter writer, GedcomIndividualRecord[] p

var localeGroups = stateGroup
.GroupBy(pl => string.Join(", ",
pl.Location.TakeWhile(l => l != stateGroup.Key) ?? Array.Empty<string>()))
pl.Location.TakeWhile(l => l != stateGroup.Key)))
.OrderBy(g => g.Key);
foreach (var localeGroup in localeGroups)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Microsoft.Extensions.Logging;
using Paramore.Brighter;
using Stravaig.FamilyTree.Common.Extensions;
using Stravaig.FamilyTree.Common.Humaniser;
using Stravaig.FamilyTreeGenerator.Extensions;
using Stravaig.FamilyTreeGenerator.Requests.Handlers.Services;
using Stravaig.FamilyTreeGenerator.Services;
Expand All @@ -16,10 +17,11 @@

namespace Stravaig.FamilyTreeGenerator.Requests.Handlers
{
// ReSharper disable once ClassNeverInstantiated.Global
// Instantiated by Paramore Brighter
public class RenderIndividualAsMarkdownHandler : RequestHandler<RenderIndividual>, IDisposable
{
private readonly ILogger<RenderIndividualAsMarkdownHandler> _logger;
private readonly IDateRenderer _dateRenderer;
private readonly IStaticFootnoteOrganiser _footnoteOrganiser;
private readonly IAssociatesOrganiser _associatesOrganiser;
private readonly ITimelineRenderer _timelineRenderer;
Expand All @@ -33,7 +35,6 @@ public class RenderIndividualAsMarkdownHandler : RequestHandler<RenderIndividual

public RenderIndividualAsMarkdownHandler(
ILogger<RenderIndividualAsMarkdownHandler> logger,
IDateRenderer dateRenderer,
IStaticFootnoteOrganiser footnoteOrganiser,
IAssociatesOrganiser associatesOrganiser,
ITimelineRenderer timelineRenderer,
Expand All @@ -44,7 +45,6 @@ public class RenderIndividualAsMarkdownHandler : RequestHandler<RenderIndividual
IFileNamer fileNamer)
{
_logger = logger;
_dateRenderer = dateRenderer;
_footnoteOrganiser = footnoteOrganiser;
_associatesOrganiser = associatesOrganiser;
_timelineRenderer = timelineRenderer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ private void RenderPartnershipLine(TextWriter writer, Entry entry)
if (entry.Event.Place != null)
{
writer.Write(" at ");
writer.Write(GedcomPlaceRecordExtensions.NormalisedPlaceName((IPlace) entry.Event));
writer.Write(entry.Event.NormalisedPlaceName());
}

writer.WriteLine(".");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ private void RenderPartnershipLine(TextWriter writer, Entry entry)
if (entry.Event.Place != null)
{
writer.Write(" at ");
writer.Write(GedcomPlaceRecordExtensions.NormalisedPlaceName((IPlace) entry.Event));
writer.Write(entry.Event.NormalisedPlaceName());
}

writer.WriteLine(".");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
using System.Linq;
using Microsoft.Extensions.Logging;
using Stravaig.FamilyTree.Common.Extensions;
using Stravaig.FamilyTreeGenerator.Extensions;
using Stravaig.FamilyTreeGenerator.Requests.Handlers.Services;
using Stravaig.FamilyTree.Common.Humaniser;
using Stravaig.FamilyTreeGenerator.Services;
using Stravaig.Gedcom.Model;
using Stravaig.Gedcom.Model.Extensions;
Expand All @@ -13,13 +12,16 @@ public class RenderPersonAncestorsAsJsonHandler : RenderPersonAsJsonHandlerBase
{
private class PersonModel
{
// ReSharper disable UnusedAutoPropertyAccessor.Local
// Used by JSON Serialiser
public string Id { get; set; }
public string Name { get; set; }
public string Gender { get; set; }
public string Relationship { get; set; }
public string DateOfBirth { get; set; }
public string DateOfDeath { get; set; }
public PersonModel[] Parents { get; set; }
// ReSharper restore UnusedAutoPropertyAccessor.Local
}

private readonly IRelationshipRenderer _relationshipRenderer;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,29 @@
using System.Linq;
using Microsoft.Extensions.Logging;
using Stravaig.FamilyTree.Common.Extensions;
using Stravaig.FamilyTreeGenerator.Extensions;
using Stravaig.FamilyTreeGenerator.Requests.Handlers.Services;
using Stravaig.FamilyTree.Common.Humaniser;
using Stravaig.FamilyTreeGenerator.Services;
using Stravaig.Gedcom.Model;
using Stravaig.Gedcom.Model.Extensions;

namespace Stravaig.FamilyTreeGenerator.Requests.Handlers
{
// ReSharper disable once ClassNeverInstantiated.Global
// Instantiated by Paramore Brighter
public class RenderPersonDescendantsAsJsonHandler : RenderPersonAsJsonHandlerBase
{
private class PersonModel
{
// Used by JSON Serialiser
// ReSharper disable UnusedAutoPropertyAccessor.Local
public string Id { get; set; }
public string Name { get; set; }
public string Gender { get; set; }
public string Relationship { get; set; }
public string DateOfBirth { get; set; }
public string DateOfDeath { get; set; }
public PersonModel[] Children { get; set; }
// ReSharper restore UnusedAutoPropertyAccessor.Local
}

private readonly IRelationshipRenderer _relationshipRenderer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Stravaig.FamilyTree.Common.Extensions;
using Stravaig.FamilyTreeGenerator.Extensions;
using Stravaig.FamilyTreeGenerator.Requests.Handlers.Services;
using Stravaig.FamilyTree.Common.Humaniser;
using Stravaig.FamilyTreeGenerator.Services;
using Stravaig.Gedcom.Model;
using Stravaig.Gedcom.Model.Extensions;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using System.IO;
using System.Text;
using System.Threading;
using Humanizer;
using Microsoft.Extensions.Logging;
using Microsoft.VisualBasic;
using Paramore.Brighter;
using Stravaig.FamilyTreeGenerator.Services;
using Stravaig.Gedcom.Model;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
using System.IO;
using System.Linq;
using System.Text;
using Humanizer;
using Microsoft.Extensions.Logging;
using Paramore.Brighter;
using Stravaig.FamilyTree.Common.Extensions;
using Stravaig.FamilyTreeGenerator.Extensions;
using Stravaig.FamilyTreeGenerator.Requests.Handlers.Services;
using Stravaig.FamilyTreeGenerator.Services;
using Stravaig.Gedcom.Model;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Linq;
using Microsoft.Extensions.Logging;
using Stravaig.FamilyTree.Common.Extensions;
using Stravaig.FamilyTreeGenerator.Extensions;
using Stravaig.FamilyTreeGenerator.Requests.Handlers.Services;
using Stravaig.FamilyTreeGenerator.Services;
using Stravaig.Gedcom.Model;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using Stravaig.Gedcom.Model;

namespace Stravaig.FamilyTreeGenerator.Requests.Handlers.Services
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using Stravaig.FamilyTree.Common.Humaniser;
using Stravaig.FamilyTreeGenerator.Extensions;
using Stravaig.FamilyTreeGenerator.Services;
using Stravaig.Gedcom.Extensions;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using Stravaig.Gedcom;
using Stravaig.Gedcom.Model;

namespace Stravaig.FamilyTreeGenerator.Requests
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using Stravaig.Gedcom;
using Stravaig.Gedcom.Model;

namespace Stravaig.FamilyTreeGenerator.Requests
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=requests_005Chandlers_005Cglue/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

0 comments on commit aeeb295

Please sign in to comment.