-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow USFM texts to be generated from the USFM string only - sillsdev…
- Loading branch information
1 parent
ceb586c
commit 2c35224
Showing
3 changed files
with
80 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using System.IO; | ||
using SIL.ObjectModel; | ||
|
||
namespace SIL.Machine.Corpora | ||
{ | ||
public class StringStreamContainer : DisposableBase, IStreamContainer | ||
{ | ||
private readonly string _content; | ||
|
||
public StringStreamContainer(string content) | ||
{ | ||
_content = content; | ||
} | ||
|
||
public Stream OpenStream() | ||
{ | ||
MemoryStream stream = new MemoryStream(); | ||
StreamWriter writer = new StreamWriter(stream); | ||
writer.Write(_content); | ||
writer.Flush(); | ||
stream.Position = 0; | ||
return stream; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using System.Text; | ||
using SIL.Scripture; | ||
|
||
namespace SIL.Machine.Corpora | ||
{ | ||
public class UsfmStringText : UsfmTextBase | ||
{ | ||
private readonly string _usfm; | ||
|
||
public UsfmStringText( | ||
UsfmStylesheet stylesheet, | ||
Encoding encoding, | ||
string id, | ||
string usfm, | ||
ScrVers versification = null, | ||
bool includeMarkers = false, | ||
bool includeAllText = false | ||
) | ||
: base(id, stylesheet, encoding, versification, includeMarkers, includeAllText) | ||
{ | ||
_usfm = usfm; | ||
} | ||
|
||
protected override IStreamContainer CreateStreamContainer() | ||
{ | ||
return new StringStreamContainer(_usfm); | ||
} | ||
} | ||
} |