Пример #1
0
        /// <summary>
        /// Adds a raw scanner.
        /// The AdvertisementPacket event will be raised on the scanner for each advertisement packet received.
        /// The scanner must not already be added.
        /// </summary>
        /// <param name="buttonScanner">A ButtonScanner</param>
        public void AddScanner(ButtonScanner buttonScanner)
        {
            if (buttonScanner == null)
            {
                throw new ArgumentNullException(nameof(buttonScanner));
            }
            if (!_scanners.TryAdd(buttonScanner.ScanId, buttonScanner))
            {
                throw new ArgumentException("Button scanner already added", nameof(buttonScanner));
            }

            SendPacket(new CmdCreateScanner {
                ScanId = buttonScanner.ScanId
            });
        }
Пример #2
0
        /// <summary>
        /// Removes a raw scanner.
        /// No further AdvertisementPacket events will be raised.
        /// The scanner must be currently added.
        /// </summary>
        /// <param name="buttonScanner">A ButtonScanner that was previously added</param>
        public void RemoveScanner(ButtonScanner buttonScanner)
        {
            if (buttonScanner == null)
            {
                throw new ArgumentNullException(nameof(buttonScanner));
            }
            ButtonScanner buttonScannerPrev;

            if (!_scanners.TryRemove(buttonScanner.ScanId, out buttonScannerPrev))
            {
                throw new ArgumentException("Button scanner was not added", nameof(buttonScanner));
            }

            SendPacket(new CmdRemoveScanner {
                ScanId = buttonScanner.ScanId
            });
        }