Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/15/10 14:45:46 (15 years ago)
Author:
epitzer
Message:

make most serializers internal and complete API documentation (#548)

Location:
trunk/sources/HeuristicLab.Persistence/3.3/Default/CompositeSerializers
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/ArraySerializer.cs

    r3017 r3036  
    99
    1010  [StorableClass]
    11   public class ArraySerializer : ICompositeSerializer {
     11  internal sealed class ArraySerializer : ICompositeSerializer {
    1212
    1313    public int Priority {
  • trunk/sources/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/CompactNumberArray2StringSerializer.cs

    r3017 r3036  
    1111
    1212  [StorableClass]
    13   public class CompactNumberArray2StringSerializer : ICompositeSerializer {
     13  internal sealed class CompactNumberArray2StringSerializer : ICompositeSerializer {
    1414
    1515    public int Priority {
  • trunk/sources/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/DictionarySerializer.cs

    r3017 r3036  
    1010
    1111  [StorableClass]
    12   public class DictionarySerializer : ICompositeSerializer {
     12  internal sealed class DictionarySerializer : ICompositeSerializer {
    1313
    1414    public int Priority {
  • trunk/sources/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/EnumSerializer.cs

    r3017 r3036  
    88
    99  [StorableClass]
    10   public class EnumSerializer : ICompositeSerializer {
     10  internal sealed class EnumSerializer : ICompositeSerializer {
    1111
    1212    public int Priority {
  • trunk/sources/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/EnumerableSerializer.cs

    r3017 r3036  
    1111
    1212  [StorableClass]
    13   public class EnumerableSerializer : ICompositeSerializer {
     13  internal sealed class EnumerableSerializer : ICompositeSerializer {
    1414
    1515    public int Priority {
  • trunk/sources/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/KeyValuePairSerializer.cs

    r3017 r3036  
    1010
    1111  [StorableClass]
    12   public class KeyValuePairSerializer : ICompositeSerializer {
     12  internal sealed class KeyValuePairSerializer : ICompositeSerializer {
    1313
    1414    public int Priority {
  • trunk/sources/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/Number2StringSerializer.cs

    r3017 r3036  
    1212namespace HeuristicLab.Persistence.Default.CompositeSerializers {
    1313
     14  /// <summary>
     15  /// Serializes a primitive number type using the ToString() method and an
     16  /// approriate precision and parses back the generated string using
     17  /// the number type's Parse() method.
     18  ///
     19  /// This serializer has Priorty below zero and is disabled by default
     20  /// but can be useful in generating custom serializers.
     21  /// </summary>
    1422  [StorableClass]
    15   public class Number2StringSerializer : ICompositeSerializer {
     23  public sealed class Number2StringSerializer : ICompositeSerializer {
    1624
    1725    private static readonly List<Type> numberTypes =
     
    4250    }
    4351
     52    /// <summary>
     53    /// Determines for every type whether the composite serializer is applicable.
     54    /// </summary>
     55    /// <param name="type">The type.</param>
     56    /// <returns>
     57    ///   <c>true</c> if this instance can serialize the specified type; otherwise, <c>false</c>.
     58    /// </returns>
    4459    public bool CanSerialize(Type type) {
    4560      return numberParsers.ContainsKey(type);
    4661    }
    4762
     63    /// <summary>
     64    /// Give a reason if possibly why the given type cannot be serialized by this
     65    /// ICompositeSerializer.
     66    /// </summary>
     67    /// <param name="type">The type.</param>
     68    /// <returns>
     69    /// A string justifying why type cannot be serialized.
     70    /// </returns>
    4871    public string JustifyRejection(Type type) {
    4972      return string.Format("not a number type (one of {0})",
     
    5174    }
    5275
     76    /// <summary>
     77    /// Formats the specified obj.
     78    /// </summary>
     79    /// <param name="obj">The obj.</param>
     80    /// <returns></returns>
    5381    public string Format(object obj) {
    5482      if (obj.GetType() == typeof(float))
     
    6189    }
    6290
     91    /// <summary>
     92    /// Parses the specified string value.
     93    /// </summary>
     94    /// <param name="stringValue">The string value.</param>
     95    /// <param name="type">The type.</param>
     96    /// <returns></returns>
    6397    public object Parse(string stringValue, Type type) {
    6498      try {
     
    75109
    76110
     111
     112    /// <summary>
     113    /// Defines the Priorty of this composite serializer. Higher number means
     114    /// higher prioriy. Negative numbers are fallback serializers that are
     115    /// disabled by default.
     116    /// All default generic composite serializers have priority 100. Specializations
     117    /// have priority 200 so they will  be tried first. Priorities are
     118    /// only considered for default configurations.
     119    /// </summary>
     120    /// <value></value>
    77121    public int Priority {
    78122      get { return -100; }
    79123    }
    80124
     125    /// <summary>
     126    /// Generate MetaInfo necessary for instance creation. (e.g. dimensions
     127    /// necessary for array creation.
     128    /// </summary>
     129    /// <param name="obj">An object.</param>
     130    /// <returns>An enumerable of <see cref="Tag"/>s.</returns>
    81131    public IEnumerable<Tag> CreateMetaInfo(object obj) {
    82132      yield return new Tag(Format(obj));
    83133    }
    84134
     135    /// <summary>
     136    /// Decompose an object into <see cref="Tag"/>s, the tag name can be null,
     137    /// the order in which elements are generated is guaranteed to be
     138    /// the same as they will be supplied to the Populate method.
     139    /// </summary>
     140    /// <param name="obj">An object.</param>
     141    /// <returns>An enumerable of <see cref="Tag"/>s.</returns>
    85142    public IEnumerable<Tag> Decompose(object obj) {
    86143      // numbers are composed just of meta info
     
    88145    }
    89146
     147    /// <summary>
     148    /// Create an instance of the object using the provided meta information.
     149    /// </summary>
     150    /// <param name="type">A type.</param>
     151    /// <param name="metaInfo">The meta information.</param>
     152    /// <returns>A fresh instance of the provided type.</returns>
    90153    public object CreateInstance(Type type, IEnumerable<Tag> metaInfo) {
    91154      var it = metaInfo.GetEnumerator();
     
    102165    }
    103166
     167    /// <summary>
     168    /// Fills an object with values from the previously generated <see cref="Tag"/>s
     169    /// in Decompose. The order in which the values are supplied is
     170    /// the same as they where generated. <see cref="Tag"/> names might be null.
     171    /// </summary>
     172    /// <param name="instance">An empty object instance.</param>
     173    /// <param name="tags">The tags.</param>
     174    /// <param name="type">The type.</param>
    104175    public void Populate(object instance, IEnumerable<Tag> tags, Type type) {
    105176      // numbers are composed just of meta info, no need to populate
  • trunk/sources/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/NumberEnumerable2StringSerializer.cs

    r3017 r3036  
    1212
    1313  [StorableClass]
    14   public class NumberEnumerable2StringSerializer : ICompositeSerializer {
     14  internal sealed class NumberEnumerable2StringSerializer : ICompositeSerializer {
    1515
    1616    public int Priority {
  • trunk/sources/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/StackSerializer.cs

    r3017 r3036  
    1111
    1212  [StorableClass]
    13   public class StackSerializer : ICompositeSerializer {
     13  internal sealed class StackSerializer : ICompositeSerializer {
    1414
    1515    public int Priority {
  • trunk/sources/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/Storable/StorableHookAttribute.cs

    r3031 r3036  
    1111  /// Indicates the time at which the hook should be invoked.
    1212  /// </summary>
    13   public enum HookType { BeforeSerialization, AfterDeserialization };
     13  public enum HookType {
     14
     15    /// <summary>
     16    /// States that this hook should be called before the storable
     17    /// serializer starts decomposing the object.
     18    /// </summary>
     19    BeforeSerialization,
     20   
     21    /// <summary>
     22    /// States that this hook should be called after the storable
     23    /// serializer hast complete re-assembled the object.
     24    /// </summary>
     25    AfterDeserialization };
    1426
    1527
  • trunk/sources/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/Storable/StorableSerializer.cs

    r3031 r3036  
    1818  /// </summary>
    1919  [StorableClass]
    20   public class StorableSerializer : ICompositeSerializer {
     20  public sealed class StorableSerializer : ICompositeSerializer {
    2121
    2222    #region ICompositeSerializer implementation
    2323
     24    /// <summary>
     25    /// Priority 200, one of the first default composite serializers to try.
     26    /// </summary>
     27    /// <value></value>
    2428    public int Priority {
    2529      get { return 200; }
    2630    }
    2731
     32    /// <summary>
     33    /// Determines for every type whether the composite serializer is applicable.
     34    /// </summary>
     35    /// <param name="type">The type.</param>
     36    /// <returns>
     37    ///   <c>true</c> if this instance can serialize the specified type; otherwise, <c>false</c>.
     38    /// </returns>
    2839    public bool CanSerialize(Type type) {
    2940      if (!ReflectionTools.HasDefaultConstructor(type) &&
     
    3344    }
    3445
     46    /// <summary>
     47    /// Give a reason if possibly why the given type cannot be serialized by this
     48    /// ICompositeSerializer.
     49    /// </summary>
     50    /// <param name="type">The type.</param>
     51    /// <returns>
     52    /// A string justifying why type cannot be serialized.
     53    /// </returns>
    3554    public string JustifyRejection(Type type) {
    3655      if (!ReflectionTools.HasDefaultConstructor(type) &&
     
    4261    }
    4362
     63    /// <summary>
     64    /// Creates the meta info.
     65    /// </summary>
     66    /// <param name="o">The object.</param>
     67    /// <returns>A list of storable components.</returns>
    4468    public IEnumerable<Tag> CreateMetaInfo(object o) {
    4569      InvokeHook(HookType.BeforeSerialization, o);
     
    4771    }
    4872
     73    /// <summary>
     74    /// Decompose an object into <see cref="Tag"/>s, the tag name can be null,
     75    /// the order in which elements are generated is guaranteed to be
     76    /// the same as they will be supplied to the Populate method.
     77    /// </summary>
     78    /// <param name="obj">An object.</param>
     79    /// <returns>An enumerable of <see cref="Tag"/>s.</returns>
    4980    public IEnumerable<Tag> Decompose(object obj) {
    5081      foreach (var accessor in GetStorableAccessors(obj)) {
     
    5586    private static readonly object[] defaultArgs = new object[] { true };
    5687
     88    /// <summary>
     89    /// Create an instance of the object using the provided meta information.
     90    /// </summary>
     91    /// <param name="type">A type.</param>
     92    /// <param name="metaInfo">The meta information.</param>
     93    /// <returns>A fresh instance of the provided type.</returns>
    5794    public object CreateInstance(Type type, IEnumerable<Tag> metaInfo) {
    5895      try {
     
    66103    }
    67104
     105    /// <summary>
     106    /// Populates the specified instance.
     107    /// </summary>
     108    /// <param name="instance">The instance.</param>
     109    /// <param name="objects">The objects.</param>
     110    /// <param name="type">The type.</param>
    68111    public void Populate(object instance, IEnumerable<Tag> objects, Type type) {
    69112      var memberDict = new Dictionary<string, Tag>();
  • trunk/sources/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/StructSerializer.cs

    r3017 r3036  
    1111
    1212  [StorableClass]
    13   public class StructSerializer : ICompositeSerializer {   
     13  internal sealed class StructSerializer : ICompositeSerializer {   
    1414
    1515    public int Priority {
  • trunk/sources/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/TypeSerializer.cs

    r3017 r3036  
    99
    1010  [StorableClass]
    11   public class TypeSerializer : ICompositeSerializer {
     11  internal sealed class TypeSerializer : ICompositeSerializer {
    1212
    1313    public int Priority {
Note: See TracChangeset for help on using the changeset viewer.