public static ISingleObjectBuilder<T> WithPrivate<T, TProperty>(this
ISingleObjectBuilder<T> b, Expression<Func<T, TProperty>> property,
TProperty value)
{
b.Do(x => ((PropertyInfo)
((MemberExpression)property.Body).Member).SetValue(x, value, null));
return b;
}
More and more I'm striving to encapsulate my domain entities.
Generally, this means I setup state via methods, but sometimes it's
easier to just set a private property. This extension solves that
problem for me.
What do you think?
Tim Scott