Free cookie consent management tool by TermsFeed Policy Generator

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

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

Namespace refactoring, visibility check (#548)

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