| | 1 | | // Copyright (c) ZeroC, Inc. |
| | 2 | |
|
| | 3 | | using Ice.Instrumentation; |
| | 4 | |
|
| | 5 | | namespace Ice.Internal; |
| | 6 | |
|
| | 7 | | public sealed class ObserverHelper |
| | 8 | | { |
| | 9 | | public static InvocationObserver get(Instance instance, string op) |
| | 10 | | { |
| 1 | 11 | | CommunicatorObserver obsv = instance.initializationData().observer; |
| 1 | 12 | | if (obsv != null) |
| | 13 | | { |
| 1 | 14 | | InvocationObserver observer = obsv.getInvocationObserver(null, op, _emptyContext); |
| 1 | 15 | | observer?.attach(); |
| 1 | 16 | | return observer; |
| | 17 | | } |
| 1 | 18 | | return null; |
| | 19 | | } |
| | 20 | |
|
| 0 | 21 | | public static InvocationObserver get(Ice.ObjectPrx proxy, string op) => get(proxy, op, null); |
| | 22 | |
|
| | 23 | | public static InvocationObserver get(Ice.ObjectPrx proxy, string op, Dictionary<string, string> context) |
| | 24 | | { |
| 1 | 25 | | CommunicatorObserver obsv = |
| 1 | 26 | | ((Ice.ObjectPrxHelperBase)proxy).iceReference().getInstance().initializationData().observer; |
| 1 | 27 | | if (obsv != null) |
| | 28 | | { |
| | 29 | | InvocationObserver observer; |
| 1 | 30 | | if (context == null) |
| | 31 | | { |
| 1 | 32 | | observer = obsv.getInvocationObserver(proxy, op, _emptyContext); |
| | 33 | | } |
| | 34 | | else |
| | 35 | | { |
| 1 | 36 | | observer = obsv.getInvocationObserver(proxy, op, context); |
| | 37 | | } |
| 1 | 38 | | observer?.attach(); |
| 1 | 39 | | return observer; |
| | 40 | | } |
| 1 | 41 | | return null; |
| | 42 | | } |
| | 43 | |
|
| 1 | 44 | | private static readonly Dictionary<string, string> _emptyContext = new Dictionary<string, string>(); |
| | 45 | | } |