private Bulb HandleBulbPacket(IGateway gateway, AnswerPacketBase packet) { Bulb bulb; if (!_bulbs.TryGetValue(packet.TargetMacAddress, out bulb)) { lock (_bulbCollectionLock) { if (!_bulbs.TryGetValue(packet.TargetMacAddress, out bulb)) { bulb = new Bulb(packet.TargetMacAddress, gateway); _bulbs.Add(bulb.Mac, bulb); OnBulbCollectionChanged(); } } } packet.Apply(bulb); return(bulb); }
protected bool Equals(Bulb other) { return(_mac.SequenceEqual(other._mac)); }