You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Objects.cs 2.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq.Expressions;
  4. using Luticate2.Auth.Utils.Business.ObjectConverterDescriptor;
  5. namespace Luticate2.Auth.Tests.Business.ExpressionConverter
  6. {
  7. public static class StaticDbo
  8. {
  9. public static bool StaticField;
  10. public static bool StaticProperty { get; set; }
  11. }
  12. public class TestDbo1
  13. {
  14. public Guid Id { get; set; }
  15. public string Name { get; set; }
  16. public IList<TestDbo2> TestDbo2s { get; set; }
  17. public string ToString()
  18. {
  19. throw new NotImplementedException();
  20. }
  21. }
  22. public class TestDbo2
  23. {
  24. public Guid Id { get; set; }
  25. public string Name { get; set; }
  26. public string NameVirtual { get; set; }
  27. public TestDbo1 TestDbo1 { get; set; }
  28. public TestDbo2 Parent { get; set; }
  29. public TestModel1 Unused { get; set; }
  30. }
  31. public class TestModel1
  32. {
  33. public Guid id { get; set; }
  34. public string name { get; set; }
  35. public ICollection<TestModel2> test_model2 { get; set; }
  36. }
  37. public class TestModel2
  38. {
  39. public Guid id { get; set; }
  40. public string name { get; set; }
  41. public Guid test_model1_id { get; set; }
  42. public TestModel1 test_model1 { get; set; }
  43. public TestModel2 parent { get; set; }
  44. }
  45. public class LuOcdTest1 : LuObjectConverterDescriptor<TestDbo1, TestModel1>
  46. {
  47. public LuOcdTest1()
  48. {
  49. AddMemberConverter(x => x.Id, y => y.id, PropertyType.Value);
  50. AddMemberConverter(x => x.Name, y => y.name, PropertyType.Value);
  51. AddMemberConverter(x => x.TestDbo2s, y => y.test_model2, PropertyType.Object);
  52. AddStaticMethodConverter(
  53. (Expression<Func<TestDbo1, string>>)(x => x.ToString()),
  54. (Expression<Func<TestModel1, string>>)(x => x.id + ": " + x.name)
  55. );
  56. }
  57. }
  58. public class LuOcdTest2 : LuObjectConverterDescriptor<TestDbo2, TestModel2>
  59. {
  60. public LuOcdTest2()
  61. {
  62. AddMemberConverter(x => x.Id, y => y.id, PropertyType.Value);
  63. AddMemberConverter(x => x.Name, y => y.name, PropertyType.Value);
  64. AddMemberConverter(x => x.NameVirtual, y => y.name + " " + y.name, PropertyType.Value);
  65. AddMemberConverter(x => x.TestDbo1, y => y.test_model1, PropertyType.Object);
  66. AddMemberConverter(x => x.Parent, y => y.parent, PropertyType.Object);
  67. }
  68. }
  69. }