1 // 2 // Copyright (c) ZeroC, Inc. All rights reserved. 3 // 4 5 namespace IceInternal 6 { 7 using System.Collections.Generic; 8 using Ice.Instrumentation; 9 10 public sealed class ObserverHelper 11 { get(Instance instance, string op)12 static public InvocationObserver get(Instance instance, string op) 13 { 14 CommunicatorObserver obsv = instance.initializationData().observer; 15 if(obsv != null) 16 { 17 InvocationObserver observer = obsv.getInvocationObserver(null, op, _emptyContext); 18 if(observer != null) 19 { 20 observer.attach(); 21 } 22 return observer; 23 } 24 return null; 25 } 26 get(Ice.ObjectPrx proxy, string op)27 static public InvocationObserver get(Ice.ObjectPrx proxy, string op) 28 { 29 return get(proxy, op, null); 30 } 31 get(Ice.ObjectPrx proxy, string op, Dictionary<string, string> context)32 static public InvocationObserver get(Ice.ObjectPrx proxy, string op, Dictionary<string, string> context) 33 { 34 CommunicatorObserver obsv = 35 ((Ice.ObjectPrxHelperBase)proxy).iceReference().getInstance().initializationData().observer; 36 if(obsv != null) 37 { 38 InvocationObserver observer; 39 if(context == null) 40 { 41 observer = obsv.getInvocationObserver(proxy, op, _emptyContext); 42 } 43 else 44 { 45 observer = obsv.getInvocationObserver(proxy, op, context); 46 } 47 if(observer != null) 48 { 49 observer.attach(); 50 } 51 return observer; 52 } 53 return null; 54 } 55 56 private static Dictionary<string, string> _emptyContext = new Dictionary<string, string>(); 57 } 58 } 59