Skip to content

Commit

Permalink
Add constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
Enkidu93 committed Aug 1, 2024
1 parent 1af0e3c commit 7681268
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/SIL.Machine/Corpora/ParatextProjectTextUpdaterBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,16 @@ namespace SIL.Machine.Corpora
{
public abstract class ParatextProjectTextUpdaterBase
{
private readonly ParatextProjectSettingsParserBase _settingsParser;
private readonly ParatextProjectSettings _settings;

protected ParatextProjectTextUpdaterBase(ParatextProjectSettingsParserBase settingsParser)
{
_settingsParser = settingsParser;
_settings = settingsParser.Parse();
}

protected ParatextProjectTextUpdaterBase(ParatextProjectSettings settings)
{
_settings = settings;
}

public string UpdateUsfm(
Expand All @@ -20,9 +25,7 @@ public string UpdateUsfm(
bool preferExistingText = true
)
{
ParatextProjectSettings settings = _settingsParser.Parse();

string fileName = settings.GetBookFileName(bookId);
string fileName = _settings.GetBookFileName(bookId);
if (!Exists(fileName))
return null;

Expand All @@ -38,8 +41,8 @@ public string UpdateUsfm(
stripAllText,
preferExistingText: preferExistingText
);
UsfmParser.Parse(usfm, handler, settings.Stylesheet, settings.Versification);
return handler.GetUsfm(settings.Stylesheet);
UsfmParser.Parse(usfm, handler, _settings.Stylesheet, _settings.Versification);
return handler.GetUsfm(_settings.Stylesheet);
}

protected abstract bool Exists(string fileName);
Expand Down
3 changes: 3 additions & 0 deletions src/SIL.Machine/Corpora/ZipParatextProjectTextUpdaterBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,8 @@ public abstract class ZipParatextProjectTextUpdaterBase : ParatextProjectTextUpd
{
protected ZipParatextProjectTextUpdaterBase(ZipParatextProjectSettingsParserBase settingsParser)
: base(settingsParser) { }

protected ZipParatextProjectTextUpdaterBase(ParatextProjectSettings settings)
: base(settings) { }
}
}

0 comments on commit 7681268

Please sign in to comment.