1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- using System;
- using System.Collections.Generic;
- using System.Linq.Expressions;
- using Luticate2.Auth.Utils.Business.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 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 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 class LuOcdTest1 : LuObjectConverterDescriptor<TestDbo1, TestModel1>
- {
- public LuOcdTest1()
- {
- AddMemberConverter(x => x.Id, y => y.id);
- AddMemberConverter(x => x.Name, y => y.name);
- AddMemberConverter(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()
- {
- AddMemberConverter(x => x.Id, y => y.id);
- AddMemberConverter(x => x.Name, y => y.name);
- AddMemberConverter(x => x.NameVirtual, y => y.name + " " + y.name);
- AddMemberConverter(x => x.TestDbo1, y => y.test_model1);
- AddMemberConverter(x => x.Parent, y => y.parent);
- AddMemberConverter((LambdaExpression) (Expression<Func<TestDbo2, TestDbo1>>) (x => x.Unused), (Expression<Func<TestModel2, TestModel1>>) (y => null));
- }
- }
- }
|