Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [Route("/service-a/", Verbs = "POST")]
- public class DtoServiceA : IReturn<IList<string>>
- {
- }
- public class ServiceA : ServiceBaseToSaveTyping
- {
- public ServiceA(Funq.Container container) : base(container)
- {
- }
- public IList<string> Post(DtoServiceA request)
- {
- //do something that belongs to ServiceA
- //then resolve ServiceB and call Post() from ServiceB
- Container.Resolve<ServiceB>().Post(new DtoServiceB());
- return new List<string>();
- }
- }
- [Route("/service-b/", Verbs = "POST")]
- public class DtoServiceB : IReturn<IList<string>>
- {
- }
- public class ServiceB : ServiceBaseToSaveTyping
- {
- public ServiceB(Funq.Container container) : base(container)
- {
- }
- public IList<string> Post(DtoServiceB request)
- {
- //do something that belongs to ServiceB
- return new List<string>();
- }
- }
- public IList<string> Post(DtoServiceA request)
- {
- //suppose if I control db connection like so
- using (var conn = IDbConnectionFactory.Open())
- {
- //do something that belongs to ServiceA
- //then resolve ServiceB and call Post() from ServiceB
- Container.Resolve<ServiceB>().Post(new DtoServiceB());
- //above line will fail because connection has already been opend by ServiecA.Post()
- }
- }
- public IList<string> Post(DtoServiceB request)
- {
- //suppose if I control db connection like so
- using (var conn = IDbConnectionFactory.Open())
- {
- }
- }
- public IList<string> Post(DtoServiceA request)
- {
- //suppose if I control db connection like so
- using (var conn = IDbConnectionFactory.Open())
- {
- //move code to a searapte "none servicestack service", which
- //can be just a normal c# class
- Resolve<NoneServiceStackServiceA>().DoSomething();
- Resolve<NoneServiceStackServiceB>().DoSomething();
- }
- }
- public IList<string> Post(DtoServiceB request)
- {
- //suppose if I control db connection like so
- using (var conn = IDbConnectionFactory.Open())
- {
- //move code to a searapte "none servicestack service", which
- //can be just a normal c# class
- Resolve<NoneServiceStackServiceB>().DoSomething();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement