in wwauth/Google.Solutions.WWAuth/View/BindingExtensions.cs [60:89]
public static Binding OnControlPropertyChange<TControl, TProperty>(
this TControl observed,
Expression<Func<TControl, TProperty>> controlProperty,
Action<TProperty> newValue)
where TControl : IComponent
{
Debug.Assert(controlProperty.NodeType == ExpressionType.Lambda);
if (controlProperty.Body is MemberExpression memberExpression &&
memberExpression.Member is PropertyInfo propertyInfo)
{
// Look for a XxxChanged event.
var changedEvent = typeof(TControl).GetEvent(propertyInfo.Name + "Changed");
if (changedEvent == null)
{
throw new ArgumentException(
$"Cannot observe {propertyInfo.Name} because class does not " +
"provide an appropriate event");
}
return new EventHandlerBinding<TControl, TProperty>(
observed,
changedEvent,
controlProperty.Compile(),
newValue);
}
else
{
throw new ArgumentException("Expression does not resolve to a property");
}
}