Changeset 1336
- Timestamp:
- 03/12/09 16:40:17 (16 years ago)
- Location:
- branches/New Persistence Exploration/Persistence/Persistence
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/New Persistence Exploration/Persistence/Persistence/DeSerializer.cs
r1332 r1336 44 44 public void SetValue(string name, object value) { 45 45 accessorDict[name].Set(value); 46 accessorDict.Remove(name); 46 47 } 47 48 public Setter GetSetter(string name) { 48 49 return value => accessorDict[name].Set(value); 50 } 51 public void PopulateDefaultValues() { 52 foreach (var pair in accessorDict) { 53 pair.Value.Set(pair.Value.DefaultValue); 54 } 49 55 } 50 56 } … … 106 112 instance = Activator.CreateInstance(start.Type, true); 107 113 Dictionary<string, DataMemberAccessor> accessorDict = 108 StorableAttribute.GetAutostorableAccessors(instance);114 StorableAttribute.GetAutostorableAccessors(instance); 109 115 compositeStack.Push(new CompositeObject(instance, accessorDict)); 110 116 id2obj.Add(start.Id, instance); … … 113 119 private void CompositeEndHandler(IParseToken token) { 114 120 CompositeEnd end = (CompositeEnd)token; 115 ICompoundSerializer c ustomSerializer = FindCompoundSerializer(end.Type);116 if (c ustomSerializer != null) {121 ICompoundSerializer compoundSerializer = FindCompoundSerializer(end.Type); 122 if (compoundSerializer != null) { 117 123 CustomObject customObject = (CustomObject)compositeStack.Pop(); 118 124 object deserializedObject = 119 c ustomSerializer.DeSerialize(customObject.customValues, end.Type);125 compoundSerializer.DeSerialize(customObject.customValues, end.Type); 120 126 id2obj[end.Id] = deserializedObject; 121 127 SetValue(end.Name, deserializedObject); 122 128 } else { 123 129 CompositeObject compositeObject = (CompositeObject)compositeStack.Pop(); 130 compositeObject.PopulateDefaultValues(); 124 131 SetValue(end.Name, compositeObject.Obj); 125 132 } -
branches/New Persistence Exploration/Persistence/Persistence/Test/NewSerializationTest.cs
r1331 r1336 34 34 [Storable] 35 35 public Dictionary<string, int> dict = new Dictionary<string, int>(); 36 [Storable(DefaultValue = "default")] 37 public string uninitialized; 36 38 } 37 39 … … 151 153 Serializer s = new Serializer(r); 152 154 Persistence.XmlFormatter xmlFormatter = new XmlFormatter(); 153 StreamWriter writer = new StreamWriter("test.xml");155 //StreamWriter writer = new StreamWriter("test.xml"); 154 156 foreach (ISerializationToken token in s) { 155 157 string line = xmlFormatter.Format(token); 156 writer.Write(line);158 //writer.Write(line); 157 159 Console.Out.Write(line); 158 160 } 159 writer.Close();161 //writer.Close(); 160 162 XmlParser parser = new XmlParser(new StreamReader("test.xml")); 161 163 DeSerializer deSerializer = new DeSerializer();
Note: See TracChangeset
for help on using the changeset viewer.