Skip to content

Commit

Permalink
Optimize the code
Browse files Browse the repository at this point in the history
  • Loading branch information
Wenveo committed Nov 29, 2021
1 parent 10d9fe1 commit 039de58
Showing 1 changed file with 7 additions and 21 deletions.
28 changes: 7 additions & 21 deletions Noisrev.League.IO.RST/RSTFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,34 +151,20 @@ private RSTFile()
/// <param name="version">RST Version</param>
public RSTFile(byte version) : this()
{
// Version 2 and 3
if (version >= 2 && version < 4)
{
// Set the type Complex.
Type = RType.Complex;
}
// Version 4 and 5
else if (version == 4 || version == 5)
{
// Set the type Simple.
Type = RType.Simple;
}
// Invalid version.
else
{
// An exception is thrown.
throw new ArgumentException($"Invalid Major version {version}. Must be one of 2, 3, 4, 5");
}
var type = version.GetRType();

/* Check the type */
if (type == null) throw new ArgumentException($"Invalid Major version {version}. Must be one of 2, 3, 4, 5");

// Set the version.
this.Type = Type;
this.Version = version;
}

/// <summary>
/// Read the RST file from the stream.
/// </summary>
/// <param name="input">The input stream.</param>
/// <param name="leaveOpen">true to leave the stream open after the System.IO.BinaryReader object is disposed; otherwise, false.</param>
/// <param name="leaveOpen">true to leave the stream open after the <see cref="System.IO.BinaryReader"/> object is disposed; otherwise, false.</param>
/// <exception cref="ArgumentException"></exception>
/// <exception cref="ArgumentNullException"></exception>
/// <exception cref="ArgumentOutOfRangeException"></exception>
Expand Down Expand Up @@ -411,7 +397,7 @@ public bool SetConfig(string conf)
/// Using an output stream, write the RST to that stream.
/// </summary>
/// <param name="output">The output stream.</param>
/// <param name="leaveOpen">true to leave the stream open after the System.IO.BinaryWriter object is disposed; otherwise, false.</param>
/// <param name="leaveOpen">true to leave the stream open after the <see cref="System.IO.BinaryWriter"/> object is disposed; otherwise, false.</param>
/// <exception cref="ArgumentException"/>
/// <exception cref="ArgumentNullException"/>
/// <exception cref="EncoderFallbackException"/>
Expand Down

0 comments on commit 039de58

Please sign in to comment.