Advertisement
Guest User

Untitled

a guest
May 24th, 2015
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. public class Student {
  2. public string Name {get;set;}
  3. public string LastName {get;set;}
  4. public Address Address {get;set;}
  5. }
  6.  
  7. public class Address {
  8. public string Street {get;set;}
  9. }
  10.  
  11. public class StudentResult
  12. {
  13. public string Name { get; set; }
  14. public Address Address {get;set;}
  15. }
  16.  
  17. public class CloneHelper {
  18.  
  19. public static T Execute<T>(object input) {
  20. var t = JsonConvert.SerializeObject (input);
  21. var t2 = JsonConvert.DeserializeObject<T> (t);
  22. return (T)t2 ;
  23. }
  24.  
  25. public static void UnitTest() {
  26. var student = new Student () {
  27. Name = "first",
  28. LastName = "last",
  29. Address = new Address () {
  30. Street = "street"
  31. }
  32. };
  33.  
  34. var studentResult = CloneHelper.Execute<StudentResult> (student);
  35. throw new ArgumentException ("insert breakpoint debug here");
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement