diff options
Diffstat (limited to 'StardewModdingAPI/Extensions.cs')
-rw-r--r-- | StardewModdingAPI/Extensions.cs | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/StardewModdingAPI/Extensions.cs b/StardewModdingAPI/Extensions.cs index d4b582b7..a0e87f04 100644 --- a/StardewModdingAPI/Extensions.cs +++ b/StardewModdingAPI/Extensions.cs @@ -1,10 +1,7 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Linq; using System.Reflection; -using System.Text; -using System.Threading.Tasks; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Input; @@ -82,12 +79,18 @@ namespace StardewModdingAPI return t.GetBaseFieldInfo(name).GetValue(o) as T; } + public static void SetBaseFieldValue<T>(this Type t, object o, string name, object newValue) where T : class + { + t.GetBaseFieldInfo(name).SetValue(o, newValue as T); + } + /* public static T GetBaseFieldValue<T>(this object o, string name) where T : class { return o.GetType().GetBaseFieldInfo(name).GetValue(o) as T; }*/ + /* public static object GetBaseFieldValue(this object o, string name) { return o.GetType().GetBaseFieldInfo(name).GetValue(o); @@ -97,5 +100,19 @@ namespace StardewModdingAPI { o.GetType().GetBaseFieldInfo(name).SetValue(o, newValue); } + */ + + public static string RemoveNumerics(this string st) + { + string s = st; + foreach (char c in s) + { + if (!char.IsLetterOrDigit(c)) + { + s = s.Replace(c.ToString(), ""); + } + } + return s; + } } }
\ No newline at end of file |