Visual Basic (Declaration) | |
---|---|
Public Shared Function TraverseProperties( _ ByVal fromType As Type, _ ByVal ParamArray propertyNames() As String _ ) As PropertyType |
C# | |
---|---|
public static PropertyType TraverseProperties( Type fromType, params string[] propertyNames ) |
Parameters
- fromType
- Any System.Type object to traverse from
- propertyNames
- The name of the properties or fields usually '.' delimited
Library/Library.Test/TestPropertyType.cs
C# | Copy Code |
---|---|
PropertyType pt; //Any of the following formats can be used pt = PropertyType.TraverseProperties(typeof(b), "publicField.PropertyA.Length"); Assert.AreEqual("Length", pt.Name); Assert.AreEqual(typeof(int), pt.Type); pt = PropertyType.TraverseProperties(typeof(b), "publicField", "PropertyA", "Length"); Assert.AreEqual("Length", pt.Name); Assert.AreEqual(typeof(int), pt.Type); pt = PropertyType.TraverseProperties(typeof(b), "publicField.PropertyA", "Length"); Assert.AreEqual("Length", pt.Name); Assert.AreEqual(typeof(int), pt.Type); pt = PropertyType.TraverseProperties(typeof(b), "publicField/PropertyA\\Length"); Assert.AreEqual("Length", pt.Name); Assert.AreEqual(typeof(int), pt.Type); pt = PropertyType.TraverseProperties(typeof(b), "publicField\\PropertyA", "Length"); Assert.AreEqual("Length", pt.Name); Assert.AreEqual(typeof(int), pt.Type); pt = PropertyType.TraverseProperties(typeof(b), "publicField/PropertyA", "Length"); Assert.AreEqual("Length", pt.Name); Assert.AreEqual(typeof(int), pt.Type); |
VB.NET | Copy Code |
---|---|
Dim pt As PropertyType 'Any of the following formats can be used pt = PropertyType.TraverseProperties(GetType(b), "publicField.PropertyA.Length") Assert.AreEqual("Length", pt.Name) Assert.AreEqual(GetType(Integer), pt.Type) pt = PropertyType.TraverseProperties(GetType(b), "publicField", "PropertyA", "Length") Assert.AreEqual("Length", pt.Name) Assert.AreEqual(GetType(Integer), pt.Type) pt = PropertyType.TraverseProperties(GetType(b), "publicField.PropertyA", "Length") Assert.AreEqual("Length", pt.Name) Assert.AreEqual(GetType(Integer), pt.Type) pt = PropertyType.TraverseProperties(GetType(b), "publicField/PropertyA\Length") Assert.AreEqual("Length", pt.Name) Assert.AreEqual(GetType(Integer), pt.Type) pt = PropertyType.TraverseProperties(GetType(b), "publicField\PropertyA", "Length") Assert.AreEqual("Length", pt.Name) Assert.AreEqual(GetType(Integer), pt.Type) pt = PropertyType.TraverseProperties(GetType(b), "publicField/PropertyA", "Length") Assert.AreEqual("Length", pt.Name) Assert.AreEqual(GetType(Integer), pt.Type) |
Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7
Reference
PropertyType ClassPropertyType Members