/// <summary> /// 加载映射配置文件 /// </summary> /// <typeparam name="TEntity">实体类型</typeparam> /// <typeparam name="TMappingProfile">映射配置文件类型</typeparam> public static void LoadMappingProfile <TEntity, TMappingProfile>() where TMappingProfile : IMappingProfile <TEntity>, new() { var profile = new TMappingProfile(); profile.Configure(InternalHelper.GetExcelConfigurationMapping <TEntity>()); }
/// <summary> /// 加载映射配置文件 /// </summary> /// <typeparam name="TEntity">实体类型</typeparam> /// <param name="profile">映射配置文件</param> public static void LoadMappingProfile <TEntity>(IMappingProfile <TEntity> profile) { if (profile == null) { throw new ArgumentNullException(nameof(profile)); } profile.Configure(InternalHelper.GetExcelConfigurationMapping <TEntity>()); }
/// <summary> /// 加载映射配置文件 /// </summary> /// <param name="profile">映射配置文件</param> private static void LoadMappingProfile(IMappingProfile profile) { if (profile == null) { throw new ArgumentNullException(nameof(profile)); } var profileInterfaceType = profile.GetType() .GetTypeInfo() .ImplementedInterfaces .FirstOrDefault(x => x.IsGenericType && x.GetGenericTypeDefinition() == ProfileGenericTypeDefinition); if (profileInterfaceType == null) { return; } var entityType = profileInterfaceType.GetGenericArguments()[0]; var configuration = InternalHelper.GetExcelConfigurationMapping(entityType); var method = profileInterfaceType.GetMethod(MappingProfileConfigureMethodName, new[] { typeof(IExcelConfiguration <>).MakeGenericType(entityType) }); method?.Invoke(profile, new object[] { configuration }); }
/// <summary> /// 获取指定实体配置入口点 /// </summary> /// <typeparam name="TEntity">实体类型</typeparam> public static IExcelConfiguration <TEntity> For <TEntity>() => InternalHelper.GetExcelConfigurationMapping <TEntity>();