Skip to content

Instantly share code, notes, and snippets.

@rmaziarka
Created February 11, 2017 12:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rmaziarka/d7778d0ae7d3f2e58a1879f4678c4e2e to your computer and use it in GitHub Desktop.
Save rmaziarka/d7778d0ae7d3f2e58a1879f4678c4e2e to your computer and use it in GitHub Desktop.
Resolver with improper 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