public static bool needsSize(this CommandMode inMode) { NeedsSizeAttribute[] attributes = (NeedsSizeAttribute[])inMode.GetType().GetField(inMode.ToString()).GetCustomAttributes(typeof(NeedsSizeAttribute), false); return(attributes.Length > 0); }
public static bool hasAttribute <T>(this CommandMode inMode) where T : class { object[] attribs = inMode.GetType().GetField(inMode.ToString()).GetCustomAttributes(true); for (int i = 0; i < attribs.Length; i++) { if (attribs[i].GetType() == typeof(T)) { return(true); } } return(false); }
public static string response(this CommandMode inMode) { ResponseAttribute[] attributes = (ResponseAttribute[])inMode.GetType().GetField(inMode.ToString()).GetCustomAttributes(typeof(ResponseAttribute), false); if (attributes.Length == 0) { Console.WriteLine("internal error"); return(""); } else { return(attributes[0].response); } }