Param public static void setpropertyvalueobject obj

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: Property(obj, propertyName); } else { if (obj is IDictionary) { value = ((IDictionary) obj)[propertyName]; } else { PropertyInfo propertyInfo = reflectionCache.GetGetter(propertyName); if (propertyInfo == null) { throw new ProbeException("No Get method for property " + propertyName + " on instance of " + obj.GetType().Name); } try { value = propertyInfo.GetValue(obj, null); } catch (ArgumentException ae) { throw new ProbeException(ae); } catch (TargetException t) { throw new ProbeException(t); } catch (TargetParameterCountException tp) { throw new ProbeException(tp); } catch (MethodAccessException ma) { throw new ProbeException(ma); } } } return value; } catch (ProbeException pe) { throw pe; } catch(Exception e) { throw new ProbeException("Could not Set property '" + propertyName + "' for " + obj.GetType().Name + ". Cause: " + e.Message, e); } } private static void SetArrayProperty(object obj, string indexedName, object value) { try { int startIndex = indexedName.IndexOf("["); int length = indexedName.IndexOf("]"); string name = indexedName.Substring(0, startIndex); string index = indexedName.Substring( startIndex+1, length-(startIndex+1)); int i = System.Convert.ToInt32(index); object list = null; if (name.Length > 0) { list = GetProperty(obj, name); } else { list = obj; } if (list is IList) { ((IList) list)[i] = value; } else { throw new ProbeException("The '" + name + "' property of the " + obj.GetType().Name + " class is not a List or Array."); } } catch (ProbeException pe) { throw pe; } catch (Exception e) { throw new ProbeException("Error getting ordinal value from .net object. Cause" + e.Message, e); } } /// <summary> /// /// </summary> /// <param name="obj"></param> /// <param name="propertyName"></param> /// <param name="propertyValue"></param> protected static void Set...
View Full Document

Ask a homework question - tutors are online