4 using System.ComponentModel;
6 using SharpYaml.Serialization;
7 using SharpYaml.Serialization.Serializers;
8 using SiliconStudio.Core;
9 using SiliconStudio.Core.IO;
10 using SiliconStudio.Core.Reflection;
11 using SiliconStudio.Core.Yaml;
14 namespace SiliconStudio.Assets.Serializers
20 [YamlSerializerFactory]
23 public override IYamlSerializable TryCreate(SerializerContext context,
ITypeDescriptor typeDescriptor)
25 return CanVisit(typeDescriptor.
Type) ?
this : null;
28 protected override void CreateOrTransformObject(ref ObjectContext objectContext)
30 objectContext.Instance = objectContext.SerializerContext.IsSerializing ?
new AssetItemMutable((AssetItem)objectContext.Instance) :
new AssetItemMutable();
33 protected override void TransformObjectAfterRead(ref ObjectContext objectContext)
35 objectContext.Instance = ((AssetItemMutable)objectContext.Instance).ToAssetItem();
38 private class AssetItemMutable
40 public AssetItemMutable()
44 public AssetItemMutable(AssetItem item)
46 Location = item.Location;
47 SourceFolder = item.SourceFolder;
52 public UFile Location;
61 public AssetItem ToAssetItem()
63 return new AssetItem(Location, Asset) { SourceFolder = SourceFolder };
67 public bool CanVisit(Type type)
69 return type == typeof(AssetItem);
74 context.Visitor.VisitObject(context.Instance, context.Descriptor,
true);
Type Type
Gets the type described by this instance.
SharpYaml.Serialization.ITypeDescriptor ITypeDescriptor
Defines a normalized directory path. See UPath for details. This class cannot be inherited.
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.