4 using SharpYaml.Serialization;
5 using SharpYaml.Serialization.Serializers;
6 using SiliconStudio.Core;
7 using SiliconStudio.Core.IO;
8 using SiliconStudio.Core.Reflection;
9 using SiliconStudio.Core.Yaml;
12 namespace SiliconStudio.Assets.Serializers
18 [YamlSerializerFactory]
21 public override IYamlSerializable TryCreate(SerializerContext context,
ITypeDescriptor typeDescriptor)
23 return CanVisit(typeDescriptor.
Type) ?
this : null;
26 protected override void CreateOrTransformObject(ref ObjectContext objectContext)
28 objectContext.Instance = objectContext.SerializerContext.IsSerializing ?
new AssetBaseMutable((
AssetBase)objectContext.Instance) :
new AssetBaseMutable();
31 protected override void TransformObjectAfterRead(ref ObjectContext objectContext)
33 objectContext.Instance = ((AssetBaseMutable)objectContext.Instance).ToAssetBase();
36 private class AssetBaseMutable
38 public AssetBaseMutable()
44 Location = item.Location;
49 public UFile Location;
60 public bool CanVisit(Type type)
68 context.Visitor.VisitObject(context.Instance, context.Descriptor,
false);
SharpYaml.Serialization.ITypeDescriptor ITypeDescriptor
Type Type
Gets the type described by this instance.
An asset item part of a Package accessible through Package.Assets.
A custom visitor used by DataVisitorBase.
Provides access members of a type.
Defines a normalized file path. See UPath for details. This class cannot be inherited.