Module.GetCustomAttributes 메서드 (Boolean)
.NET Framework 2.0
모든 사용자 지정 특성을 반환합니다.
네임스페이스: System.Reflection
어셈블리: mscorlib(mscorlib.dll)
어셈블리: mscorlib(mscorlib.dll)
다음 예제에서는 지정된 검색 조건과 일치하는 모듈 이름을 표시합니다.
using System; using System.Reflection; //Define a module-level attribute. [module: ReflectionModule_Examples.MySimpleAttribute("module-level")] namespace ReflectionModule_Examples { class MyMainClass { static void Main() { Module[] moduleArray; moduleArray = Assembly.GetExecutingAssembly().GetModules(false); // In a simple project with only one module, the module at index // 0 will be the module containing these classes. Module myModule = moduleArray[0]; object[] attributes; attributes = myModule.GetCustomAttributes(true); foreach(Object o in attributes) { Console.WriteLine("Found this attribute on myModule: {0}.", o.ToString()); } } } //A very simple custom attribute. [AttributeUsage(AttributeTargets.Class | AttributeTargets.Module)] public class MySimpleAttribute : Attribute { private string name; public MySimpleAttribute(string newName) { name = newName; } } }
package ReflectionModule_Examples;
import System.*;
import System.Reflection.*;
//Define a module-level attribute.
/** @module ReflectionModule_Examples.MySimpleAttribute("module-level")
*/
class MyMainClass
{
public static void main(String[] args)
{
Module moduleArray[];
moduleArray = Assembly.GetExecutingAssembly().GetModules(false);
// In a simple project with only one module, the module at index
// 0 will be the module containing these classes.
Module myModule = (Module)moduleArray.get_Item(0);
Object attributes[];
attributes = myModule.GetCustomAttributes(true);
for (int iCtr = 0; iCtr < attributes.length; iCtr++) {
Object o = ( Object)attributes[iCtr];
Console.WriteLine("Found this attribute on myModule: {0}.",
o.ToString());
}
} //main
} //MyMainClass
//A very simple custom attribute.
/** @attribute AttributeUsage(AttributeTargets.Class | AttributeTargets.Module)
*/
public class MySimpleAttribute extends Attribute
{
private String name;
public MySimpleAttribute(String newName)
{
name = newName;
} //MySimpleAttribute
} //MySimpleAttribute
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.