Skip to content

Commit

Permalink
Some small refactorings
Browse files Browse the repository at this point in the history
  • Loading branch information
ChainsManipulator committed Mar 18, 2024
1 parent af306f1 commit a373176
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
8 changes: 7 additions & 1 deletion Libiada.Core/Core/IBaseObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public interface IBaseObject
/// Object to compare to.
/// </param>
/// <returns>
/// true of objects are equal and false otherwise.
/// True if objects are equal and false otherwise.
/// </returns>
bool Equals(object other);

Expand All @@ -33,4 +33,10 @@ public interface IBaseObject
/// The <see cref="int"/>.
/// </returns>
int GetHashCode();

/// <summary>
/// Converts <see cref="IBaseObject"/> to <see cref="string"/>
/// </summary>
/// <returns></returns>
string ToString();
}
3 changes: 2 additions & 1 deletion Libiada.Core/DataTransformers/HighOrderFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ public static class HighOrderFactory
/// </exception>
public static Chain Create(Chain source, Link link)
{
if (link != Link.Start && link != Link.End && link != Link.CycleEnd && link != Link.CycleStart)
Link[] applicableLinks = [Link.Start, Link.End, Link.CycleEnd, Link.CycleStart];
if (!applicableLinks.Contains(link))
{
throw new ArgumentException("Unknown or inapplicable link", nameof(link));
}
Expand Down
6 changes: 3 additions & 3 deletions Libiada.Core/Extensions/EnumExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public static string GetDisplayValue<T>(this T value) where T : struct, ICompara

var fieldInfo = type.GetField(value.ToString(CultureInfo.InvariantCulture));

var descriptionAttributes = fieldInfo.GetCustomAttributes(typeof(DisplayAttribute), false) as DisplayAttribute[];
var descriptionAttributes = fieldInfo?.GetCustomAttributes(typeof(DisplayAttribute), false) as DisplayAttribute[];

if (descriptionAttributes == null)
{
Expand All @@ -57,12 +57,12 @@ public static string GetDisplayValue<T>(this T value) where T : struct, ICompara
/// Enum type.
/// </typeparam>
/// <returns>
/// The <see cref="string"/>.
/// The <see cref="string"/> or <see langword="null"/> if value is not found.
/// </returns>
/// <exception cref="TypeArgumentException">
/// Thrown if type argument is not enum.
/// </exception>
public static string GetName<T>(this T value) where T : struct, IComparable, IFormattable, IConvertible
public static string? GetName<T>(this T value) where T : struct, IComparable, IFormattable, IConvertible
{
Type type = typeof(T);

Expand Down

0 comments on commit a373176

Please sign in to comment.