AssetFileSerializer Class
Namespace: Stride.Core.AssetsAssembly: Stride.Core.Assets.dll
Main entry point for serializing/deserializing Asset.
public static class AssetFileSerializer
| Name | Description | |
|---|---|---|
| Fields | ||
| Default | The default serializer. |
|
| Methods | ||
| FindSerializer(String) | Finds a serializer for the specified asset file extension. |
|
| Load<T>(Stream, UFile, ILogger) | ||
| Load<T>(String, ILogger) | Deserializes an Asset from the specified stream. |
|
| Register(IAssetSerializerFactory) | Registers the specified serializer factory. |
|
| Save(Stream, Object, AttachedYamlAssetMetadata, ILogger) | Serializes an Asset to the specified stream. |
|
| Save(String, Object, AttachedYamlAssetMetadata, ILogger) | Serializes an Asset to the specified file path. |
|
Fields
Default
The default serializer.
public static readonly IAssetSerializer Default
Field Value
| Type | Description |
|---|---|
| IAssetSerializer |
Methods
FindSerializer(String)
Finds a serializer for the specified asset file extension.
public static IAssetSerializer FindSerializer(string assetFileExtension)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | assetFileExtension | The asset file extension. |
Returns
| Type | Description |
|---|---|
| IAssetSerializer | IAssetSerializerFactory. |
Load<T>(Stream, UFile, ILogger)
public static AssetLoadResult<T> Load<T>(Stream stream, UFile filePath, ILogger log = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.IO.Stream | stream | |
| Stride.Core.IO.UFile | filePath | |
| ILogger | log |
Returns
| Type | Description |
|---|---|
| AssetLoadResult<T> |
Type Parameters
| Name | Description |
|---|---|
| T |
Load<T>(String, ILogger)
Deserializes an Asset from the specified stream.
public static AssetLoadResult<T> Load<T>(string filePath, ILogger log = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | filePath | The file path. |
| ILogger | log | The logger. |
Returns
| Type | Description |
|---|---|
| AssetLoadResult<T> | An instance of Asset not a valid asset asset object file. |
Type Parameters
| Name | Description |
|---|---|
| T | Type of the asset |
Register(IAssetSerializerFactory)
Registers the specified serializer factory.
public static void Register(IAssetSerializerFactory serializerFactory)
Parameters
| Type | Name | Description |
|---|---|---|
| IAssetSerializerFactory | serializerFactory | The serializer factory. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | serializerFactory |
Save(Stream, Object, AttachedYamlAssetMetadata, ILogger)
Serializes an Asset to the specified stream.
public static void Save(Stream stream, object asset, AttachedYamlAssetMetadata yamlMetadata, ILogger log = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.IO.Stream | stream | The stream. |
| System.Object | asset | The asset object. |
| AttachedYamlAssetMetadata | yamlMetadata | |
| ILogger | log | The logger. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | stream or assetFileExtension |
Save(String, Object, AttachedYamlAssetMetadata, ILogger)
Serializes an Asset to the specified file path.
public static void Save(string filePath, object asset, AttachedYamlAssetMetadata yamlMetadata, ILogger log = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | filePath | The file path. |
| System.Object | asset | The asset object. |
| AttachedYamlAssetMetadata | yamlMetadata | |
| ILogger | log | The logger. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | filePath |