summaryrefslogtreecommitdiff
path: root/StardewModdingAPI/Extensions.cs
diff options
context:
space:
mode:
Diffstat (limited to 'StardewModdingAPI/Extensions.cs')
-rw-r--r--StardewModdingAPI/Extensions.cs19
1 files changed, 15 insertions, 4 deletions
diff --git a/StardewModdingAPI/Extensions.cs b/StardewModdingAPI/Extensions.cs
index d2d8dce8..1bd589db 100644
--- a/StardewModdingAPI/Extensions.cs
+++ b/StardewModdingAPI/Extensions.cs
@@ -29,15 +29,26 @@ namespace StardewModdingAPI
return result;
}
- public static bool IsInt32(this string s)
+ public static bool IsInt32(this object o)
{
int i;
- return Int32.TryParse(s, out i);
+ return Int32.TryParse(o.ToString(), out i);
}
- public static Int32 AsInt32(this string s)
+ public static Int32 AsInt32(this object o)
{
- return Int32.Parse(s);
+ return Int32.Parse(o.ToString());
+ }
+
+ public static bool IsBool(this object o)
+ {
+ bool b;
+ return Boolean.TryParse(o.ToString(), out b);
+ }
+
+ public static bool AsBool(this object o)
+ {
+ return Boolean.Parse(o.ToString());
}
public static int GetHash(this IEnumerable enumerable)