Skip to content

Instantly share code, notes, and snippets.

@Beej126
Created April 16, 2020 15:43
Show Gist options
  • Select an option

  • Save Beej126/2a81e69673d9754ad675becf776ee5e6 to your computer and use it in GitHub Desktop.

Select an option

Save Beej126/2a81e69673d9754ad675becf776ee5e6 to your computer and use it in GitHub Desktop.
c# ternary fluent builder
public static class AuthorizationPolicyBuilderExtensions
{
//https://devio.wordpress.com/2014/02/07/conditions-in-fluent-interface-method-chaining/
public static T Ternary<T>(this T t, bool cond, Func<T, T> ifTrue, Func<T, T> ifFalse)
where T : AuthorizationPolicyBuilder => cond ? ifTrue(t) : ifFalse(t);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment