Changeset 3028 for trunk/sources/HeuristicLab.Persistence
- Timestamp:
- 03/15/10 12:01:10 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/XmlGenerator.cs ¶
r3016 r3028 189 189 } 190 190 191 /// <summary> 192 /// Formats the specified type cache. 193 /// </summary> 194 /// <param name="typeCache">The type cache.</param> 195 /// <returns>An enumerable of formatted type cache tags.</returns> 191 196 public IEnumerable<string> Format(List<TypeMapping> typeCache) { 192 197 yield return CreateNodeStart(XmlStringConstants.TYPECACHE); … … 211 216 /// <summary> 212 217 /// Serialize an object into a file. 213 ///214 218 /// The XML configuration is obtained from the <c>ConfigurationService</c>. 215 219 /// Needed assemblies are not included. 216 220 /// </summary> 221 /// <param name="o">The object.</param> 222 /// <param name="filename">The filename.</param> 217 223 /// <param name="compression">ZIP file compression level</param> 218 224 public static void Serialize(object o, string filename, int compression) { … … 220 226 } 221 227 228 /// <summary> 229 /// Serializes the specified object into a file. 230 /// Needed assemblies are not included, ZIP compression level is set to 5. 231 /// </summary> 232 /// <param name="obj">The object.</param> 233 /// <param name="filename">The filename.</param> 234 /// <param name="config">The configuration.</param> 222 235 public static void Serialize(object obj, string filename, Configuration config) { 223 236 Serialize(obj, filename, config, false, 5); 224 237 } 225 238 239 /// <summary> 240 /// Serializes the specified object into a file. 241 /// </summary> 242 /// <param name="obj">The object.</param> 243 /// <param name="filename">The filename.</param> 244 /// <param name="config">The configuration.</param> 245 /// <param name="includeAssemblies">if set to <c>true</c> include needed assemblies.</param> 246 /// <param name="compression">The ZIP compression level.</param> 226 247 public static void Serialize(object obj, string filename, Configuration config, bool includeAssemblies, int compression) { 227 248 try { … … 278 299 } 279 300 301 /// <summary> 302 /// Serializes the specified object into a stream using the <see cref="XmlFormat"/> 303 /// obtained from the <see cref="ConfigurationService"/>. 304 /// </summary> 305 /// <param name="obj">The object.</param> 306 /// <param name="stream">The stream.</param> 280 307 public static void Serialize(object obj, Stream stream) { 281 308 Serialize(obj, stream, ConfigurationService.Instance.GetConfiguration(new XmlFormat())); … … 283 310 284 311 312 /// <summary> 313 /// Serializes the specified object into a stream. 314 /// </summary> 315 /// <param name="obj">The object.</param> 316 /// <param name="stream">The stream.</param> 317 /// <param name="config">The configuration.</param> 285 318 public static void Serialize(object obj, Stream stream, Configuration config) { 286 319 Serialize(obj, stream, config, false); 287 320 } 288 321 289 public static void Serialize(object obj, Stream stream, Configuration config, bool includeAssemblies) { 290 Serialize(obj, stream, config, includeAssemblies, true); 291 } 292 293 public static void Serialize(object obj, Stream stream, Configuration config, bool includeAssemblies, bool interleaveTypeInfo) { 322 /// <summary> 323 /// Serializes the specified object into a stream. 324 /// </summary> 325 /// <param name="obj">The object.</param> 326 /// <param name="stream">The stream.</param> 327 /// <param name="config">The configuration.</param> 328 /// <param name="includeAssemblies">if set to <c>true</c> include need assemblies.</param> 329 public static void Serialize(object obj, Stream stream, Configuration config, bool includeAssemblies) { 294 330 try { 295 331 using (StreamWriter writer = new StreamWriter(new GZipStream(stream, CompressionMode.Compress))) { -
TabularUnified trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/XmlParser.cs ¶
r3005 r3028 12 12 namespace HeuristicLab.Persistence.Default.Xml { 13 13 14 /// <summary> 15 /// Main entry point of persistence loading from XML. Use the static 16 /// methods to load from a file or stream. 17 /// </summary> 14 18 public class XmlParser : IEnumerable<ISerializationToken> { 15 19 … … 18 22 private readonly Dictionary<string, Handler> handlers; 19 23 24 /// <summary> 25 /// Initializes a new instance of the <see cref="XmlParser"/> class. 26 /// </summary> 27 /// <param name="input">The input.</param> 20 28 public XmlParser(TextReader input) { 21 29 XmlReaderSettings settings = new XmlReaderSettings { … … 35 43 } 36 44 45 /// <summary> 46 /// Returns an enumerator that iterates through the serialization tokens. 47 /// </summary> 48 /// <returns> 49 /// An that can be used to iterate through the collection of serialization tokens. 50 /// </returns> 37 51 public IEnumerator<ISerializationToken> GetEnumerator() { 38 52 while (reader.Read()) { … … 52 66 } 53 67 } 68 } 69 70 /// <summary> 71 /// Returns an enumerator that iterates through the serialization tokens. 72 /// </summary> 73 /// <returns> 74 /// An that can be used to iterate through the collection of serialization tokens. 75 /// </returns> 76 IEnumerator IEnumerable.GetEnumerator() { 77 return GetEnumerator(); 54 78 } 55 79 … … 115 139 } 116 140 117 IEnumerator IEnumerable.GetEnumerator() { 118 return GetEnumerator(); 119 } 120 141 /// <summary> 142 /// Parses the type cache. 143 /// </summary> 144 /// <param name="reader">The reader.</param> 145 /// <returns>A list of type mapping entries.</returns> 121 146 public static List<TypeMapping> ParseTypeCache(TextReader reader) { 122 147 try { … … 139 164 } 140 165 166 /// <summary> 167 /// Deserializes an object from the specified filename. 168 /// </summary> 169 /// <param name="filename">The filename.</param> 170 /// <returns>A fresh object instance</returns> 141 171 public static object Deserialize(string filename) { 142 172 using (ZipFile file = new ZipFile(filename)) { … … 145 175 } 146 176 177 /// <summary> 178 /// Deserializes the specified filename. 179 /// </summary> 180 /// <typeparam name="T">object type expected from the serialized file</typeparam> 181 /// <param name="filename">The filename.</param> 182 /// <returns>A fresh object of type T</returns> 183 public static T Deserialize<T>(string filename) { 184 return (T)Deserialize(filename); 185 } 186 187 188 /// <summary> 189 /// Deserializes an object from the specified stream. 190 /// </summary> 191 /// <param name="stream">The stream.</param> 192 /// <returns>A fresh object instance.</returns> 147 193 public static object Deserialize(Stream stream) { 148 194 try { … … 157 203 throw new PersistenceException("Unexpected exception during deserialization", x); 158 204 } 205 } 206 207 /// <summary> 208 /// Deserializes an object from the specified stream. 209 /// </summary> 210 /// <typeparam name="T">object type expected from the serialized stream</typeparam> 211 /// <param name="stream">The stream.</param> 212 /// <returns>A fresh object instance.</returns> 213 public static T Deserialize<T>(Stream stream) { 214 return (T)Deserialize(stream); 159 215 } 160 216
Note: See TracChangeset
for help on using the changeset viewer.