public void SetPropertyValue(dynamic instance, string strPropertyName, object newValue) { if (instance.InvokeRequired) { SetPropertyValueDelegate spvd = new SetPropertyValueDelegate(SetPropertyValue); instance.Invoke(spvd, new object[] { instance, strPropertyName, newValue }); } else { Type type = instance.GetType(); PropertyInfo propertyInfo = type.GetProperty(strPropertyName); propertyInfo.SetValue(instance, newValue); } }
public void SetPropertyValue(object instance, PropertyInfo property, object val) { SetPropertyValueDelegate dsv = CreateSetPropertyValueDelegate(instance, property); dsv(instance, val); }