Created
March 18, 2010 23:13
-
-
Save jfromaniello/337035 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
//A way to map WellKnownInstaceType ( http://fabiomaulo.blogspot.com/2009/08/from-db-to-ram-wellknowinstancetype.html ) | |
//artifact | |
public class WellKnownInstancePattern<TType, TWellKnownInstanceType> | |
: IPatternApplier<MemberInfo, IPropertyMapper> | |
where TWellKnownInstanceType : WellKnownInstanceType<TType> | |
where TType : class | |
{ | |
public bool Match(MemberInfo subject) | |
{ | |
return subject.GetPropertyOrFieldType().Equals(typeof (TType)); | |
} | |
public void Apply(MemberInfo subject, IPropertyMapper applyTo) | |
{ | |
applyTo.Type<TWellKnownInstanceType>(); | |
} | |
} | |
//usage | |
public void RegisterPatterns(Mapper mapper) | |
{ | |
mapper.PatternsAppliers.Property.Add(new WellKnownInstancePattern<Country, CountryType>()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment