-
Notifications
You must be signed in to change notification settings - Fork 490
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7035548
commit 035712a
Showing
12 changed files
with
224 additions
and
72 deletions.
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
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
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
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 |
---|---|---|
@@ -1,17 +1,22 @@ | ||
using System; | ||
|
||
namespace RuriLib.Exceptions | ||
namespace RuriLib.Exceptions; | ||
|
||
/// <summary> | ||
/// An exception that is thrown when a Wordlist Type with the given name was not present | ||
/// in the Environment settings. | ||
/// </summary> | ||
public class InvalidWordlistTypeException : Exception | ||
{ | ||
/// <summary> | ||
/// An exception that is thrown when a Wordlist Type with the given name was not present | ||
/// in the Environment settings. | ||
/// Creates a <see cref="InvalidWordlistTypeException"/> with a message that contains the invalid type. | ||
/// </summary> | ||
public class InvalidWordlistTypeException : Exception | ||
/// <param name="type"> | ||
/// The invalid Wordlist Type that was not found in the Environment settings. | ||
/// </param> | ||
public InvalidWordlistTypeException(string type) | ||
: base($"The Wordlist Type {type} was not found in the Environment settings") | ||
{ | ||
public InvalidWordlistTypeException(string type) | ||
: base($"The Wordlist Type {type} was not found in the Environment settings") | ||
{ | ||
|
||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,26 +1,59 @@ | ||
using System; | ||
|
||
namespace RuriLib.Exceptions | ||
namespace RuriLib.Exceptions; | ||
|
||
/// <summary> | ||
/// An exception that is thrown when an error occurs while parsing LoliCode. | ||
/// </summary> | ||
public class LoliCodeParsingException : Exception | ||
{ | ||
public class LoliCodeParsingException : Exception | ||
{ | ||
public int LineNumber { get; set; } | ||
/// <summary> | ||
/// The line number where the error occurred. | ||
/// </summary> | ||
public int LineNumber { get; set; } | ||
|
||
public LoliCodeParsingException(int lineNumber) | ||
{ | ||
LineNumber = lineNumber; | ||
} | ||
/// <summary> | ||
/// Creates a new <see cref="LoliCodeParsingException"/>. | ||
/// </summary> | ||
/// <param name="lineNumber"> | ||
/// The line number where the error occurred. | ||
/// </param> | ||
public LoliCodeParsingException(int lineNumber) | ||
{ | ||
LineNumber = lineNumber; | ||
} | ||
|
||
public LoliCodeParsingException(int lineNumber, string message) | ||
: base($"[Line {lineNumber}] {message}") | ||
{ | ||
LineNumber = lineNumber; | ||
} | ||
/// <summary> | ||
/// Creates a new <see cref="LoliCodeParsingException"/>. | ||
/// </summary> | ||
/// <param name="lineNumber"> | ||
/// The line number where the error occurred. | ||
/// </param> | ||
/// <param name="message"> | ||
/// The error message. | ||
/// </param> | ||
public LoliCodeParsingException(int lineNumber, string message) | ||
: base($"[Line {lineNumber}] {message}") | ||
{ | ||
LineNumber = lineNumber; | ||
} | ||
|
||
public LoliCodeParsingException(int lineNumber, string message, Exception inner) | ||
: base($"[Line {lineNumber}] {message}", inner) | ||
{ | ||
LineNumber = lineNumber; | ||
} | ||
/// <summary> | ||
/// Creates a new <see cref="LoliCodeParsingException"/>. | ||
/// </summary> | ||
/// <param name="lineNumber"> | ||
/// The line number where the error occurred. | ||
/// </param> | ||
/// <param name="message"> | ||
/// The error message. | ||
/// </param> | ||
/// <param name="inner"> | ||
/// The inner exception. | ||
/// </param> | ||
public LoliCodeParsingException(int lineNumber, string message, Exception inner) | ||
: base($"[Line {lineNumber}] {message}", inner) | ||
{ | ||
LineNumber = lineNumber; | ||
} | ||
} | ||
|
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 |
---|---|---|
@@ -1,16 +1,19 @@ | ||
using System; | ||
|
||
namespace RuriLib.Exceptions | ||
namespace RuriLib.Exceptions; | ||
|
||
/// <summary> | ||
/// An exception that is thrown when no Wordlist Types were specified | ||
/// in the Environment settings. | ||
/// </summary> | ||
public class NoWordlistTypesExceptions : Exception | ||
{ | ||
/// <summary> | ||
/// An exception that is thrown when no Wordlist Types were specified | ||
/// in the Environment settings. | ||
/// Creates a new <see cref="NoWordlistTypesExceptions"/>. | ||
/// </summary> | ||
public class NoWordlistTypesExceptions : Exception | ||
public NoWordlistTypesExceptions() : | ||
base("No Wordlist Types specified in the Environment settings") | ||
{ | ||
public NoWordlistTypesExceptions() : base("No Wordlist Types specified in the Environment settings") | ||
{ | ||
|
||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,29 +1,61 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace RuriLib.Extensions | ||
namespace RuriLib.Extensions; | ||
|
||
/// <summary> | ||
/// Provides extension methods for <see cref="bool"/>. | ||
/// </summary> | ||
public static class BoolExtensions | ||
{ | ||
public static class BoolExtensions | ||
{ | ||
public static bool AsBool(this bool b) | ||
=> b; | ||
/// <summary> | ||
/// Converts a <see cref="bool"/> to a <see cref="bool"/>. | ||
/// </summary> | ||
public static bool AsBool(this bool b) | ||
=> b; | ||
|
||
public static int AsInt(this bool b) | ||
=> Convert.ToInt32(b); | ||
/// <summary> | ||
/// Converts a <see cref="bool"/> to an <see cref="int"/>. | ||
/// Returns 1 if true, 0 if false. | ||
/// </summary> | ||
public static int AsInt(this bool b) | ||
=> Convert.ToInt32(b); | ||
|
||
public static float AsFloat(this bool b) | ||
=> Convert.ToSingle(b); | ||
/// <summary> | ||
/// Converts a <see cref="bool"/> to a <see cref="float"/>. | ||
/// Returns 1.0f if true, 0.0f if false. | ||
/// </summary> | ||
/// <param name="b"></param> | ||
/// <returns></returns> | ||
public static float AsFloat(this bool b) | ||
=> Convert.ToSingle(b); | ||
|
||
public static byte[] AsBytes(this bool b) | ||
=> BitConverter.GetBytes(b); | ||
/// <summary> | ||
/// Converts a <see cref="bool"/> to a <see cref="T:byte[]"/>. | ||
/// Returns a single byte with value 1 if true, 0 if false. | ||
/// </summary> | ||
public static byte[] AsBytes(this bool b) | ||
=> BitConverter.GetBytes(b); | ||
|
||
public static string AsString(this bool b) | ||
=> b.ToString(); | ||
/// <summary> | ||
/// Converts a <see cref="bool"/> to a <see cref="string"/>. | ||
/// Returns "True" if true, "False" if false. | ||
/// </summary> | ||
public static string AsString(this bool b) | ||
=> b.ToString(); | ||
|
||
public static List<string> AsList(this bool b) | ||
=> new List<string> { b.ToString() }; | ||
/// <summary> | ||
/// Converts a <see cref="bool"/> to a <see cref="List{T}"/> of <see cref="string"/>. | ||
/// Returns a list with a single element containing the string representation of the bool. | ||
/// </summary> | ||
public static List<string> AsList(this bool b) | ||
=> [b.ToString()]; | ||
|
||
public static Dictionary<string, string> AsDict(this bool b) | ||
=> new Dictionary<string, string> { { b.ToString(), "" } }; | ||
} | ||
/// <summary> | ||
/// Converts a <see cref="bool"/> to a <see cref="Dictionary{TKey, TValue}"/> of <see cref="string"/>. | ||
/// Returns a dictionary with a single key-value pair containing the string representation of the bool | ||
/// as the key and an empty string as the value. | ||
/// </summary> | ||
public static Dictionary<string, string> AsDict(this bool b) | ||
=> new() { { b.ToString(), "" } }; | ||
} |
Oops, something went wrong.