/// <summary> /// The subsequent Bind* operations only apply when the Attribute's property is not null. /// </summary> /// <param name="propertyName"></param> /// <returns></returns> public FluentBindingRule <TAttribute> When <TValue>(string propertyName, TValue expectedEnumValue) { var prop = ResolveProperty(propertyName); // C# doesn't allow generic enum constraints. Must enforce at runtime. if (!typeof(TValue).IsEnum) { throw new InvalidOperationException($"Rule filter for '{propertyName}' can only be used with enums."); } AppendFilter(FilterNode.IsEqual(prop, expectedEnumValue)); return(this); }