Skip to content

Instantly share code, notes, and snippets.

@AlexArchive
Created September 3, 2014 13:49
Show Gist options
  • Save AlexArchive/8f1ea0103e67d4a864c5 to your computer and use it in GitHub Desktop.
Save AlexArchive/8f1ea0103e67d4a864c5 to your computer and use it in GitHub Desktop.
Every day expressions
public static class ExtensionMethod
{
public static void SetValue<T>(
this T target,
Expression<Func<T, object>> expression, object value) where T : Control
{
var memberExpression = expression.Body as MemberExpression;
if (memberExpression != null)
{
var property = memberExpression.Member as PropertyInfo;
if (property != null)
{
property.SetValue(target, value, null);
}
Control control = target;
control.Invalidate();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment