wasSharp – Diff between revs 27 and 39

Subversion Repositories:
Rev:
Show entire fileIgnore whitespace
Rev 27 Rev 39
Line 70... Line 70...
70   70  
71 writer.WriteEndElement(); 71 writer.WriteEndElement();
72 } 72 }
Line 73... Line -...
73 } -  
74   -  
75 /// <summary> -  
76 /// Deep-clones the serializable dictionary. -  
77 /// </summary> -  
78 /// <returns>a deep clone of the original dictionary</returns> -  
79 public SerializableDictionary<TKey, TValue> Clone() -  
80 { -  
81 SerializableDictionary<TKey, TValue> clone; -  
82 try -  
83 { -  
84 using (var memoryStream = new MemoryStream()) -  
85 { -  
86 new XmlSerializer( -  
87 typeof(SerializableDictionary<TKey, TValue>), new XmlRootAttribute(DictionaryNodeName)) -  
88 .Serialize(memoryStream, this); -  
89 memoryStream.Position = 0; -  
90 clone = (SerializableDictionary<TKey, TValue>) -  
91 new XmlSerializer( -  
92 typeof(SerializableDictionary<TKey, TValue>), new XmlRootAttribute(DictionaryNodeName)) -  
93 .Deserialize(memoryStream); -  
94 } -  
95 } -  
96 /* cloning failed so return an empty dictionary */ -  
97 catch (Exception) -  
98 { -  
99 clone = new SerializableDictionary<TKey, TValue>(); -  
100 } -  
101 return clone; -  
102 } 73 }
Line 103... Line 74...
103   74  
104 #region Constants 75 #region Constants
105   76  
106 public string DictionaryNodeName { get; set; } = "Dictionary"; 77 public readonly string DictionaryNodeName = @"Dictionary";
Line 107... Line 78...
107 public string ItemNodeName { get; set; } = "Item"; 78 public readonly string ItemNodeName = @"Item";
Line 108... Line 79...
108 public string KeyNodeName { get; set; } = "Key"; 79 public readonly string KeyNodeName = @"Key";