Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Persistence/3.3/Default/Decomposers/TypeDecomposer.cs @ 1553

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

Replace final fixes for broken parent references with separation of instance creation with meta information. (#548)

File size: 1.0 KB
Line 
1using System;
2using HeuristicLab.Persistence.Core;
3using HeuristicLab.Persistence.Interfaces;
4using System.Collections.Generic;
5
6namespace HeuristicLab.Persistence.Default.Decomposers {
7 
8  public class TypeDecomposer : IDecomposer {
9
10    public int Priority {
11      get { return 100; }
12    }
13
14    public bool CanDecompose(Type type) {
15      return type == typeof (Type) ||
16             type.VersionInvariantName() == "System.RuntimeType, mscorlib";
17    }
18
19    public IEnumerable<Tag> CreateMetaInfo(object o) {
20      yield return new Tag("VersionInvariantName", ((Type)o).VersionInvariantName());
21    }
22
23    public IEnumerable<Tag> Decompose(object obj) {
24      return new Tag[] { };
25    }
26
27    public object CreateInstance(Type type, IEnumerable<Tag> metaInfo) {
28      foreach (var typeName in metaInfo) {
29        return Type.GetType((string)typeName.Value);
30      }
31      return null;     
32    }
33
34    public void Populate(object instance, IEnumerable<Tag> objects, Type type) {     
35    }
36  }
37}
Note: See TracBrowser for help on using the repository browser.