Advertisement
Guest User

Untitled

a guest
Jul 26th, 2016
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.31 KB | None | 0 0
  1. (src, dest, ctxt) =>
  2. {
  3. return (src == null)
  4. ? null
  5. : {
  6. var typeMapDestination = dest ?? new DeepTypeMapper.CustomerDTO();
  7. try
  8. {
  9. var resolvedValue = ((false | (src == null)) | (src.Address == null)) ? null : src.Address.City;
  10. typeMapDestination.AddressCity = resolvedValue;
  11. }
  12. catch (Exception ex)
  13. {
  14. throw new AutoMapperMappingException("Error mapping types.", ex, AutoMapper.TypePair, AutoMapper.TypeMap, AutoMapper.PropertyMap);
  15. }
  16.  
  17. try
  18. {
  19. var resolvedValue = (false | (src == null)) ? null : src.WorkAddresses;
  20. typeMapDestination.WorkAddresses =
  21. {
  22. var passedDestination = (dest == null) ? null : typeMapDestination.WorkAddresses;
  23. var collectionDestination = (passedDestination != null) ? passedDestination : new List<DeepTypeMapper.AddressDTO>();
  24. return (resolvedValue == null)
  25. ? collectionDestination
  26. : {
  27. var enumerator = resolvedValue.GetEnumerator();
  28. while (true)
  29. {
  30. if (enumerator.MoveNext())
  31. {
  32. var item = enumerator.Current;
  33. collectionDestination.Add(
  34. (item == null)
  35. ? null
  36. : {
  37. var typeMapDestination = null ?? new DeepTypeMapper.AddressDTO();
  38. try
  39. {
  40. var resolvedValue = (false | (item == null)) ? null : item.Country;
  41. typeMapDestination.Country = resolvedValue;
  42. }
  43. catch (Exception ex)
  44. {
  45. throw new AutoMapperMappingException("Error mapping types.", ex, AutoMapper.TypePair, AutoMapper.TypeMap, AutoMapper.PropertyMap);
  46. }
  47.  
  48. try
  49. {
  50. var resolvedValue = (false | (item == null)) ? null : item.City;
  51. typeMapDestination.City = resolvedValue;
  52. }
  53. catch (Exception ex)
  54. {
  55. throw new AutoMapperMappingException("Error mapping types.", ex, AutoMapper.TypePair, AutoMapper.TypeMap, AutoMapper.PropertyMap);
  56. }
  57.  
  58. try
  59. {
  60. var resolvedValue = (false | (item == null)) ? default(int) : item.Id;
  61. typeMapDestination.Id = resolvedValue;
  62. }
  63. catch (Exception ex)
  64. {
  65. throw new AutoMapperMappingException("Error mapping types.", ex, AutoMapper.TypePair, AutoMapper.TypeMap, AutoMapper.PropertyMap);
  66. }
  67.  
  68. return typeMapDestination;
  69. });
  70. }
  71. else
  72. {
  73. break;
  74. }
  75. }
  76.  
  77. return collectionDestination;
  78. return }
  79. };
  80. }
  81. catch (Exception ex)
  82. {
  83. throw new AutoMapperMappingException("Error mapping types.", ex, AutoMapper.TypePair, AutoMapper.TypeMap, AutoMapper.PropertyMap);
  84. }
  85.  
  86. try
  87. {
  88. var resolvedValue = (false | (src == null)) ? null : src.Addresses;
  89. typeMapDestination.Addresses = (resolvedValue == null)
  90. ? new DeepTypeMapper.AddressDTO[0]
  91. : {
  92. var count = resolvedValue.Count();
  93. var destinationArray = new DeepTypeMapper.AddressDTO[count];
  94. var destinationArrayIndex = 0;
  95. var sourceArrayIndex = 0;
  96. while (true)
  97. {
  98. if (sourceArrayIndex < resolvedValue.Length)
  99. {
  100. var item = resolvedValue[sourceArrayIndex];
  101. destinationArray[destinationArrayIndex++] =
  102. {
  103. return (item == null)
  104. ? null
  105. : {
  106. typeMapDestination = null ?? new DeepTypeMapper.AddressDTO();
  107. try
  108. {
  109. resolvedValue = (false | (item == null)) ? null : item.Country;
  110. typeMapDestination.Country = resolvedValue;
  111. }
  112. catch (Exception ex)
  113. {
  114. throw new AutoMapperMappingException("Error mapping types.", ex, AutoMapper.TypePair, AutoMapper.TypeMap, AutoMapper.PropertyMap);
  115. }
  116.  
  117. try
  118. {
  119. resolvedValue = (false | (item == null)) ? null : item.City;
  120. typeMapDestination.City = resolvedValue;
  121. }
  122. catch (Exception ex)
  123. {
  124. throw new AutoMapperMappingException("Error mapping types.", ex, AutoMapper.TypePair, AutoMapper.TypeMap, AutoMapper.PropertyMap);
  125. }
  126.  
  127. try
  128. {
  129. resolvedValue = (false | (item == null)) ? default(int) : item.Id;
  130. typeMapDestination.Id = resolvedValue;
  131. }
  132. catch (Exception ex)
  133. {
  134. throw new AutoMapperMappingException("Error mapping types.", ex, AutoMapper.TypePair, AutoMapper.TypeMap, AutoMapper.PropertyMap);
  135. }
  136.  
  137. return typeMapDestination;
  138. }
  139. };
  140. sourceArrayIndex++;
  141. }
  142. else
  143. {
  144. break;
  145. }
  146. }
  147.  
  148. return destinationArray;
  149. };
  150. }
  151. catch (Exception ex)
  152. {
  153. throw new AutoMapperMappingException("Error mapping types.", ex, AutoMapper.TypePair, AutoMapper.TypeMap, AutoMapper.PropertyMap);
  154. }
  155.  
  156. try
  157. {
  158. var resolvedValue = (false | (src == null)) ? null : src.HomeAddress;
  159. typeMapDestination.HomeAddress =
  160. {
  161. return (resolvedValue == null)
  162. ? null
  163. : {
  164. typeMapDestination = (dest == null) ? null : typeMapDestination.HomeAddress ?? new DeepTypeMapper.AddressDTO();
  165. try
  166. {
  167. resolvedValue = (false | (resolvedValue == null)) ? null : resolvedValue.Country;
  168. typeMapDestination.Country = resolvedValue;
  169. }
  170. catch (Exception ex)
  171. {
  172. throw new AutoMapperMappingException("Error mapping types.", ex, AutoMapper.TypePair, AutoMapper.TypeMap, AutoMapper.PropertyMap);
  173. }
  174.  
  175. try
  176. {
  177. resolvedValue = (false | (resolvedValue == null)) ? null : resolvedValue.City;
  178. typeMapDestination.City = resolvedValue;
  179. }
  180. catch (Exception ex)
  181. {
  182. throw new AutoMapperMappingException("Error mapping types.", ex, AutoMapper.TypePair, AutoMapper.TypeMap, AutoMapper.PropertyMap);
  183. }
  184.  
  185. try
  186. {
  187. resolvedValue = (false | (resolvedValue == null)) ? default(int) : resolvedValue.Id;
  188. typeMapDestination.Id = resolvedValue;
  189. }
  190. catch (Exception ex)
  191. {
  192. throw new AutoMapperMappingException("Error mapping types.", ex, AutoMapper.TypePair, AutoMapper.TypeMap, AutoMapper.PropertyMap);
  193. }
  194.  
  195. return typeMapDestination;
  196. }
  197. };
  198. }
  199. catch (Exception ex)
  200. {
  201. throw new AutoMapperMappingException("Error mapping types.", ex, AutoMapper.TypePair, AutoMapper.TypeMap, AutoMapper.PropertyMap);
  202. }
  203.  
  204. try
  205. {
  206. var resolvedValue = (false | (src == null)) ? null : src.Address;
  207. typeMapDestination.Address =
  208. {
  209. return (resolvedValue == null)
  210. ? null
  211. : {
  212. var typeMapDestination = (dest == null) ? null : typeMapDestination.Address ?? new DeepTypeMapper.Address();
  213. try
  214. {
  215. var resolvedValue = (false | (resolvedValue == null)) ? null : resolvedValue.Country;
  216. typeMapDestination.Country = resolvedValue;
  217. }
  218. catch (Exception ex)
  219. {
  220. throw new AutoMapperMappingException("Error mapping types.", ex, AutoMapper.TypePair, AutoMapper.TypeMap, AutoMapper.PropertyMap);
  221. }
  222.  
  223. try
  224. {
  225. var resolvedValue = (false | (resolvedValue == null)) ? null : resolvedValue.City;
  226. typeMapDestination.City = resolvedValue;
  227. }
  228. catch (Exception ex)
  229. {
  230. throw new AutoMapperMappingException("Error mapping types.", ex, AutoMapper.TypePair, AutoMapper.TypeMap, AutoMapper.PropertyMap);
  231. }
  232.  
  233. try
  234. {
  235. var resolvedValue = (false | (resolvedValue == null)) ? null : resolvedValue.Street;
  236. typeMapDestination.Street = resolvedValue;
  237. }
  238. catch (Exception ex)
  239. {
  240. throw new AutoMapperMappingException("Error mapping types.", ex, AutoMapper.TypePair, AutoMapper.TypeMap, AutoMapper.PropertyMap);
  241. }
  242.  
  243. try
  244. {
  245. var resolvedValue = (false | (resolvedValue == null)) ? default(int) : resolvedValue.Id;
  246. typeMapDestination.Id = resolvedValue;
  247. }
  248. catch (Exception ex)
  249. {
  250. throw new AutoMapperMappingException("Error mapping types.", ex, AutoMapper.TypePair, AutoMapper.TypeMap, AutoMapper.PropertyMap);
  251. }
  252.  
  253. return typeMapDestination;
  254. }
  255. };
  256. }
  257. catch (Exception ex)
  258. {
  259. throw new AutoMapperMappingException("Error mapping types.", ex, AutoMapper.TypePair, AutoMapper.TypeMap, AutoMapper.PropertyMap);
  260. }
  261.  
  262. try
  263. {
  264. var resolvedValue = (false | (src == null)) ? null : src.Name;
  265. typeMapDestination.Name = resolvedValue;
  266. }
  267. catch (Exception ex)
  268. {
  269. throw new AutoMapperMappingException("Error mapping types.", ex, AutoMapper.TypePair, AutoMapper.TypeMap, AutoMapper.PropertyMap);
  270. }
  271.  
  272. try
  273. {
  274. var resolvedValue = (false | (src == null)) ? default(int) : src.Id;
  275. typeMapDestination.Id = resolvedValue;
  276. }
  277. catch (Exception ex)
  278. {
  279. throw new AutoMapperMappingException("Error mapping types.", ex, AutoMapper.TypePair, AutoMapper.TypeMap, AutoMapper.PropertyMap);
  280. }
  281.  
  282. return typeMapDestination;
  283. }
  284. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement