summaryrefslogtreecommitdiff
path: root/src/StardewModdingAPI/Extensions.cs
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2016-11-04 18:24:10 -0400
committerJesse Plamondon-Willard <github@jplamondonw.com>2016-11-04 18:24:10 -0400
commit78e8a6a4a088d6bff017bfcf22007f9fc8950071 (patch)
treeb6d73a4de283af75ff46fae70c0bc177792f007a /src/StardewModdingAPI/Extensions.cs
parentab3fffde0a96275026c7056369f58100c4b42a83 (diff)
downloadSMAPI-78e8a6a4a088d6bff017bfcf22007f9fc8950071.tar.gz
SMAPI-78e8a6a4a088d6bff017bfcf22007f9fc8950071.tar.bz2
SMAPI-78e8a6a4a088d6bff017bfcf22007f9fc8950071.zip
remove extensions from public interface, refactor & document
Diffstat (limited to 'src/StardewModdingAPI/Extensions.cs')
-rw-r--r--src/StardewModdingAPI/Extensions.cs78
1 files changed, 0 insertions, 78 deletions
diff --git a/src/StardewModdingAPI/Extensions.cs b/src/StardewModdingAPI/Extensions.cs
deleted file mode 100644
index 9a8c55f4..00000000
--- a/src/StardewModdingAPI/Extensions.cs
+++ /dev/null
@@ -1,78 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Linq;
-using System.Reflection;
-using Microsoft.Xna.Framework.Input;
-
-namespace StardewModdingAPI
-{
- public static class Extensions
- {
- public static Random Random = new Random();
-
- public static bool IsKeyDown(this Keys key)
- {
- return Keyboard.GetState().IsKeyDown(key);
- }
-
- public static string ToSingular<T>(this IEnumerable<T> ienum, string split = ", ") // where T : class
- {
- //Apparently Keys[] won't split normally :l
- if (typeof(T) == typeof(Keys))
- {
- return string.Join(split, ienum.ToArray());
- }
- return string.Join(split, ienum);
- }
-
- public static bool IsInt32(this object o)
- {
- int i;
- return int.TryParse(o.ToString(), out i);
- }
-
- public static int AsInt32(this object o)
- {
- return int.Parse(o.ToString());
- }
-
- public static int GetHash(this IEnumerable enumerable)
- {
- var hash = 0;
- foreach (var v in enumerable)
- {
- hash ^= v.GetHashCode();
- }
- return hash;
- }
-
- public static FieldInfo GetBaseFieldInfo(this Type t, string name)
- {
- return t.GetField(name, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Static);
- }
-
- public static T GetBaseFieldValue<T>(this Type t, object o, string name) where T : class
- {
- 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 string RemoveNumerics(this string st)
- {
- var s = st;
- foreach (var c in s)
- {
- if (!char.IsLetterOrDigit(c))
- {
- s = s.Replace(c.ToString(), "");
- }
- }
- return s;
- }
- }
-} \ No newline at end of file