CSharpTest.Net
IsDefined Method
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Reflection Namespace > PropertyType Class : IsDefined Method

attributeType
inherit

Glossary Item Box

Indicates whether one or more instance of attributeType is defined on this member.

Syntax

Visual Basic (Declaration) 
Public Function IsDefined( _
   ByVal attributeType As Type, _
   ByVal inherit As Boolean _
) As Boolean
C# 
public bool IsDefined( 
   Type attributeType,
   bool inherit
)

Parameters

attributeType
inherit

Example

Library/Library.Test/TestPropertyType.cs

C#Copy Code
PropertyType pt = new PropertyType(typeof(a), "PropertyA");
Assert.IsTrue(pt.IsDefined(typeof(System.ComponentModel.DisplayNameAttribute), false));
Assert.AreEqual(1, pt.GetCustomAttributes(false).Length);
Assert.AreEqual(1, pt.GetCustomAttributes(typeof(System.ComponentModel.DisplayNameAttribute), false).Length);
Assert.AreEqual(0, pt.GetCustomAttributes(typeof(System.ComponentModel.DesignOnlyAttribute), false).Length);
VB.NETCopy Code
Dim pt As New PropertyType(GetType(a), "PropertyA")
Assert.IsTrue(pt.IsDefined(GetType(System.ComponentModel.DisplayNameAttribute), False))
Assert.AreEqual(1, pt.GetCustomAttributes(False).Length)
Assert.AreEqual(1, pt.GetCustomAttributes(GetType(System.ComponentModel.DisplayNameAttribute), False).Length)
Assert.AreEqual(0, pt.GetCustomAttributes(GetType(System.ComponentModel.DesignOnlyAttribute), False).Length)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Generated with Document! X 2011 by Innovasys