1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using HeuristicLab.Persistence.Core;
|
---|
4 |
|
---|
5 | namespace HeuristicLab.Persistence.Interfaces {
|
---|
6 |
|
---|
7 | public interface IDecomposer {
|
---|
8 |
|
---|
9 | /// <summary>
|
---|
10 | /// Defines the Priorty of this Decomposer. Higher number means
|
---|
11 | /// higher prioriy. Negative numbers are fallback decomposers.
|
---|
12 | /// All default generic decomposers have priority 100. Specializations
|
---|
13 | /// have priority 200 so they will be tried first. Priorities are
|
---|
14 | /// only considered for default configurations.
|
---|
15 | /// </summary>
|
---|
16 | int Priority { get; }
|
---|
17 |
|
---|
18 | /// <summary>
|
---|
19 | /// Determines for every type whether the decomposer is applicable.
|
---|
20 | /// </summary>
|
---|
21 | bool CanDecompose(Type type);
|
---|
22 |
|
---|
23 | /// <summary>
|
---|
24 | /// Generate MetaInfo necessary for instance creation. (i.e.
|
---|
25 | /// array dimensions).
|
---|
26 | /// </summary>
|
---|
27 | IEnumerable<Tag> CreateMetaInfo(object obj);
|
---|
28 |
|
---|
29 | /// <summary>
|
---|
30 | /// Decompose an object into KeyValuePairs, the Key can be null,
|
---|
31 | /// the order in which elements are generated is guaranteed to be
|
---|
32 | /// the same as they will be supplied to the Populate method.
|
---|
33 | /// </summary>
|
---|
34 | IEnumerable<Tag> Decompose(object obj);
|
---|
35 |
|
---|
36 | /// <summary>
|
---|
37 | /// Create an instance of the object using the provided meta information.
|
---|
38 | /// </summary>
|
---|
39 | /// <param name="type"></param>
|
---|
40 | /// <returns></returns>
|
---|
41 | object CreateInstance(Type type, IEnumerable<Tag> metaInfo);
|
---|
42 |
|
---|
43 | /// <summary>
|
---|
44 | /// Compose an object from the KeyValuePairs previously generated
|
---|
45 | /// in DeCompose. The order in which the values are supplied is
|
---|
46 | /// the same as they where generated. Keys might be null.
|
---|
47 | /// </summary>
|
---|
48 | void Populate(object instance, IEnumerable<Tag> tags, Type type);
|
---|
49 | }
|
---|
50 |
|
---|
51 | } |
---|