Module.Is Defined : Module « Reflection « C# / C Sharp






Module.Is Defined

 

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;
    }
}

   
  








Related examples in the same category

1.Load Assembly
2.Module Class Performs reflection on a module.
3.Module.Assembly
4.Module.FilterTypeName
5.Module.Filter Type Name
6.Module.Fully Qualified Name
7.Module.Is Resource
8.Module.ToString