C# Class Glare.Assets.AssetFormat

This describes a resource format.
To implement creating, CanCreate and Create need to be overloaded. To implement loading, CanLoad, LoadMatch, and Load need to be overloaded; LoadTypesMutable should be filled or provided in the constructor (if CanLoad is true and no types are provided in the constructor, the PrimaryType is automatically added). To implement saving, CanSave, Save, and SaveCheck need to be overloaded; SaveTypesMutable should be filled or provided in the constructor (if CanSave is true and no types are provided in the constructor, the PrimaryType is automatically added).
Inheritance: PluginAsset
Exibir arquivo Open project: Burton-Radons/Alexandria Class Usage Examples

Public Methods

Method Description
AssetFormat ( PluginAsset pluginResource, Type primaryType, bool canLoad = false, IList loadTypes = null, bool canSave = false, IList saveTypes = null, bool canCreate = false, IList createTypes = null, string extension = null, IList extensions = null ) : System

Create ( AssetManager manager, Type resourceType ) : Asset

Create a new Asset of the PrimaryType.

Load ( AssetLoader loader ) : Asset

Load an Asset. This should have previously matched using LoadMatch.

LoadAsset ( AssetLoader loader, IEnumerable formats, ResolveLoadConflictCallback resolveConflict = null ) : Asset

Load an Asset.

LoadAssetAsync ( AssetLoader loader, IEnumerable formats, ResolveLoadConflictCallback resolveConflict = null, AssetLoaderProgressCallback progress = null, System.TimeSpan progressUpdateRate = null ) : Task

Load an Asset.

LoadMatch ( AssetLoader loader ) : LoadMatchStrength

Attempt to match this AssetFormat against the loader.

LoadMatchAsset ( LoadMatchStrength &matchStrength, AssetLoader loader, IEnumerable formats, ResolveLoadConflictCallback resolveConflict = null ) : AssetFormat

Find the best AssetFormat for loading an Asset.

MatchStrengthToString ( LoadMatchStrength value ) : string

Get a string describing a match strength, which handles values in between like "Perfect-2" or "Strong+3".

Save ( Asset asset, BinaryWriter writer, FileManager fileManager ) : void

Save the asset to the file.

SaveCheck ( Asset resource ) : SaveCheckResult

Check whether the Asset can be saved with this AssetFormat.

Protected Methods

Method Description
LoadMatchMagic ( AssetLoader loader, int magic, int minimumLength = 4 ) : LoadMatchStrength

Perform a quick match based on a magic Int32 value.

LoadMatchMagic ( AssetLoader loader, string magic, int minimumLength ) : LoadMatchStrength

Perform a quick match based on a magic string and a minimum length.

Private Methods

Method Description
CreateConflictException ( AssetLoader loader, LoadMatchStrength matchStrength, IList formats ) : InvalidDataException
MatchStrengthToString ( LoadMatchStrength reference, LoadMatchStrength value ) : string

Method Details

AssetFormat() public method

public AssetFormat ( PluginAsset pluginResource, Type primaryType, bool canLoad = false, IList loadTypes = null, bool canSave = false, IList saveTypes = null, bool canCreate = false, IList createTypes = null, string extension = null, IList extensions = null ) : System
pluginResource PluginAsset The context for the , used to find the .
primaryType System.Type The primary type that this operates with.
canLoad bool Whether this can load s; if true, then and must be implemented.
loadTypes IList Any additional types that could be loaded beyond the ; this can only be provided if is true.
canSave bool Whether this can save s; if true, then and must be implemented, and can be provided for additional types this can save beyond the .
saveTypes IList Any additional types that this can save beyond the ; this can only be provided if is true.
canCreate bool Whether this can create an . If so, must be implemented, and can be provided for additional types this can create beyond the .
createTypes IList Any additional types that this can create beyond the ; this can only be provided if is true.
extension string File extension that this format uses in the form of ".ext".
extensions IList File extensions that this format uses in the form of new string[] { ".ext", ".ext2" }
return System

Create() public method

Create a new Asset of the PrimaryType.
public Create ( AssetManager manager, Type resourceType ) : Asset
manager AssetManager
resourceType System.Type
return Asset

Load() public method

Load an Asset. This should have previously matched using LoadMatch.
public Load ( AssetLoader loader ) : Asset
loader AssetLoader
return Asset

LoadAsset() public static method

Load an Asset.
public static LoadAsset ( AssetLoader loader, IEnumerable formats, ResolveLoadConflictCallback resolveConflict = null ) : Asset
loader AssetLoader
formats IEnumerable
resolveConflict ResolveLoadConflictCallback
return Asset

LoadAssetAsync() public static method

Load an Asset.
public static LoadAssetAsync ( AssetLoader loader, IEnumerable formats, ResolveLoadConflictCallback resolveConflict = null, AssetLoaderProgressCallback progress = null, System.TimeSpan progressUpdateRate = null ) : Task
loader AssetLoader
formats IEnumerable
resolveConflict ResolveLoadConflictCallback
progress AssetLoaderProgressCallback
progressUpdateRate System.TimeSpan
return Task

LoadMatch() public method

Attempt to match this AssetFormat against the loader.
public LoadMatch ( AssetLoader loader ) : LoadMatchStrength
loader AssetLoader
return LoadMatchStrength

LoadMatchAsset() public static method

Find the best AssetFormat for loading an Asset.
public static LoadMatchAsset ( LoadMatchStrength &matchStrength, AssetLoader loader, IEnumerable formats, ResolveLoadConflictCallback resolveConflict = null ) : AssetFormat
matchStrength LoadMatchStrength
loader AssetLoader
formats IEnumerable
resolveConflict ResolveLoadConflictCallback
return AssetFormat

LoadMatchMagic() protected method

Perform a quick match based on a magic Int32 value.
protected LoadMatchMagic ( AssetLoader loader, int magic, int minimumLength = 4 ) : LoadMatchStrength
loader AssetLoader
magic int
minimumLength int
return LoadMatchStrength

LoadMatchMagic() protected method

Perform a quick match based on a magic string and a minimum length.
protected LoadMatchMagic ( AssetLoader loader, string magic, int minimumLength ) : LoadMatchStrength
loader AssetLoader
magic string
minimumLength int
return LoadMatchStrength

MatchStrengthToString() public static method

Get a string describing a match strength, which handles values in between like "Perfect-2" or "Strong+3".
public static MatchStrengthToString ( LoadMatchStrength value ) : string
value LoadMatchStrength
return string

Save() public method

Save the asset to the file.
public Save ( Asset asset, BinaryWriter writer, FileManager fileManager ) : void
asset Asset
writer System.IO.BinaryWriter
fileManager FileManager The that might be necessary to save additional files. This can be null if it can't be supported.
return void

SaveCheck() public method

Check whether the Asset can be saved with this AssetFormat.
public SaveCheck ( Asset resource ) : SaveCheckResult
resource Asset
return SaveCheckResult