/src/Otis.Tests/MappingPreparerDTO.cs

http://otis-lib.googlecode.com/ · C# · 70 lines · 61 code · 9 blank · 0 comment · 0 complexity · e4489f1fd95b29b1e8ba3362c0d7e0e9 MD5 · raw file

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using Otis.Tests.Entity;
  5. namespace Otis.Tests
  6. {
  7. [MapClass(typeof(User), Preparer = "Otis.Tests.Util.Convert")]
  8. public class MappingPreparerDTO_Duplicate
  9. {
  10. [Map("$Id")]
  11. public int Id;
  12. [MappingPreparer]
  13. public void Preparer(ref MappingPreparerDTO_Duplicate dto, ref User user)
  14. { }
  15. }
  16. [MapClass(typeof(User))]
  17. public class MappingPreparerDTO_NonPublic
  18. {
  19. [Map("$Id")]
  20. public int Id;
  21. [MappingPreparer]
  22. void Preparer(ref MappingPreparerDTO_NonPublic dto, ref User user) { }
  23. }
  24. [MapClass(typeof(User))]
  25. public class MappingPreparerDTO_InstancePreparer
  26. {
  27. [Map("$Id")]
  28. public int Id;
  29. public string FullName;
  30. [MappingPreparer]
  31. public void Preparer(ref MappingPreparerDTO_InstancePreparer dto, ref User user)
  32. {
  33. dto.FullName = "custom_mapping_InstancePreparer";
  34. }
  35. }
  36. [MapClass(typeof(User), Preparer = "Otis.Tests.MappingPreparerTestConverter.Convert")]
  37. public class MappingPreparerDTO_StaticPreparer
  38. {
  39. [Map("$Id")]
  40. public int Id;
  41. public string FullName;
  42. }
  43. [MapClass(typeof(User))]
  44. public class MappingPreparerDTO_CheckOrder
  45. {
  46. [Map("$Id")]
  47. public int Id;
  48. [MappingPreparer]
  49. public void Preparer(ref MappingPreparerDTO_CheckOrder dto, ref User user)
  50. {
  51. dto.Id = -1;
  52. }
  53. }
  54. public class MappingPreparerTestConverter
  55. {
  56. public static void Convert(ref MappingPreparerDTO_StaticPreparer dto, ref User user)
  57. {
  58. dto.FullName = "custom_mapping_StaticPreparer";
  59. }
  60. }
  61. }