12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- using System;
- using System.Collections.Generic;
- using System.Linq.Expressions;
- using Luticate2.Auth.Utils.Business.Converters.ObjectConverterDescriptor;
-
- namespace Luticate2.Auth.Tests.Business.ObjectConverter
- {
- public static class StaticDbo
- {
- public static bool StaticField;
-
- public static bool StaticProperty { get; set; }
- }
-
- public class TestDbo1
- {
- public Guid Id { get; set; }
-
- public string Name { get; set; }
-
- public IList<TestDbo2> TestDbo2s { get; set; }
-
- public override string ToString()
- {
- throw new NotImplementedException();
- }
- }
-
- public class TestDbo2
- {
- public Guid Id { get; set; }
-
- public string Name { get; set; }
-
- public string NameVirtual { get; set; }
-
- public TestDbo1 TestDbo1 { get; set; }
-
- public TestDbo2 Parent { get; set; }
-
- public TestDbo1 Unused { get; set; }
-
- public int NotOptionalInt { get; set; }
- }
-
- public class TestModel1
- {
- public Guid id { get; set; }
-
- public string name { get; set; }
-
- public ICollection<TestModel2> test_model2 { get; set; }
- }
-
- public class TestModel2
- {
- public Guid id { get; set; }
-
- public string name { get; set; }
-
- public Guid test_model1_id { get; set; }
-
- public TestModel1 test_model1 { get; set; }
-
- public TestModel2 parent { get; set; }
-
- public int? optional_int { get; set; }
- }
-
- public class LuOcdTest1 : LuObjectConverterDescriptor<TestDbo1, TestModel1>
- {
- public LuOcdTest1()
- {
- AddStaticMemberConverter(x => x.Id, y => y.id);
- AddStaticMemberConverter(x => x.Name, y => y.name);
- AddStaticMemberConverter(x => x.TestDbo2s, y => y.test_model2);
- AddStaticMethodConverter(
- (Expression<Func<TestDbo1, string>>)(x => x.ToString()),
- (Expression<Func<TestModel1, string>>)(x => x.id + ": " + x.name)
- );
- }
- }
-
- public class LuOcdTest2 : LuObjectConverterDescriptor<TestDbo2, TestModel2>
- {
- public LuOcdTest2()
- {
- AddStaticMemberConverter(x => x.Id, y => y.id);
- AddStaticMemberConverter(x => x.Name, y => y.name);
- AddStaticMemberConverter(x => x.NameVirtual, y => y.name + " " + y.name);
- AddStaticMemberConverter(x => x.TestDbo1, y => y.test_model1);
- AddStaticMemberConverter(x => x.Parent, y => y.parent);
- AddStaticMemberConverter(x => x.NotOptionalInt, y => y.optional_int ?? -1);
- AddNullMemberConverter<TestDbo1>(x => x.Unused);
- }
- }
- }
|