Пример #1
0
                public bool RemoveDevice(Device.CharacterDevice device)
                {
                    int id = device.Id;

                    if (!DevicesById.ContainsKey(id))
                    {
                        return(false);
                    }
                    DevicesById.Remove(id);
                    string type = device.DeviceType();

                    DevicesByType[type].Remove(device);
                    if (DevicesByType[type].Count == 0)
                    {
                        DevicesByType.Remove(type);
                    }
                    return(true);
                }
Пример #2
0
                public bool AddDevice(Device.CharacterDevice device)
                {
                    if (device.Id == -1)
                    {
                        device.Id = Counter;
                    }
                    if (DevicesById.ContainsKey(device.Id))
                    {
                        return(false);
                    }
                    DevicesById[device.Id] = device;

                    string type = device.DeviceType();

                    if (!DevicesByType.ContainsKey(type))
                    {
                        DevicesByType[type] = new List <Device.CharacterDevice>();
                    }
                    DevicesByType[type].Add(device);
                    return(true);
                }