Created
February 9, 2009 23:29
-
-
Save jagregory/61097 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
| // special interface for overriding automaps | |
| public interface IMappingOverride<T> | |
| { | |
| void Override(AutoMap<T> mapping); | |
| } | |
| // special config chunk for using above | |
| public class SupplyMappingOverridesChunk : IAutoMappingConfigChunk | |
| { | |
| private readonly Assembly assembly; | |
| public SupplyMappingOverridesChunk(Assembly overridesAssembly) | |
| { | |
| assembly = overridesAssembly; | |
| } | |
| public void Configure(AutoPersistenceModel model) | |
| { | |
| foreach (var type in assembly.GetTypes()) | |
| { | |
| if (!type.IsSubclassOf(typeof(IMappingOverride<>))) continue; | |
| // create auto map for type, and execute the | |
| // IMappingOverride<T>.Override method against it | |
| model.AddMapping(mapping); | |
| } | |
| } | |
| } | |
| // which is used through this on the AutoPersistenceModel | |
| public AutoPersistenceModel WithMappingOverridesFromAssemblyOf<T>() | |
| { | |
| return WithConfigurationChunk(new SupplyMappingOverridesChunk(typeof(T).Assembly)); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment