Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
UFileSerializer.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 SharpYaml.Events;
5 using SharpYaml.Serialization;
6 using SiliconStudio.Core.IO;
7 
8 namespace SiliconStudio.Core.Yaml
9 {
10  /// <summary>
11  /// A Yaml serializer for <see cref="UFile"/>.
12  /// </summary>
13  [YamlSerializerFactory]
14  internal class UFileSerializer : AssetScalarSerializerBase
15  {
16  public override bool CanVisit(Type type)
17  {
18  return typeof(UFile) == type;
19  }
20 
21  public override object ConvertFrom(ref ObjectContext context, Scalar fromScalar)
22  {
23  return new UFile(fromScalar.Value);
24  }
25 
26  public override string ConvertTo(ref ObjectContext objectContext)
27  {
28  var path = ((UFile)objectContext.Instance);
29  return path.FullPath;
30  }
31  }
32 }
Defines a normalized file path. See UPath for details. This class cannot be inherited.
Definition: UFile.cs:13