eightHundreds
12/7/2017 - 4:23 AM

SetPrivateProperty

 public static void SetPrivateProperty<T>(object instance, string proName, object value)
        {
            var type = typeof(T);
            var propertyInfo = type.GetProperty(proName, BindingFlags.Instance|BindingFlags.NonPublic|BindingFlags.Public);
            propertyInfo.SetValue(instance, Convert.ChangeType(value, propertyInfo.PropertyType));
        }