Beispiel #1
0
 /// <summary>
 /// Set the value of property/field this reflection points to
 /// </summary>
 /// <param name="instance">Instance of the object to set the value to, null for static classes</param>
 /// <param name="value">New value</param>
 /// <param name="suppressReadOnly">If true will silently fail for readonly members</param>
 public void SetMember(object instance, object value, bool suppressReadOnly = false)
 {
     CheckInstanceType(instance, SourceInfo.Current());
     CheckValueType(value, SourceInfo.Current());
     if (suppressReadOnly && !Info.CanWrite)
     {
         return;
     }
     Info.Set(instance, value);
 }
Beispiel #2
0
 /// <summary>
 /// Get the value of property/field this reflection points to
 /// </summary>
 /// <param name="instance">Instance of the object to retrieve the value from</param>
 /// <returns>The retrieved value</returns>
 public object GetMember(object instance)
 {
     CheckInstanceType(instance, SourceInfo.Current());
     return(Info.Get(instance));
 }