Module.IsDefined tells whether the specified attribute type has been applied to this module. : Module « Reflection « VB.Net

Home
VB.Net
1.2D
2.Application
3.Class
4.Data Structure
5.Data Types
6.Database ADO.net
7.Date Time
8.Development
9.Event
10.File Directory
11.Generics
12.GUI
13.Internationalization I18N
14.Language Basics
15.LINQ
16.Network Remote
17.Reflection
18.Security
19.Thread
20.Windows Presentation Foundation
21.Windows System
22.XML
23.XML LINQ
VB.Net » Reflection » ModuleScreenshots 
Module.IsDefined tells whether the specified attribute type has been applied to this module.
 

Imports System
Imports System.Reflection

<Module: MySimpleAttribute("module-level")
    Class MyMainClass
        Shared Sub Main()
            Dim moduleArray() As [Module]
            moduleArray = [Assembly].GetExecutingAssembly().GetModules(False)
            Dim myModule As [Module= moduleArray(0)
            Dim myType As Type
            myType = myModule.GetType("MySimpleAttribute")
            Console.WriteLine("IsDefined(MySimpleAttribute) = {0}", myModule.IsDefined(myType, False))
        End Sub
    End Class 
    <AttributeUsage(AttributeTargets.Class Or AttributeTargets.Module)> _
    Public Class MySimpleAttribute
        Inherits Attribute
        Private name As String

        Public Sub New(ByVal newName As String)
            name = newName
        End Sub 
    End Class 

   
  
Related examples in the same category
1.Module Class performs reflection on a module.
2.Module.Assembly Property gets the appropriate Assembly for this instance of Module.
3.Module.FilterTypeName Field
4.Module.FilterTypeNameIgnoreCase
5.Module.FullyQualifiedName
6.Module.GetCustomAttributes returns all custom attributes.
7.Module.GetCustomAttributes gets custom attributes of the specified type.
8.Module.GetType returns the specified type, performing a case-sensitive search.
9.Module.GetType returns the specified type, searching the module with the specified case sensitivity.
10.Module.GetType returns type
11.Module.IsResource gets a value indicating whether the object is a resource.
12.Module.Name gets a String representing the name of the module with the path removed.
13.Module.ScopeName gets a string representing the name of the module.
14.Module.ToString returns the name of the module.
15.Assembly.GetModules gets all the modules that are part of this assembly.
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.