5 using SharpYaml.Events;
6 using SharpYaml.Serialization;
7 using SiliconStudio.Core;
8 using SiliconStudio.Core.IO;
9 using SiliconStudio.Core.Serialization;
10 using SiliconStudio.Core.Yaml;
12 namespace SiliconStudio.Assets.Serializers
14 [YamlSerializerFactory]
17 public static readonly ContentReferenceSerializer
Default =
new ContentReferenceSerializer();
19 public override bool CanVisit(Type type)
24 public override object ConvertFrom(ref ObjectContext context, Scalar fromScalar)
30 if (!AssetReference.TryParse(fromScalar.Value, out guid, out location))
32 throw new YamlException(fromScalar.Start, fromScalar.End,
"Unable to decode asset reference [{0}]. Expecting format GUID:LOCATION".ToFormat(fromScalar.Value));
35 contentReference.Id = guid;
36 contentReference.Location = location;
37 return contentReference;
39 public override string ConvertTo(ref ObjectContext objectContext)
42 return string.Format(
"{0}:{1}", contentReference.Id, contentReference.Location);
Use the default mode depending on the type of the field/property.
Defines a normalized file path. See UPath for details. This class cannot be inherited.