Esempio n. 1
0
        public IData GetDataForDevice(IOwnedDevice device)
        {
            IControlToken token;

            if (MemberTokens.TryGetValue(device, out token))
            {
                return(token.GetDataForDevice(device));
            }

            if (AutoAddDevices)
            {
                token = device.TakeControl(priority: Priority, name: Name);
                Add(device, token);

                return(token.GetDataForDevice(device));
            }

            var sod = device as SingleOwnerDevice;

            if (sod != null)
            {
                return(sod.GetOwnerlessData());
            }

            throw new ArgumentException("Unhandled device");
        }
Esempio n. 2
0
        /// <summary>
        /// Lock if group token is configured for auto add
        /// </summary>
        /// <param name="device"></param>
        /// <returns>True if device is controlled by this group token</returns>
        public bool LockAndGetDataFromDevice(IOwnedDevice device)
        {
            if (MemberTokens.ContainsKey(device))
            {
                return(true);
            }

            if (!AutoAddDevices)
            {
                return(false);
            }

            // Add
            MemberTokens.Add(device, device.TakeControl(Priority, Name));

            return(true);
        }
Esempio n. 3
0
        public IData GetDataForDevice(IOwnedDevice device)
        {
            IControlToken token;

            if (MemberTokens.TryGetValue(device, out token))
            {
                return token.GetDataForDevice(device);
            }

            if (AutoAddDevices)
            {
                token = device.TakeControl(priority: Priority, name: Name);
                Add(device, token);

                return token.GetDataForDevice(device);
            }

            var sod = device as SingleOwnerDevice;
            if (sod != null)
                return sod.GetOwnerlessData();

            throw new ArgumentException("Unhandled device");
        }
Esempio n. 4
0
 public void Add(IOwnedDevice device, IControlToken token)
 {
     MemberTokens.Add(device, token);
 }
Esempio n. 5
0
        /// <summary>
        /// Lock if group token is configured for auto add
        /// </summary>
        /// <param name="device"></param>
        /// <returns>True if device is controlled by this group token</returns>
        public bool LockAndGetDataFromDevice(IOwnedDevice device)
        {
            if (MemberTokens.ContainsKey(device))
                return true;

            if (!AutoAddDevices)
                return false;

            // Add
            MemberTokens.Add(device, device.TakeControl(Priority, Name));

            return true;
        }
Esempio n. 6
0
 public IData GetDataForDevice(IOwnedDevice device)
 {
     return(this.data);
 }
Esempio n. 7
0
 public void Add(IOwnedDevice device, IControlToken token)
 {
     MemberTokens.Add(device, token);
 }
Esempio n. 8
0
 public IData GetDataForDevice(IOwnedDevice device)
 {
     return this.data;
 }