转移.net core 3.1,为.NET 5做准备

This commit is contained in:
ÂëÉñ
2020-10-22 14:59:36 +08:00
parent fd9bca23a7
commit a35d596237
1080 changed files with 175912 additions and 185681 deletions

View File

@@ -0,0 +1,50 @@
using System;
using System.Collections.Generic;
using NUnit.Framework;
namespace Infrastructure.Test
{
class TestAutoMapper
{
[Test]
public void TestConvert()
{
var my = new MyClass
{
Name = "yubao"
};
var dest = my.MapTo<DestClass>();
Console.WriteLine(JsonHelper.Instance.Serialize(dest));
}
[Test]
public void TestConvertList()
{
var users = new List<MyClass> {
new MyClass {Name = "yubaolee1"}
, new MyClass{Name = "yubaolee2"}
};
var dest = users.MapToList<MyClass, DestClass>();
Console.WriteLine(JsonHelper.Instance.Serialize(dest));
var dest2 = users.MapToList<DestClass>();
Console.WriteLine(JsonHelper.Instance.Serialize(dest2));
}
}
class MyClass
{
public string Name { get; set; }
public string NickName { get; set; }
}
class DestClass
{
public string Name { get; set; }
public int Age { get; set; }
}
}

View File

@@ -0,0 +1,54 @@
using System;
using System.Linq.Expressions;
using NUnit.Framework;
namespace Infrastructure.Test
{
public class TestDynamicLinq
{
[Test]
public void Convert()
{
FilterGroup sub = new FilterGroup
{
Operation = "or"
};
sub.Filters = new[]
{
new Filter {Key = "name", Value = "name", Contrast = "=="},
new Filter {Key = "c3", Value = "10,20,30", Contrast = "in"}
};
FilterGroup filterGroup = new FilterGroup
{
Operation = "and"
};
filterGroup.Filters = new[]
{
new Filter {Key = "c1", Value = "name", Contrast = "contains"},
new Filter {Key = "10,20,30", Value = "40", Contrast = "intersect"}
};
filterGroup.Children = new[]
{
sub
};
var expression = DynamicLinq.ConvertGroup<TestOjb>(filterGroup,
Expression.Parameter(typeof(TestOjb), "c"));
Console.WriteLine(expression.ToString());
}
}
public class TestOjb{
public string c1 { get; set; }
public string c2 { get; set; }
public string c3 { get; set; }
public string c4 { get; set; }
public string c5 { get; set; }
public string c6 { get; set; }
public string c7 { get; set; }
}
}