Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/19/08 12:12:39 (16 years ago)
Author:
vdorfer
Message:

Created API documentation for HeuristicLab.Core namespace (#331)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Core/PersistenceManager.cs

    r750 r776  
    2929
    3030namespace HeuristicLab.Core {
     31  /// <summary>
     32  /// Static class for serializing and deserializing objects.
     33  /// </summary>
    3134  public static class PersistenceManager {
     35    /// <summary>
     36    /// Creates an <see cref="XmlDocument"/> to persist an object with xml declaration.
     37    /// </summary>
     38    /// <returns>The created <see cref="XmlDocument"/>.</returns>
    3239    public static XmlDocument CreateXmlDocument() {
    3340      XmlDocument document = new XmlDocument();
     
    3542      return document;
    3643    }
     44    /// <summary>
     45    /// Saves the specified <paramref name="instance"/> in the specified <paramref name="document"/>
     46    /// if it has not already been serialized.
     47    /// </summary>
     48    /// <remarks>The tag name of the saved instance is its type name.<br/>
     49    /// The guid is saved as an <see cref="XmlAttribute"/> with tag name <c>GUID</c>.</remarks>
     50    /// <param name="instance">The object that should be saved.</param>
     51    /// <param name="document">The <see cref="XmlDocument"/> where to save the data.</param>
     52    /// <param name="persistedObjects">The dictionary of all already persisted objects. (Needed to avoid cycles.)</param>
     53    /// <returns>The saved <see cref="XmlNode"/>.</returns>
    3754    public static XmlNode Persist(IStorable instance, XmlDocument document, IDictionary<Guid, IStorable> persistedObjects) {
    3855      string name = instance.GetType().Name;
     
    4057      return Persist(name, instance, document, persistedObjects);
    4158    }
     59    /// <summary>
     60    /// Saves the specified <paramref name="instance"/> in the specified <paramref name="document"/>
     61    /// if it has not already been serialized.
     62    /// </summary>
     63    /// <param name="name">The (tag)name of the <see cref="XmlNode"/>.</param>
     64    /// <param name="instance">The object that should be saved.</param>
     65    /// <param name="document">The <see cref="XmlDocument"/> where to save the data.</param>
     66    /// <param name="persistedObjects">The dictionary of all already persisted objects. (Needed to avoid cycles.)</param>
     67    /// <returns>The saved <see cref="XmlNode"/>.</returns>
    4268    public static XmlNode Persist(string name, IStorable instance, XmlDocument document, IDictionary<Guid, IStorable> persistedObjects) {
    4369      if(persistedObjects.ContainsKey(instance.Guid)) {
     
    5379      }
    5480    }
    55     public static IStorable Restore(XmlNode node, IDictionary<Guid, IStorable> restoredObjects) {
     81    /// <summary>
     82    /// Loads a persisted object from the specified <paramref name="node"/>.
     83    /// </summary>
     84    /// <remarks>The guid is saved as an attribute with tag name <c>GUID</c>. The type of the
     85    /// persisted object is saved as attribute with tag name <c>Type</c>.<br/>
     86    /// Calls <c>instance.Populate</c>.</remarks>
     87    /// <param name="node">The <see cref="XmlNode"/> where the object is saved.</param>
     88    /// <param name="restoredObjects">A dictionary of all already restored objects.
     89    /// (Needed to avoid cycles.)</param>
     90    /// <returns>The loaded object.</returns>
     91    public static IStorable Restore(XmlNode node, IDictionary<Guid,IStorable> restoredObjects) {
    5692      Guid guid = new Guid(node.Attributes["GUID"].Value);
    5793      if(restoredObjects.ContainsKey(guid)) {
     
    65101      }
    66102    }
     103    /// <summary>
     104    /// Saves the specified <paramref name="instance"/> in the specified file through creating an
     105    /// <see cref="XmlDocument"/>.
     106    /// </summary>
     107    /// <param name="instance">The object that should be saved.</param>
     108    /// <param name="filename">The name of the file where the <paramref name="object"/> should be saved.</param>
    67109    public static void Save(IStorable instance, string filename) {
    68110      using(FileStream stream = File.Create(filename)) {
     
    71113      }
    72114    }
     115    /// <summary>
     116    /// Saves the specified <paramref name="instance"/> in the specified <paramref name="stream"/>
     117    /// through creating an <see cref="XmlDocument"/>.
     118    /// </summary>
     119    /// <param name="instance">The object that should be saved.</param>
     120    /// <param name="stream">The (file) stream where the object should be saved.</param>
    73121    public static void Save(IStorable instance, Stream stream) {
    74122      XmlDocument document = PersistenceManager.CreateXmlDocument();
     
    98146      document.Save(stream);
    99147    }
     148    /// <summary>
     149    /// Loads an object from a file with the specified <paramref name="filename"/>.
     150    /// </summary>
     151    /// <remarks>The object must be saved as an <see cref="XmlDocument"/>. <br/>
     152    /// Calls <see cref="Restore"/>.</remarks>
     153    /// <param name="filename">The filename of the file where the data is saved.</param>
     154    /// <returns>The loaded object.</returns>
    100155    public static IStorable Load(string filename) {
    101156      using(FileStream stream = File.OpenRead(filename)) {
     
    105160      }
    106161    }
     162    /// <summary>
     163    /// Loads an object from the specified <paramref name="stream"/>.
     164    /// </summary>
     165    /// <remarks>The object must be saved as an <see cref="XmlDocument"/>. <br/>
     166    /// Calls <see cref="Restore"/>.</remarks>
     167    /// <param name="stream">The stream from where to load the data.</param>
     168    /// <returns>The loaded object.</returns>
    107169    public static IStorable Load(Stream stream) {
    108170      XmlDocument doc = new XmlDocument();
     
    118180    }
    119181
     182    /// <summary>
     183    /// Loads an object from a zip file.
     184    /// </summary>
     185    /// <param name="serializedStorable">The zip file from where to load as byte array.</param>
     186    /// <returns>The loaded object.</returns>
    120187    public static IStorable RestoreFromGZip(byte[] serializedStorable) {
    121188      GZipStream stream = new GZipStream(new MemoryStream(serializedStorable), CompressionMode.Decompress);
     
    123190    }
    124191
     192    /// <summary>
     193    /// Saves the specified <paramref name="storable"/> in a zip file.
     194    /// </summary>
     195    /// <remarks>Calls <see cref="Save(HeuristicLab.Core.IStorable, Stream)"/>.</remarks>
     196    /// <param name="storable">The object to save.</param>
     197    /// <returns>The zip stream as byte array.</returns>
    125198    public static byte[] SaveToGZip(IStorable storable) {
    126199      MemoryStream memStream = new MemoryStream();
     
    131204    }
    132205
     206    /// <summary>
     207    /// Builds a meaningful string for the given <paramref name="type"/> with the namespace information,
     208    /// all its arguments, the assembly name...
     209    /// </summary>
     210    /// <param name="type">The type for which a string should be created.</param>
     211    /// <returns>A string value of this type containing different additional information.</returns>
    133212    public static string BuildTypeString(Type type) {
    134213      string assembly = type.Assembly.FullName;
Note: See TracChangeset for help on using the changeset viewer.