Пример #1
0
        public int GetHashCode(object obj)
        {
            if (!(obj is FamilyActionPair))
            {
                return(0);
            }

            FamilyActionPair fap /*lol*/ = (FamilyActionPair)obj;

            return((int)fap.fam << 8 & (byte)fap.act);
        }
Пример #2
0
        bool IEqualityComparer.Equals(object obj1, object obj2)
        {
            if (!(obj1 is FamilyActionPair) || !(obj2 is FamilyActionPair))
            {
                return(false);
            }

            FamilyActionPair fap1 = (FamilyActionPair)obj1, fap2 = (FamilyActionPair)obj2;

            return(fap1.fam == fap2.fam && fap1.act == fap2.act);
        }
Пример #3
0
        private void _handlePacket(object state)
        {
            Packet           pkt     = (Packet)state;
            FamilyActionPair pair    = new FamilyActionPair(pkt.Family, pkt.Action);
            bool             handled = false;

            if (m_handlers.ContainsKey(pair))
            {
                handled = true;
                m_handlers[pair].InvokeHandler(pkt);
            }

            if (EventReceiveData != null)
            {
                DataTransferEventArgs dte = new DataTransferEventArgs(DataTransferEventArgs.TransferType.Recv, pkt.Family, pkt.Action, pkt.Data)
                {
                    PacketHandled = handled
                };
                EventReceiveData(dte);
            }
        }