Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 3554 was 3036, checked in by epitzer, 14 years ago

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

File size: 3.1 KB
Line 
1using System;
2using System.Collections.Generic;
3using HeuristicLab.Persistence.Core;
4
5namespace HeuristicLab.Persistence.Interfaces {
6
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>
12  public interface ICompositeSerializer {
13
14    /// <summary>
15    /// Defines the Priorty of this composite serializer. Higher number means
16    /// higher prioriy. Negative numbers are fallback serializers that are
17    /// disabled by default.
18    ///
19    /// All default generic composite serializers have priority 100. Specializations
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>
26    /// Determines for every type whether the composite serializer is applicable.
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>
32    bool CanSerialize(Type type);
33
34    /// <summary>
35    /// Give a reason if possibly why the given type cannot be serialized by this
36    /// ICompositeSerializer.
37    /// </summary>
38    /// <param name="type">The type.</param>
39    /// <returns>A string justifying why type cannot be serialized.</returns>
40    string JustifyRejection(Type type);
41
42    /// <summary>
43    /// Generate MetaInfo necessary for instance creation. (e.g. dimensions
44    /// necessary for array creation.
45    /// </summary>
46    /// <param name="obj">An object.</param>
47    /// <returns>An enumerable of <see cref="Tag"/>s.</returns>
48    IEnumerable<Tag> CreateMetaInfo(object obj);
49
50    /// <summary>
51    /// Decompose an object into <see cref="Tag"/>s, the tag name can be null,
52    /// the order in which elements are generated is guaranteed to be
53    /// the same as they will be supplied to the Populate method.
54    /// </summary>
55    /// <param name="obj">An object.</param>
56    /// <returns>An enumerable of <see cref="Tag"/>s.</returns>
57    IEnumerable<Tag> Decompose(object obj);
58
59    /// <summary>
60    /// Create an instance of the object using the provided meta information.
61    /// </summary>
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>
65    object CreateInstance(Type type, IEnumerable<Tag> metaInfo);
66
67    /// <summary>
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>
75    void Populate(object instance, IEnumerable<Tag> tags, Type type);
76  }
77
78}
Note: See TracBrowser for help on using the repository browser.