Skip to content

Instantly share code, notes, and snippets.

@rmaziarka
Created February 11, 2017 12:20
Show Gist options
  • Select an option

  • Save rmaziarka/ed9f090da11d3a68023872e2c6e8b6b0 to your computer and use it in GitHub Desktop.

Select an option

Save rmaziarka/ed9f090da11d3a68023872e2c6e8b6b0 to your computer and use it in GitHub Desktop.
Resolver with proper order
public class Resolver : IValueResolver<object, object, int?>, IValueResolver<object, object, int>
{
public int? Resolve(object source, object destination, int? destMember, ResolutionContext context)
{
var result = SomeLogic(source);
return result;
}
public int Resolve(object source, object destination, int destMember, ResolutionContext context)
{
var result = this.Resolve(source, destination, (int?)destMember, context);
if (result.HasValue)
return result.Value;
throw new NullReferenceException("Resolver");
}
private int? SomeLogic(object source)
{
return 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment