private void CompileMappings() { if (autoMappingsCreated) { return; } alterations.Apply(this); var types = sources .SelectMany(x => x.GetTypes()) .OrderBy(x => InheritanceHierarchyDepth(x)); foreach (var type in types) { // skipped by user-defined configuration criteria if (!cfg.ShouldMap(type)) { log.AutomappingSkippedType(type, "Skipped by result of IAutomappingConfiguration.ShouldMap(Type)"); continue; } // skipped by inline where clause if (whereClause != null && !whereClause(type)) { log.AutomappingSkippedType(type, "Skipped by Where clause"); continue; } // skipped because either already mapped elsewhere, or not valid for mapping if (!ShouldMap(type)) { continue; } mappingTypes.Add(new AutoMapType(type)); } log.AutomappingCandidateTypes(mappingTypes.Select(x => x.Type)); foreach (var type in mappingTypes) { if (type.IsMapped) { continue; } AddMapping(type.Type); } autoMappingsCreated = true; }
public void ShouldNotMapCompilerGeneratedClasses() { var anonymous = new { id = 5, title = "Whatever happening" }; configuration.ShouldMap(anonymous.GetType()).ShouldBeFalse(); }