示例#1
0
    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);
 }
示例#3
0
    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);
        }
    }