コード例 #1
0
        public void AutoMapperService_GivenLineSourceTypeObject_ReturnLineTargetTypeObject()
        {
            //Arrange
            var eId        = "000";
            var eAppSecret = "appsecret1234";
            var eIsUsed    = true;

            var channelInfoSourceObj = new LineChannelInfoSourceType()
            {
                Id     = eId,
                IsUsed = eIsUsed
            };

            var facebookUserSourceObj = new FacebookUserSourceType
            {
                Id = "111",
            };

            //Act
            var channelInfoResult = _autoMapperService.Map <LineChannelInfoSourceType, LineChannelInfoViewModel>(channelInfoSourceObj);

//            var userResult = _autoMapperService.Map<FacebookUserSourceType, FacebookUserTargetType>(facebookUserSourceObj);

            //Assert
            channelInfoResult.GetType().ShouldBe(typeof(LineChannelInfoViewModel));
            channelInfoResult.Id.ShouldBe(eId);
            channelInfoResult.IsUsed.ShouldBe(eIsUsed);

//            userResult.GetType().ShouldBe(typeof(FacebookUserTargetType));
//            userResult.Id.ShouldBe("111");
        }
コード例 #2
0
        public IActionResult Index(string query)
        {
            ArticleModel article = new ArticleModel();

            if (query != null)
            {
                ArticleDto result = articleRepository.FindByConditionAsync(x => x.Url == query).Result.FirstOrDefault();
                article = _mapperService.Map <ArticleModel, ArticleDto>(result);
            }
            return(View(article));
        }
コード例 #3
0
        public async Task <ActionResult <IEnumerable <ArticleDto> > > GetArticle()
        {
            try
            {
                FilterModel filterModel = FilterFormData();
                var         data        = await filter(filterModel);

                var result = _mapperService.Map <IEnumerable <ArticleModel>, IEnumerable <ArticleDto> >(data);
                return(JsonResult(result, true));
            }
            catch (Exception ex)
            {
                return(JsonResult(ex, false));
            }
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: lqyxt/fxchat
        static void Main(string[] args)
        {
            List <APIModel.JsonChatMessage> ListsModel = new List <APIModel.JsonChatMessage>();

            for (int i = 0; i < 20; i++)
            {
                APIModel.JsonChatMessage msg1 = new APIModel.JsonChatMessage();
                msg1.ChatMsgContent = new APIModel.ChatMsgContent()
                {
                    CmType               = APIModel.ChatMsgType.TXT,
                    LongMsgDateTime      = "",
                    MsgContent           = "消息记录123123123123",
                    MsgDateTime          = DateTime.Now,
                    UniqueIdentification = Guid.NewGuid().ToString(),
                    AtUsers              = new List <APIModel.Receiver>()
                };
                msg1.ChatMsgContent.AtUsers.Add(new APIModel.Receiver()
                {
                    ReceiverID = "123123"
                });
                msg1.CType    = APIModel.ChatType.PersonChat;
                msg1.Receiver = new APIModel.Receiver();
                msg1.Sender   = new APIModel.Sender();

                ListsModel.Add(msg1);
            }


            automapperservice.RegisterMapper("JsonPropertyTest.AutoMap");

            Stopwatch watch = new Stopwatch();

            watch.Start();
            var cachemsg = automapperservice.Map <List <RedisModel.JsonChatMessage> >(ListsModel);

            watch.Stop();
            Console.WriteLine(watch.ElapsedMilliseconds);
            Console.ReadKey();
        }