|
이 문서는 수동으로 번역한 것입니다. 원본 텍스트를 보려면 포인터를 문서의 문장 위로 올리십시오.
|
번역
원본
|
MemberInfo.GetCustomAttributes 메서드 (Boolean)
Silverlight
네임스페이스: System.Reflection
어셈블리: mscorlib(mscorlib.dll)
매개 변수
- inherit
- 형식: System.Boolean
특성을 찾기 위해 이 멤버의 상속 체인을 검색하려면 true로 설정하고, 그렇지 않으면 false로 설정합니다. 이 매개 변수는 속성과 이벤트의 경우 무시됩니다. 설명 부분을 참조하십시오.
구현
ICustomAttributeProvider.GetCustomAttributes(Boolean)| 예외 | 상황 |
|---|---|
| TypeLoadException |
플랫폼 참고 사항
Windows Phone용 Silverlight
일부 특성 생성자 인수 및 속성 값은 MemberInfo.GetCustomAttributes 오류를 일으킬 수 있습니다.
참고: |
|---|
using System; using System.Reflection; // Define a custom attribute with one named parameter. [AttributeUsage(AttributeTargets.All)] public class MyAttribute : Attribute { private string myName; public MyAttribute(string name) { myName = name; } public string Name { get { return myName; } } } // Define a class that has the custom attribute associated with one of its members. public class MyClass1 { [MyAttribute("This is an example attribute.")] public void MyMethod(int i) { return; } } public class Example { public static void Demo(System.Windows.Controls.TextBlock outputBlock) { try { // Get the type of MyClass1. Type myType = typeof(MyClass1); // Get the members associated with MyClass1. MemberInfo[] myMembers = myType.GetMembers(); // Display the attributes for each of the members of MyClass1. for (int i = 0; i < myMembers.Length; i++) { Object[] myAttributes = myMembers[i].GetCustomAttributes(true); if (myAttributes.Length > 0) { outputBlock.Text += String.Format("\nThe attributes for the member {0} are: \n", myMembers[i]) + "\n"; for (int j = 0; j < myAttributes.Length; j++) outputBlock.Text += String.Format("The type of the attribute is {0}.", myAttributes[j]) + "\n"; } } } catch (Exception e) { outputBlock.Text += String.Format("An exception occurred: {0}", e.Message) + "\n"; } } }
Silverlight에서 지원되는 운영 체제 및 브라우저에 대한 자세한 내용은 지원되는 운영 체제 및 브라우저을 참조하십시오.
참고: