Created
February 11, 2017 12:20
-
-
Save rmaziarka/ed9f090da11d3a68023872e2c6e8b6b0 to your computer and use it in GitHub Desktop.
Resolver with proper order
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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