Last change
on this file since 1463 was
1454,
checked in by epitzer, 15 years ago
|
merge persistence exploration branch into trunk as HL plugin. (#506)
|
File size:
890 bytes
|
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 | public bool CanDecompose(Type type) {
|
---|
10 | return type == typeof (Type) ||
|
---|
11 | type.VersionInvariantName() == "System.RuntimeType, mscorlib";
|
---|
12 | }
|
---|
13 |
|
---|
14 | public IEnumerable<Tag> DeCompose(object obj) {
|
---|
15 | Type t = (Type) obj;
|
---|
16 | yield return new Tag("VersionInvariantName", t.VersionInvariantName());
|
---|
17 | }
|
---|
18 |
|
---|
19 | public object CreateInstance(Type type) {
|
---|
20 | return null;
|
---|
21 | }
|
---|
22 |
|
---|
23 | public object Populate(object instance, IEnumerable<Tag> objects, Type type) {
|
---|
24 | foreach ( var typeName in objects ) {
|
---|
25 | return Type.GetType((string)typeName.Value);
|
---|
26 | }
|
---|
27 | return null;
|
---|
28 | }
|
---|
29 | }
|
---|
30 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.