using System;
using System.Reflection;
[module: MySimpleAttribute("module-level")]
class MyMainClass
{
static void Main()
{
Module[] moduleArray;
moduleArray = Assembly.GetExecutingAssembly().GetModules(false);
Module myModule = moduleArray[0];
Type myType;
myType = myModule.GetType("ReflectionModule_Examples.MySimpleAttribute");
Console.WriteLine("IsDefined(MySimpleAttribute) = {0}", myModule.IsDefined(myType, false));
}
}
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Module)]
public class MySimpleAttribute : Attribute
{
private string name;
public MySimpleAttribute(string newName)
{
name = newName;
}
}