[Test] public void TestSerialization()
		{
			PropertiesDictionary pd = new PropertiesDictionary();

			for(int i=0; i<10; i++)
			{
				pd[i.ToString()] = i;
			}

			Assert.AreEqual(10, pd.Count, "Dictionary should have 10 items");

			// Serialize the properties into a memory stream
			BinaryFormatter formatter = new BinaryFormatter();
			MemoryStream memory = new MemoryStream();
			formatter.Serialize(memory, pd);

			// Deserialize the stream into a new properties dictionary
			memory.Position = 0;
			PropertiesDictionary pd2 = (PropertiesDictionary)formatter.Deserialize(memory);

			Assert.AreEqual(10, pd2.Count, "Deserialized Dictionary should have 10 items");

			foreach(string key in pd.GetKeys())
			{
				Assert.AreEqual(pd[key], pd2[key], "Check Value Persisted for key [{0}]", key);
			}
		}
Пример #2
0
 /// <summary>
 /// Get the keys stored in the properties.
 /// </summary>
 /// <para>
 /// Gets the keys stored in the properties.
 /// </para>
 /// <returns>a set of the defined keys</returns>
 public string[] GetKeys()
 {
     if (_dictionary != null)
     {
         return(_dictionary.GetKeys());
     }
     return(null);
 }
        /// <summary>
        /// Get the keys stored in the properties.
        /// </summary>
        /// <para>
        /// Gets the keys stored in the properties.
        /// </para>
        /// <returns>a set of the defined keys</returns>
        public string[] GetKeys()
        {
#if NETCF
            PropertiesDictionary _dictionary = GetProperties(false);
#endif
            if (_dictionary != null)
            {
                return(_dictionary.GetKeys());
            }
            return(null);
        }
 public string[] GetKeys() =>
 _dictionary?.GetKeys();