public void AddCallback <T>(object obj, System.Action <T> action) { if (!_callbacks.ContainsKey(typeof(T))) { _callbacks[typeof(T)] = new Dictionary <object, iCallback>(); } if (_callbacks[typeof(T)].ContainsKey(obj)) { throw new System.Exception("Cannot register the same object multiple times for the same action"); } _callbacks[typeof(T)][obj] = new CallbackImpl <T>(action); }
public void GetCallbackPtrReturnsPointerToShadow() { using var callback = new CallbackImpl(); Assert.NotEqual(IntPtr.Zero, MarshallingHelpers.ToCallbackPtr <ICallback>(callback)); }