Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
DataContentSerializer.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 using System;
4 using System.Collections.Generic;
5 using System.Linq;
6 using System.Text;
7 using System.Threading.Tasks;
8 
9 using SiliconStudio.Core.Serialization;
10 using SiliconStudio.Core.Serialization.Contents;
11 using SiliconStudio.Core.Serialization.Serializers;
12 
13 namespace SiliconStudio.Core.Serialization.Contents
14 {
15  /// <summary>
16  /// ContentSerializer that simply defers serialization to low level serialization.
17  /// </summary>
18  /// <typeparam name="T">The type to serialize.</typeparam>
19  public class DataContentSerializer<T> : ContentSerializerBase<T> where T : new()
20  {
21  public override void Serialize(ContentSerializerContext context, SerializationStream stream, ref T obj)
22  {
23  // Get serializer
24  // TODO: Cache it? Need to make sure it doesn't end up being different between different serialization mode.
25  var dataSerializer = stream.Context.SerializerSelector.GetSerializer<T>();
26 
27  // Serialize object
28  stream.SerializeExtended(ref obj, context.Mode, dataSerializer);
29  }
30  }
31 }
Base class for implementation of SerializationStream.
override void Serialize(ContentSerializerContext context, SerializationStream stream, ref T obj)