Brunet.Connections.NodeInfo.ToDictionary C# (CSharp) Метод

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

public ToDictionary ( ) : IDictionary
Результат IDictionary
    public IDictionary ToDictionary()
    {
      if( _as_dict != null ) {
        return _as_dict;
      }
      ListDictionary ht = new ListDictionary();
      if( _address != null ) {
        ht["address"] = _address.ToString();
      }
      if( _tas.Count > 0 ) {
        string[] trans = new string[ _tas.Count ];
        int count = _tas.Count;
        for(int i = 0; i < count; i++) {
          trans[i] = _tas[i].ToString();
        }
        ht["transports"] = trans;
      }
      Interlocked.Exchange<IDictionary>(ref _as_dict, ht);
      return ht;
    }
  }

Usage Example

Пример #1
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");
        }
All Usage Examples Of Brunet.Connections.NodeInfo::ToDictionary