summaryrefslogtreecommitdiff
path: root/src/SMAPI.Mods.ConsoleCommands/Framework/ItemData/SearchableItem.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/SMAPI.Mods.ConsoleCommands/Framework/ItemData/SearchableItem.cs')
-rw-r--r--src/SMAPI.Mods.ConsoleCommands/Framework/ItemData/SearchableItem.cs21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/ItemData/SearchableItem.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/ItemData/SearchableItem.cs
index 3eede413..b618a308 100644
--- a/src/SMAPI.Mods.ConsoleCommands/Framework/ItemData/SearchableItem.cs
+++ b/src/SMAPI.Mods.ConsoleCommands/Framework/ItemData/SearchableItem.cs
@@ -1,4 +1,5 @@
-using StardewValley;
+using System;
+using StardewValley;
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.ItemData
{
@@ -37,5 +38,23 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.ItemData
this.ID = id;
this.Item = item;
}
+
+ /// <summary>Get whether the item name contains a case-insensitive substring.</summary>
+ /// <param name="substring">The substring to find.</param>
+ public bool NameContains(string substring)
+ {
+ return
+ this.Name.IndexOf(substring, StringComparison.InvariantCultureIgnoreCase) != -1
+ || this.DisplayName.IndexOf(substring, StringComparison.InvariantCultureIgnoreCase) != -1;
+ }
+
+ /// <summary>Get whether the item name is exactly equal to a case-insensitive string.</summary>
+ /// <param name="name">The substring to find.</param>
+ public bool NameEquivalentTo(string name)
+ {
+ return
+ this.Name.Equals(name, StringComparison.InvariantCultureIgnoreCase)
+ || this.DisplayName.Equals(name, StringComparison.InvariantCultureIgnoreCase);
+ }
}
}