首页 > Web开发 > 详细

net core 2.x - rabbitmq 扩展使用

时间:2020-04-28 17:54:46      阅读:68      评论:0      收藏:0      [点我收藏+]

2.x 中使用

rabbitmq

简单封装下,支持直接通过autoInject(sourceType,tagettype,tagettype2)注解方式直接映射,也支持创建profile方式 两种使用方式参考: [Route("TestParamValide")] [HttpPost] public ActionResult TestParamValide([FromBody]ValideModel model) { var sysDic = model.MapTo(); return null; }

两种使用方式:

// -----------------------------------------------------------------------
// <copyright file="MqSettings.cs" company="禾卓软件科技有限公司">
// Copyright (c) 2020 禾卓软件科技有限公司. All rights reserved.
// </copyright>
// <last-editor>谭明超 - 2020/4/28 16:29:38 </last-editor>
// -----------------------------------------------------------------------


[Route("TestParamValideMapperProfile")] [HttpPost] public ActionResult<object> TestParamValideMapperProfile([FromBody]ValideModel2 model) { var sysDic = model.MapTo<SysDictionary>(); return null; } //方式一:直接使用AutoInject [AutoInject(typeof(SysDictionary), typeof(ValideModel))] public class ValideModel : Infrastructure.Mapper.DTO { [Required(ErrorMessage = "{0}不可为空")] public string Code { get; set; } } public class ValideModel2 : Infrastructure.Mapper.DTO { [Required(ErrorMessage = "{0}不可为空")] public string Code { get; set; } } //方式二:创建Profile public class ValideModelMapperProfile : Profile, IMapperProfile { public ValideModelMapperProfile() { CreateMap<SysDictionary, ValideModel2>().ReverseMap(); } }

源码地址:

https://github.com/tanmingchao/automapper/tree/master

   

net core 2.x - rabbitmq 扩展使用

原文:https://www.cnblogs.com/Tmc-Blog/p/12795633.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!