Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
fix: add a method for IsTheSameTo
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Apr 22, 2023
1 parent 42b7001 commit b51f100
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions RotationSolver.Basic/Helpers/IActionHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,19 +83,15 @@ internal static bool IsLastAction(params ActionID[] ids)
}

public static bool IsTheSameTo(this IAction action, bool isAdjust, params IAction[] actions)
=> action.IsTheSameTo(GetIDFromActions(isAdjust, actions));

public static bool IsTheSameTo(this IAction action, params ActionID[] actions)
{
if (action == null) return false;
return IsActionID(isAdjust ? (ActionID)action.AdjustedID : (ActionID)action.ID, GetIDFromActions(isAdjust, actions));
return IsActionID((ActionID)action.AdjustedID, actions);
}

private static bool IsActionID(ActionID id, params ActionID[] ids)
{
foreach (var i in ids)
{
if (i == id) return true;
}
return false;
}
private static bool IsActionID(ActionID id, params ActionID[] ids) => ids.Contains(id);

private static ActionID[] GetIDFromActions(bool isAdjust, params IAction[] actions)
{
Expand Down

0 comments on commit b51f100

Please sign in to comment.