public static TargetMapping DeriveMapping(string targetName, string prefix, TypeInfo typeInfo) { TargetMapping mapping = null; var baseTypes = typeInfo.GetAllBaseTypes().Where(x => x.IsGenericType); var firstGenericType = baseTypes.First(); // TODO: Consider root and namespace layers or nested types, when problems are better understood if (TryGetMapping(firstGenericType, typeof(CodeFirstMetadataNamespace<>), typeof(TargetNamespaceMapping<>), targetName, prefix, ref mapping)) return mapping; if (TryGetMapping(firstGenericType, typeof(CodeFirstMetadataClass<>), typeof(TargetClassMapping<>), targetName, prefix, ref mapping)) return mapping; if (TryGetMapping(firstGenericType, typeof(CodeFirstMetadataMethod<>), typeof(TargetMethodMapping<>), targetName, prefix, ref mapping)) return mapping; if (TryGetMapping(firstGenericType, typeof(CodeFirstMetadataProperty<>), typeof(TargetPropertyMapping<>), targetName, prefix, ref mapping)) return mapping; if (TryGetMapping(firstGenericType, typeof(CodeFirstMetadataParameter<>), typeof(TargetParameterMapping<>), targetName, prefix, ref mapping)) return mapping; throw new NotImplementedException(); }