tests/MapperPerformanceTest/Program.cs

(开头部分) 39KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Linq.Expressions;
using System.Threading;
using DotNetCommon;
using DotNetCommon.Data;
using DotNetCommon.Extensions;

namespace ConsoleTest
{
    public class Program
    {
        static void Main(string[] args)
        {
            // 简单类型转换(比对4种方式: src/dotnetcommon/automapper/jsonserial )
            Test1();
            // 循环引用(比对2种方式: dotnetcommon / automapper)
            Test3();
            // 嵌套(比对4种方式: src / dotnetcommon / automapper / jsonserial)
            Test4();
            // 树状结构(比对3种方式: dotnetcommon / automapper / jsonserial)
            Test5();
            Console.WriteLine("比对完成!");
            Console.Read();
        }

        #region 简单转换 Person => PersonDto 同类型属性17个 无嵌套类型
        private static void Test1()
        {
            Console.WriteLine();

            var person = new Person()
            {
                Id = 1,
                Name = "Test",
                Addr = "天明路",
                Age = 18,
                Description = "描述",
                Email = "123456789@qq.com",
                IdentityNo = "410123200001021234",
                Intro = "个性签名",
                Nick = "昵称",
                Phone = "15012345678",
                Picture = "https://iconfont.alicdn.com/t/ff73b7fb-7199-4356-8d10-5dd133bac7a9.png",
                Birth = DateTime.Parse("2000-01-02"),
                QQ = "123456789",
                Score = 98.5,
                Sex = EnumSex.Male,
                WeiXin = "weixinname",
                Books = new List<string> { "语文", "数学" },
            };

            var list = new List<Person>();
            for (var i = 0; i < 100; i++) list.Add(person.ToJson().ToObject<Person>());

            //手写代码
            Console.WriteLine();
            Console.WriteLine($"SrcMapper---------------------------List<Person>[Count=100] => List<PersonDto>-------------------------------");
后面还有 784 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。