Bjørn Larsen 3 Posted December 10, 2020 Hi, I have a MARS server with multiple resource-classes. In one of these classes I would like to insert data that is provided from a method on another resource class. Example: TResourceA = class [GET] function GetSubData: String; end; TResourceB = class [GET] function GetAllData: String; end; When ResourceB.GetAllData is invoked I would like to include data from ResourceA.GetSubData in the response. This works fine by creating an object of TResouceA and call GetSubData long as ResourceA does not use objects injected through attributes. (E.g [Context] FD: TMARSFireDAC); What is the correct way to do this when ResourceA uses attributes ([Context] FD: TMARSFireDAC)? Best regards, Bjørn Larsen Share this post Link to post
Andrea Magni 75 Posted January 18, 2021 Hi, nice question, sorry for the late of my reply. One thing you can do is to have an inheritance hierarchy. TResourceB may inherit from TResourceA. That way it should be easy to include data from GetSubData in the GetAllData result. You can still keep two distinct resources and MARS will inject everything on this or that class depending on the matching of the request path. Another way would be to pass the Context-Injected instance from one resource to the other. Through an overloaded method for example. Or through a property. I am going to make the injection mechanism more available to direct use in the future. Stay tuned. Sincerely, Andrea Share this post Link to post