Free cookie consent management tool by TermsFeed Policy Generator

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

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

Format white space. (Ctrl-K, Ctrl-D) (#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  [EmptyStorableClass]
9  public class TypeDecomposer : IDecomposer {
10
11    public int Priority {
12      get { return 100; }
13    }
14
15    public bool CanDecompose(Type type) {
16      return type == typeof(Type) ||
17             type.VersionInvariantName() == "System.RuntimeType, mscorlib";
18    }
19
20    public IEnumerable<Tag> CreateMetaInfo(object o) {
21      yield return new Tag("VersionInvariantName", ((Type)o).VersionInvariantName());
22    }
23
24    public IEnumerable<Tag> Decompose(object obj) {
25      return new Tag[] { };
26    }
27
28    public object CreateInstance(Type type, IEnumerable<Tag> metaInfo) {
29      foreach (var typeName in metaInfo) {
30        return Type.GetType((string)typeName.Value);
31      }
32      return null;
33    }
34
35    public void Populate(object instance, IEnumerable<Tag> objects, Type type) {
36    }
37  }
38}
Note: See TracBrowser for help on using the repository browser.