- Timestamp:
- 04/16/09 13:20:55 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Persistence/3.3/Core/DeSerializer.cs
r1566 r1567 4 4 using HeuristicLab.Persistence.Core.Tokens; 5 5 6 namespace HeuristicLab.Persistence.Core { 6 namespace HeuristicLab.Persistence.Core { 7 7 8 public class ParentReference { }8 public class Deserializer { 9 9 10 class Midwife {10 class Midwife { 11 11 12 public int? Id { get; private set; }13 public bool MetaMode { get; set; }14 public object Obj { get; private set; }12 public int? Id { get; private set; } 13 public bool MetaMode { get; set; } 14 public object Obj { get; private set; } 15 15 16 private List<Tag> metaInfo;17 private List<Tag> customValues;18 private Type type;19 private IDecomposer decomposer;16 private List<Tag> metaInfo; 17 private List<Tag> customValues; 18 private Type type; 19 private IDecomposer decomposer; 20 20 21 public Midwife(object value) {22 this.Obj = value;23 }21 public Midwife(object value) { 22 this.Obj = value; 23 } 24 24 25 public Midwife(Type type, IDecomposer decomposer, int? id) {26 this.type = type;27 this.decomposer = decomposer;28 this.Id = id;29 MetaMode = false;30 metaInfo = new List<Tag>();31 customValues = new List<Tag>();32 }25 public Midwife(Type type, IDecomposer decomposer, int? id) { 26 this.type = type; 27 this.decomposer = decomposer; 28 this.Id = id; 29 MetaMode = false; 30 metaInfo = new List<Tag>(); 31 customValues = new List<Tag>(); 32 } 33 33 34 public void CreateInstance() {35 if (Obj != null)36 throw new ApplicationException("object already instantiated");37 Obj = decomposer.CreateInstance(type, metaInfo);38 }34 public void CreateInstance() { 35 if (Obj != null) 36 throw new ApplicationException("object already instantiated"); 37 Obj = decomposer.CreateInstance(type, metaInfo); 38 } 39 39 40 public void AddValue(string name, object value) { 41 if (MetaMode) { 42 metaInfo.Add(new Tag(name, value)); 43 } else { 44 customValues.Add(new Tag(name, value)); 40 public void AddValue(string name, object value) { 41 if (MetaMode) { 42 metaInfo.Add(new Tag(name, value)); 43 } else { 44 customValues.Add(new Tag(name, value)); 45 } 46 } 47 48 public void Populate() { 49 decomposer.Populate(Obj, customValues, type); 45 50 } 46 51 } 47 48 public void Populate() {49 decomposer.Populate(Obj, customValues, type);50 }51 }52 53 public class Deserializer {54 52 55 53 private readonly Dictionary<int, object> id2obj;
Note: See TracChangeset
for help on using the changeset viewer.