Csla client-side customs agent service? #2856
-
Wondering if there is a way to accomplish what I'm calling a "customs agent". It would be a service that sits at the entry point where objects go into and out of the DataPortal. This service would have access to the ApplicationContext of objects on the client side (going into the DP) and the ApplicationContext of objects on the server side (right before coming back from the DP). What I'd like is for this service to be able raise an event if the ApplicationContext (of an object coming back to the client across the DP border) meets some criteria (some bool flag). This would empower my client side to know that certain events happened on the server side of the data portal and do a subsequent response or refresh or whatever is appropriate. Since no information flows back from the server to the client in ApplicationContext, I'm having trouble thinking of a way to accomplish this. Obviously scheduled polling could accomplish this where the client pulls information every so often...but that is expensive and 99% of the time useless. Any ideas? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 12 replies
-
Self-reporting? An alternate theoretical idea is to bake this feature into my base classes so that when they cross the border back onto the client-side, they can check the flag/condition and if it is true then the object could get the notification service via DI and then do the notification. @rockfordlhotka can you tell me is the So using LocalProxy |
Beta Was this translation helpful? Give feedback.
-
@swegele Yeah, I think your questions are key. When I first read your thread I wondered about interceptors as helpful. However, I then thought they are not the right solution, because they are on the server, not the client. However, @rockfordlhotka 's answer makes me question myself. We had to add guard clauses to our interceptor to ensure that it was only executed on remote data portals - but I think that was the point: we were discriminating between LocalProxy and everything else. I think OnDataPortalInvokeComplete might be a better solution, if it works, as you want your behaviour on the client, not the server. I think interceptors are about logical server-side behaviour. I can't think of any other client-side interception of this type. That's not to say there isn't any, but that I don't know of it. The only other thing that springs to mind is deserialization events, but they happen for reasons other than data portal events, and happen on each object in a graph, rather than just the root. I think the answer to your question is to try it. I think a bit of code will answer the majority of your questions, so that's what I would do next. |
Beta Was this translation helpful? Give feedback.
-
@swegele It might be interesting to try to create a wrapper for another proxy - any other proxy - rather than a copy of any single one. |
Beta Was this translation helpful? Give feedback.
@swegele Yeah, I think your questions are key. When I first read your thread I wondered about interceptors as helpful. However, I then thought they are not the right solution, because they are on the server, not the client. However, @rockfordlhotka 's answer makes me question myself. We had to add guard clauses to our interceptor to ensure that it was only executed on remote data portals - but I think that was the point: we were discriminating between LocalProxy and everything else.
I think OnDataPortalInvokeComplete might be a better solution, if it works, as you want your behaviour on the client, not the server. I think interceptors are about logical server-side behaviour.
I can't think…