Ejemplo n.º 1
0
            public static uint AddMessageCallback(bool isSingleUse, Action <string> messageCallback)
            {
                if (!_initialized)
                {
                    PInvoke.AppleAuth_SetupNativeMessageHandlerCallback(PInvoke.NativeMessageHandlerCallback);
                    _initialized = true;
                }

                if (messageCallback == null)
                {
                    throw new Exception("Can't add a null Message Callback.");
                }

                var usedCallbackId = default(uint);

                lock (SyncLock)
                {
                    usedCallbackId = _callbackId;
                    _callbackId   += 1;
                    if (_callbackId >= MaxCallbackId)
                    {
                        _callbackId = InitialCallbackId;
                    }

                    var callbackEntry = new Entry(isSingleUse, messageCallback);
                    CallbackDictionary.Add(usedCallbackId, callbackEntry);
                }
                return(usedCallbackId);
            }