Advertisement
Guest User

Untitled

a guest
Dec 17th, 2014
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.29 KB | None | 0 0
  1. [Route("/service-a/", Verbs = "POST")]
  2. public class DtoServiceA : IReturn<IList<string>>
  3. {
  4. }
  5.  
  6. public class ServiceA : ServiceBaseToSaveTyping
  7. {
  8. public ServiceA(Funq.Container container) : base(container)
  9. {
  10. }
  11.  
  12. public IList<string> Post(DtoServiceA request)
  13. {
  14. //do something that belongs to ServiceA
  15. //then resolve ServiceB and call Post() from ServiceB
  16. Container.Resolve<ServiceB>().Post(new DtoServiceB());
  17.  
  18. return new List<string>();
  19. }
  20. }
  21.  
  22. [Route("/service-b/", Verbs = "POST")]
  23. public class DtoServiceB : IReturn<IList<string>>
  24. {
  25. }
  26.  
  27. public class ServiceB : ServiceBaseToSaveTyping
  28. {
  29. public ServiceB(Funq.Container container) : base(container)
  30. {
  31. }
  32.  
  33. public IList<string> Post(DtoServiceB request)
  34. {
  35. //do something that belongs to ServiceB
  36. return new List<string>();
  37. }
  38. }
  39.  
  40. public IList<string> Post(DtoServiceA request)
  41. {
  42. //suppose if I control db connection like so
  43. using (var conn = IDbConnectionFactory.Open())
  44. {
  45. //do something that belongs to ServiceA
  46. //then resolve ServiceB and call Post() from ServiceB
  47. Container.Resolve<ServiceB>().Post(new DtoServiceB());
  48. //above line will fail because connection has already been opend by ServiecA.Post()
  49. }
  50. }
  51.  
  52. public IList<string> Post(DtoServiceB request)
  53. {
  54. //suppose if I control db connection like so
  55. using (var conn = IDbConnectionFactory.Open())
  56. {
  57.  
  58. }
  59. }
  60.  
  61. public IList<string> Post(DtoServiceA request)
  62. {
  63. //suppose if I control db connection like so
  64. using (var conn = IDbConnectionFactory.Open())
  65. {
  66. //move code to a searapte "none servicestack service", which
  67. //can be just a normal c# class
  68. Resolve<NoneServiceStackServiceA>().DoSomething();
  69. Resolve<NoneServiceStackServiceB>().DoSomething();
  70. }
  71. }
  72.  
  73. public IList<string> Post(DtoServiceB request)
  74. {
  75. //suppose if I control db connection like so
  76. using (var conn = IDbConnectionFactory.Open())
  77. {
  78. //move code to a searapte "none servicestack service", which
  79. //can be just a normal c# class
  80. Resolve<NoneServiceStackServiceB>().DoSomething();
  81. }
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement