Table of Contents

Class TypedAssetDelivery

Namespace
Shard.Assets.Delivery
Assembly
Shard.Assets.dll

Builds deterministic packet bodies from typed asset collections.

public static class TypedAssetDelivery
Inheritance
TypedAssetDelivery
Inherited Members

Methods

Array<TAsset, TWire>(AssetMap<TAsset>, Func<TAsset, string, TWire>)

Builds an array packet body from typed assets in deterministic key order.

[SuppressMessage("ReSharper", "ForeachCanBeConvertedToQueryUsingAnotherGetEnumerator")]
public static TWire[] Array<TAsset, TWire>(AssetMap<TAsset> assets, Func<TAsset, string, TWire> convert) where TAsset : notnull

Parameters

assets AssetMap<TAsset>
convert Func<TAsset, string, TWire>

Returns

TWire[]

Type Parameters

TAsset
TWire

Indexed<TAsset, TWire>(AssetMap<TAsset>, Func<TAsset, string, TWire>, Func<string, TWire>)

Builds the Dictionary<int, TWire> body of an indexed store's update packet. Every assigned index is emitted, ensuring that the resulting index space is dense. Loaded assets are converted with convert, while reserved keys without a loaded asset are created with reservedDefault.

public static Dictionary<int, TWire> Indexed<TAsset, TWire>(AssetMap<TAsset> assets, Func<TAsset, string, TWire> convert, Func<string, TWire> reservedDefault) where TAsset : notnull where TWire : class

Parameters

assets AssetMap<TAsset>
convert Func<TAsset, string, TWire>
reservedDefault Func<string, TWire>

Returns

Dictionary<int, TWire>

Type Parameters

TAsset
TWire

Remarks

Reserved entries must always produce a valid wire value because the client indexes the resulting collection as a dense array and may fail if an assigned index is missing.

Stringed<TAsset, TWire>(AssetMap<TAsset>, Func<TAsset, string, TWire>)

Builds a packet body keyed by strings from typed assets in deterministic key order.

public static Dictionary<string, TWire> Stringed<TAsset, TWire>(AssetMap<TAsset> assets, Func<TAsset, string, TWire> convert) where TAsset : notnull

Parameters

assets AssetMap<TAsset>
convert Func<TAsset, string, TWire>

Returns

Dictionary<string, TWire>

Type Parameters

TAsset
TWire