public static FluentMappingsContainer AddFromAssemblyOf <T>(this FluentMappingsContainer mappings, Predicate <Type> where) { if (where == null) { return(mappings.AddFromAssemblyOf <T>()); } var mappingClasses = typeof(T).Assembly.GetExportedTypes() .Where(x => (typeof(IMappingProvider).IsAssignableFrom(x) || typeof(IIndeterminateSubclassMappingProvider).IsAssignableFrom(x))) .Where(x => where (x)); foreach (var type in mappingClasses) { mappings.Add(type); } return(mappings); }
// http://stackoverflow.com/q/6204511/206297 public static FluentMappingsContainer AddFromAssemblyOf <T>(this FluentMappingsContainer mappings, Predicate <Type> where) { if (where == null) { return(mappings.AddFromAssemblyOf <T>()); } var mappingClasses = typeof(T).Assembly.GetExportedTypes() .Where(x => IsMappingOf <IMappingProvider>(x) || IsMappingOf <IIndeterminateSubclassMappingProvider>(x) || IsMappingOf <IExternalComponentMappingProvider>(x) || IsMappingOf <IFilterDefinition>(x)) .Where(x => where (x)); foreach (var type in mappingClasses) { mappings.Add(type); } return(mappings); }