File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed
Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ namespace BencodeNET.Parsing
1414 /// </summary>
1515 public class BStringParser : BObjectParser < BString >
1616 {
17+
1718 /// <summary>
1819 /// The minimum stream length in bytes for a valid string ('0:').
1920 /// </summary>
@@ -32,13 +33,23 @@ public BStringParser()
3233 /// <param name="encoding"></param>
3334 public BStringParser ( Encoding encoding )
3435 {
35- Encoding = encoding ?? throw new ArgumentNullException ( nameof ( encoding ) ) ;
36+ _encoding = encoding ?? throw new ArgumentNullException ( nameof ( encoding ) ) ;
3637 }
3738
3839 /// <summary>
3940 /// The encoding used when creating the <see cref="BString"/> when parsing.
4041 /// </summary>
41- public override Encoding Encoding { get ; }
42+ public override Encoding Encoding => _encoding ;
43+ private Encoding _encoding ;
44+
45+ /// <summary>
46+ /// Changes the encoding used for parsing.
47+ /// </summary>
48+ /// <param name="encoding">The new encoding to use.</param>
49+ public void ChangeEncoding ( Encoding encoding )
50+ {
51+ _encoding = encoding ;
52+ }
4253
4354 /// <summary>
4455 /// Parses the next <see cref="BString"/> from the reader.
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ public Encoding Encoding
2727 set
2828 {
2929 _encoding = value ?? throw new ArgumentNullException ( nameof ( value ) ) ;
30- Parsers . AddOrReplace ( new BStringParser ( value ) ) ;
30+ Parsers . GetSpecific < BStringParser > ( ) ? . ChangeEncoding ( value ) ;
3131 }
3232 }
3333 private Encoding _encoding ;
You can’t perform that action at this time.
0 commit comments