Changeset 6737 for branches/PersistenceSpeedUp/HeuristicLab.Persistence/3.3/Default/Xml/XmlGenerator.cs
- Timestamp:
- 09/12/11 10:12:50 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PersistenceSpeedUp/HeuristicLab.Persistence/3.3/Default/Xml/XmlGenerator.cs
r6211 r6737 157 157 AddTypeInfo(beginToken.TypeId, dict); 158 158 return CreateNodeStart(XmlStringConstants.COMPOSITE, dict); 159 160 159 } 161 160 … … 164 163 if (typeId == lastTypeToken.Id) { 165 164 dict.Add("typeName", lastTypeToken.TypeName); 166 dict.Add("serializer", lastTypeToken.Serializer);167 165 lastTypeToken = null; 168 166 } else { 169 167 FlushTypeToken(); 168 } 169 } 170 if (lastSerializerToken != null) { 171 if (typeId == lastSerializerToken.Id) { 172 dict.Add("serializer", lastSerializerToken.Serializer); 173 lastSerializerToken = null; 174 } else { 175 FlushSerializerToken(); 170 176 } 171 177 } … … 238 244 239 245 protected TypeToken lastTypeToken; 246 protected SerializerToken lastSerializerToken; 240 247 /// <summary> 241 248 /// Formats the specified token. … … 245 252 protected override string Format(TypeToken token) { 246 253 lastTypeToken = token; 254 return ""; 255 } 256 257 protected override string Format(SerializerToken token) { 258 lastSerializerToken = token; 247 259 return ""; 248 260 } … … 255 267 new Dictionary<string, string> { 256 268 {"id", lastTypeToken.Id.ToString()}, 257 {"typeName", lastTypeToken.TypeName }, 258 {"serializer", lastTypeToken.Serializer }}); 269 {"typeName", lastTypeToken.TypeName }}); 259 270 } finally { 260 271 lastTypeToken = null; … … 262 273 } 263 274 275 protected string FlushSerializerToken() { 276 if (lastSerializerToken == null) 277 return ""; 278 try { 279 return CreateNode(XmlStringConstants.SERIALIZER, 280 new Dictionary<string, string> { 281 {"id", lastSerializerToken.Id.ToString()}, 282 {"serializer", lastSerializerToken.Serializer }}); 283 } finally { 284 lastTypeToken = null; 285 } 286 } 287 264 288 /// <summary> 265 289 /// Formats the specified type cache. … … 267 291 /// <param name="typeCache">The type cache.</param> 268 292 /// <returns>An enumerable of formatted type cache tags.</returns> 269 public IEnumerable<string> Format( List<TypeMapping>typeCache) {293 public IEnumerable<string> Format(TypeCache typeCache) { 270 294 yield return CreateNodeStart(XmlStringConstants.TYPECACHE); 271 foreach (var mapping in typeCache) 272 yield return CreateNode( 273 XmlStringConstants.TYPE, 274 mapping.GetDict()); 295 foreach (var type in typeCache.Types) { 296 int id = typeCache.GetOrCreateId(type); 297 var dict = new Dictionary<string, string> { 298 {"id", id.ToString()}, 299 {"typeName", type.AssemblyQualifiedName}, 300 }; 301 Type serializer = typeCache.GetSerializer(id); 302 if (serializer != null) 303 dict.Add("serializer", serializer.AssemblyQualifiedName); 304 yield return CreateNode(XmlStringConstants.TYPE, dict); 305 } 275 306 yield return CreateNodeEnd(XmlStringConstants.TYPECACHE); 276 307 } … … 342 373 writer.Flush(); 343 374 if (includeAssemblies) { 344 foreach (string name in serializer. RequiredFiles) {375 foreach (string name in serializer.GetRequiredFiles()) { 345 376 Uri uri = new Uri(name); 346 377 if (!uri.IsFile) {
Note: See TracChangeset
for help on using the changeset viewer.