PageRenderTime 112ms CodeModel.GetById 90ms app.highlight 3ms RepoModel.GetById 17ms app.codeStats 0ms

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