Skip to content

Instantly share code, notes, and snippets.

@pjmagee
Last active August 29, 2015 14:04
Show Gist options
  • Select an option

  • Save pjmagee/32d35cf2c6f145efdf12 to your computer and use it in GitHub Desktop.

Select an option

Save pjmagee/32d35cf2c6f145efdf12 to your computer and use it in GitHub Desktop.
public static void PerformAs<TOut>(this IEntity item, Action<TOut> perform) where TOut : class, IEntity
{
var conversionResult = item as TOut;
conversionResult.Perform(converted => perform(converted));
}
public static IEnumerable<T> OrEmptyIfNull<T>(this IEnumerable<T> source)
{
return source ?? Enumerable.Empty<T>();
}
// Current
(owner as RetainedOrg).Perform(o => o.BusinessUnit.HasValue());
// Extension
owner.PerformAs<RetainedOrg>(o => o.BusinessUnit.HasValue());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment