This project has moved. For the latest updates, please go here.

DynamicProperty

Change a Property value at run-time without knowing which Property at compile-time

SetPropertyValue()

void SetPropertyValue(string propertyName, object newValue)
Details:
  • Change the Property propertyName of a given Object to the value newValue
  • Will throw an Exception if the Property is not present
  • Will throw an Exception if the Property does not allow writes
Usage:
someObject.SetPropertyValue("Admin", false);
someObject.SetPropertyValue("Name", "Stan");

SetPropertyValue<T>()

void GetPropertyValue<T>(string propertyName)
Details:
  • Get the Property propertyName of a given Object and cast to T
  • Will throw an Exception if the Property is not present
Usage:
bool isAdmin = someObject.GetPropertyValue<bool>("IsAdmin");
string name = someObject.GetPropertyValue<string>("Name");

SetPropertyValue()

void GetPropertyValue(string propertyName)
Details:
  • Get the Property propertyName of a given Object as an Object
  • Will throw an Exception if the Property is not present
Usage:
object isAdmin = someObject.GetPropertyValue("IsAdmin");
object name = someObject.GetPropertyValue("Name");

Last edited Jan 27, 2016 at 6:05 PM by naspinski, version 6

Comments

No comments yet.