GetHashCode() публичный Метод

public GetHashCode ( ) : int
Результат int
Пример #1
0
        public void RoundTrip(NodeInfo ni)
        {
            NodeInfo ni_other = NodeInfo.CreateInstance(ni.Address, ni.Transports);

            Assert.AreEqual(ni, ni_other, "Hashtable roundtrip");
            Assert.AreEqual(ni.GetHashCode(), ni_other.GetHashCode(), "Hashtable GetHashCode roundtrip");
        }
Пример #2
0
        public void RoundTripHT(NodeInfo ni)
        {
            NodeInfo ni_other = NodeInfo.CreateInstance(ni.ToDictionary());

            Assert.AreEqual(ni, ni_other, "Hashtable roundtrip");
            Assert.AreEqual(ni.GetHashCode(), ni_other.GetHashCode(), "Hashtable GetHashCode roundtrip");
        }
Пример #3
0
        protected static NodeInfo CreateInstance(Address a, IList tas, TransportAddress ta)
        {
            NodeInfo result   = null;
            var      ni_cache = Interlocked.Exchange <WeakValueTable <int, NodeInfo> >(ref _cache, null);

            if (ni_cache != null)
            {
                try {
                    //Set up the key:
                    _cache_key._done_hash = false;
                    _cache_key._address   = a;
                    if (tas == null)
                    {
                        if (ta == null)
                        {
                            _cache_key._tas = EmptyTas;
                        }
                        else
                        {
                            _ta_list[0]     = ta;
                            _cache_key._tas = _ta_list;
                        }
                    }
                    else
                    {
                        _cache_key._tas = tas;
                    }

                    result = ni_cache.GetValue(_cache_key.GetHashCode());
                    if (!_cache_key.Equals(result))
                    {
                        //This may look weird, but we are using a NodeInfo as a key
                        //to lookup NodeInfos, this will allow us to only keep one
                        //identical NodeInfo in scope at a time.
                        if (ta == null)
                        {
                            //Note, if ta == null that implies tas is not null
                            result = new NodeInfo(a, tas);
                        }
                        else
                        {
                            result = new NodeInfo(a, ta);
                        }
                        ni_cache.Replace(result.GetHashCode(), result);
                    }
                } finally {
                    Interlocked.Exchange <WeakValueTable <int, NodeInfo> >(ref _cache, ni_cache);
                }
            }
            else if (ta == null)
            {
                //Note, if ta == null that implies tas is not null
                result = new NodeInfo(a, tas);
            }
            else
            {
                result = new NodeInfo(a, ta);
            }
            return(result);
        }
Пример #4
0
 public void RoundTrip(NodeInfo ni) {
   NodeInfo ni_other = NodeInfo.CreateInstance(ni.Address, ni.Transports);
   Assert.AreEqual(ni, ni_other, "Hashtable roundtrip");
   Assert.AreEqual(ni.GetHashCode(), ni_other.GetHashCode(), "Hashtable GetHashCode roundtrip");
 }
Пример #5
0
 public void RoundTripHT(NodeInfo ni) {
   NodeInfo ni_other = NodeInfo.CreateInstance( ni.ToDictionary() );
   Assert.AreEqual(ni, ni_other, "Hashtable roundtrip");
   Assert.AreEqual(ni.GetHashCode(), ni_other.GetHashCode(), "Hashtable GetHashCode roundtrip");
 }
Пример #6
0
 public override int GetHashCode()
 {
     return(Remote.GetHashCode());
 }
Пример #7
0
 public override int GetHashCode()
 {
     return(_remote_ni.GetHashCode());
 }