Ejemplo n.º 1
0
        /// <inheritdoc />
        public bool Remove(ILifxDevice device)
        {
            EquatableWeakReference <ILifxDevice> deviceRef = this.members.FirstOrDefault(x => x.Target == device);

            if (deviceRef != null)
            {
                if (this.members.Remove(deviceRef))
                {
                    this.DeviceRemoved?.Invoke(device, new LifxDeviceRemovedEventArgs(device));

                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Removes a <see cref="ILifxDevice"/> from a former grouping and adds it to the grouping specified by <paramref name="newCollection"/>.
        /// </summary>
        /// <param name="device">The <see cref="ILifxDevice"/> to updated the membership information for.</param>
        /// <param name="newCollection">The <typeparamref name="TCollection"/> to add the <see cref="ILifxDevice"/> to.</param>
        internal void UpdateMembershipInformation(ILifxDevice device, TTag newCollection)
        {
            lock (this.deviceMap) {
                if (this.deviceMap.TryGetValue(device, out TCollection previousCollection))
                {
                    previousCollection.Remove(device);
                }

                // Add to new collection
                TCollection newCollectionStore = this.GetOrCreateCollectionInternal(newCollection);

                newCollectionStore.Add(device);

                this.deviceMap.AddOrUpdate(device, newCollectionStore);
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="LifxDeviceRemovedEventArgs"/> class.
 /// </summary>
 /// <param name="device">The removed <see cref="ILifxDevice"/>.</param>
 internal LifxDeviceRemovedEventArgs(ILifxDevice device)
 {
     this.Device = device;
 }
Ejemplo n.º 4
0
        /// <inheritdoc />
        public void Add(ILifxDevice device)
        {
            this.members.Add(new EquatableWeakReference <ILifxDevice>(device));

            this.DeviceAdded?.Invoke(this, new LifxDeviceAddedEventArgs(device));
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Called for each device that.
 /// </summary>
 /// <param name="device">The device that the membership rename operation is called on.</param>
 /// <param name="timeoutMs">How long to wait for a response before the call times out.</param>
 /// <param name="cancellationToken">Cancellation token to force the function to return its immediate result.</param>
 /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
 protected abstract Task RenameDeviceMembership(ILifxDevice device, int?timeoutMs = null, CancellationToken cancellationToken = default);
Ejemplo n.º 6
0
 /// <inheritdoc />
 public bool Contains(ILifxDevice device)
 {
     return(this.members.Any(members => members.Target == device));
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="LifxDeviceDiscoveredEventArgs"/> class.
 /// </summary>
 /// <param name="device">The discovered <see cref="ILifxDevice"/>.</param>
 internal LifxDeviceDiscoveredEventArgs(ILifxDevice device)
 {
     this.Device = device;
 }