Getinstanceobjgettype try object value null if

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: eflectionInfo.GetInstance(type).GetSetterType(propertyName); } } return type; } /// <summary> /// Returns the type that the set expects to receive as a parameter when /// setting a property value. /// </summary> /// <param name="type">The type to check</param> /// <param name="propertyName">The name of the property</param> /// <returns>The type of the property</returns> private static Type GetPropertyTypeForSetter(Type type, string propertyName) { if (propertyName.IndexOf('.') > -1) { StringTokenizer parser = new StringTokenizer(propertyName, "."); IEnumerator enumerator = parser.GetEnumerator(); while (enumerator.MoveNext()) { propertyName = (string)enumerator.Current; type = ReflectionInfo.GetInstance(type).GetSetterType(propertyName); } } else { type = ReflectionInfo.GetInstance(type).GetSetterType(propertyName); } return type; } /// <summary> /// Returns the type that the get expects to receive as a parameter when /// setting a property value. /// </summary> /// <param name="obj">The object to check</param> /// <param name="propertyName">The name of the property</param> /// <returns>The type of the property</returns> public static Type GetPropertyTypeForGetter(object obj, string propertyName) { Type type = obj.GetType(); if (obj is IDictionary) { IDictionary map = (IDictionary) obj; object value = map[propertyName]; if (value == null) { type = typeof(object); } else { type = value.GetType(); } } else { if (propertyName.IndexOf('.') > -1) { StringTokenizer parser = new StringTokenizer(propertyName, "."); IEnumerator enumerator = parser.GetEnumerator(); while (enumerator.MoveNext()) { propertyName = (string)enumerator.Current; type = ReflectionInfo.GetInstance(type).GetGetterType(propertyName); } } else { type = ReflectionInfo.GetInstance(type).GetGetterType(propertyName); } } return type; } /// <summary> /// Returns the type that the get expects to receive as a par...
View Full Document

This document was uploaded on 10/12/2012.

Ask a homework question - tutors are online