12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- 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; } // TODO
-
- 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 TestModel1 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, PropertyType.Value);
- AddMemberConverter(x => x.Name, y => y.name, PropertyType.Value);
- // AddMemberConverter(x => x.TestDbo2s, y => y.test_model2, PropertyType.Object); // TODO
- 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, PropertyType.Value);
- AddMemberConverter(x => x.Name, y => y.name, PropertyType.Value);
- AddMemberConverter(x => x.NameVirtual, y => y.name + " " + y.name, PropertyType.Value);
- AddMemberConverter(x => x.TestDbo1, y => y.test_model1, PropertyType.Object);
- AddMemberConverter(x => x.Parent, y => y.parent, PropertyType.Object);
- }
- }
- }
|