public void Save(string filename)
            {
                this.dictionary.Clear();
                this.dictionary.Add("SortingDirection", (int)this.SortingDirection);
                this.dictionary.Add("SortedHeaderUid", this.SortedHeaderUid ?? "");
                this.dictionary.Add("ColumnCount", this.Columns.Count);

                for (int i = 0; i < this.Columns.Count; i++)
                {
                    this.dictionary.Add("Column" + i, this.Columns[i].Uid);
                    this.dictionary.Add("ColumnWidth" + i, this.Columns[i].Width);
                }

                var data = dictionary.Serialize();

                File.WriteAllBytes(Path.Combine(ApplicationData.Current.LocalFolder.FullName, filename), data);
            }
Ejemplo n.º 2
0
        public void Serialize_Deserialize_Dictionary_Test()
        {
            var testData = new KeyRawValueDictionary();

            testData.Add("Key1", 490);
            testData.Add("Key2", 291.732874);
            testData.Add("Random Key", 3.5f);
            testData.Add("OMG", "A string is great");
            testData.Add("How it works", 88.668 / 66);
            testData.Add("Test Data", 33332);

            var data = testData.Serialize();

            var newCollection = new KeyRawValueDictionary();

            newCollection.Deserialize(data);

            Assert.AreEqual(testData["Key1"].ToInteger(), newCollection["Key1"].ToInteger());
            Assert.AreEqual(testData["Key2"].ToDouble(), newCollection["Key2"].ToDouble());
            Assert.AreEqual(testData["Random Key"].ToFloat(), newCollection["Random Key"].ToFloat());
            Assert.AreEqual(testData["OMG"].ToString(), newCollection["OMG"].ToString());
            Assert.AreEqual(testData["How it works"].ToDouble(), newCollection["How it works"].ToDouble());
            Assert.AreEqual(testData["Test Data"], newCollection["Test Data"]);
        }