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 | |
---|
1 | using System;
|
---|
2 | using HeuristicLab.Persistence.Core;
|
---|
3 | using HeuristicLab.Persistence.Interfaces;
|
---|
4 | using System.Collections.Generic;
|
---|
5 |
|
---|
6 | namespace 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.