/// <summary>カスタム属性クラスを取得する(メソッド属性用)</summary> /// <param name="methodInfo">メソッドのMethodInfo</param> /// <param name="myAttribute">カスタム属性クラスの配列</param> /// <remarks>自由に(拡張して)利用できる。</remarks> public static void GetAttr(MethodInfo methodInfo, out MyAttribute[] myAttribute) { // 属性クラスのリストを取得する。inheritは、AllowMultipleに合わせる。 // http://msdn.microsoft.com/ja-jp/library/system.type.getcustomattributes.aspx object[] list = methodInfo.GetCustomAttributes(typeof(MyAttribute), true); // object[]をMyAttribute[]に変換して返す。 int i = 0; myAttribute = new MyAttribute[list.Length]; foreach (MyAttribute temp in list) { myAttribute[i] = temp; } }