Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Persistence/3.3/Interfaces/ICompositeSerializer.cs @ 3494

Last change on this file since 3494 was 3036, checked in by epitzer, 15 years ago

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

File size: 3.1 KB
RevLine 
[1454]1using System;
2using System.Collections.Generic;
3using HeuristicLab.Persistence.Core;
4
5namespace HeuristicLab.Persistence.Interfaces {
6
[3016]7  /// <summary>
8  /// A composite serializer does not directly transform an object into its
9  /// serialized form. It merely decomposes into other objects, that can
10  /// later be used to recompose the same object.
11  /// </summary>
[1823]12  public interface ICompositeSerializer {
[1454]13
14    /// <summary>
[1823]15    /// Defines the Priorty of this composite serializer. Higher number means
[3016]16    /// higher prioriy. Negative numbers are fallback serializers that are
17    /// disabled by default.
18    ///
[1823]19    /// All default generic composite serializers have priority 100. Specializations
[1539]20    /// have priority 200 so they will  be tried first. Priorities are
21    /// only considered for default configurations.
22    /// </summary>
23    int Priority { get; }
24
25    /// <summary>
[1823]26    /// Determines for every type whether the composite serializer is applicable.
[3016]27    /// </summary>
28    /// <param name="type">The type.</param>
29    /// <returns>
30    /// <c>true</c> if this instance can serialize the specified type; otherwise, <c>false</c>.
31    /// </returns>
[1823]32    bool CanSerialize(Type type);
[1454]33
34    /// <summary>
[2993]35    /// Give a reason if possibly why the given type cannot be serialized by this
36    /// ICompositeSerializer.
37    /// </summary>
[3016]38    /// <param name="type">The type.</param>
39    /// <returns>A string justifying why type cannot be serialized.</returns>
[2993]40    string JustifyRejection(Type type);
41
42    /// <summary>
[3016]43    /// Generate MetaInfo necessary for instance creation. (e.g. dimensions
[3036]44    /// necessary for array creation.
[3016]45    /// </summary>
46    /// <param name="obj">An object.</param>
47    /// <returns>An enumerable of <see cref="Tag"/>s.</returns>
[1553]48    IEnumerable<Tag> CreateMetaInfo(object obj);
49
50    /// <summary>
[3016]51    /// Decompose an object into <see cref="Tag"/>s, the tag name can be null,
[1454]52    /// the order in which elements are generated is guaranteed to be
[1553]53    /// the same as they will be supplied to the Populate method.
[3016]54    /// </summary>
55    /// <param name="obj">An object.</param>
56    /// <returns>An enumerable of <see cref="Tag"/>s.</returns>
[1542]57    IEnumerable<Tag> Decompose(object obj);
[1454]58
59    /// <summary>
[1553]60    /// Create an instance of the object using the provided meta information.
[1454]61    /// </summary>
[3016]62    /// <param name="type">A type.</param>
63    /// <param name="metaInfo">The meta information.</param>
64    /// <returns>A fresh instance of the provided type.</returns>
[1553]65    object CreateInstance(Type type, IEnumerable<Tag> metaInfo);
[1454]66
67    /// <summary>
[3016]68    /// Fills an object with values from the previously generated <see cref="Tag"/>s
69    /// in Decompose. The order in which the values are supplied is
70    /// the same as they where generated. <see cref="Tag"/> names might be null.
71    /// </summary>
72    /// <param name="instance">An empty object instance.</param>
73    /// <param name="tags">The tags.</param>
74    /// <param name="type">The type.</param>
[1553]75    void Populate(object instance, IEnumerable<Tag> tags, Type type);
[1566]76  }
[1454]77
78}
Note: See TracBrowser for help on using the repository browser.