Class StoreLoaderAttribute
Registers a static method as a store loader. The method must comply with StoreLoader delegate.
Namespace: Libplanet.Store
Assembly: Libplanet.dll
Syntax
public class StoreLoaderAttribute : Attribute
Examples
With the below code, SampleStore
and SampleStateStore
-backed
TrieStateStore can be instantiated from a URI like
sample:///home/foo/bar?cache=512
:
[StoreLoader("sample")]
private static (IStore Store, IStateStore StateStore) Loader(Uri storeUri)
{
NameValueCollection query = HttpUtility.ParseQueryString(storeUri.Query);
int cache = query.GetInt32("cache", 128);
var store = new SampleStore(storeUri.LocalPath, cache);
var stateStore = new SampleStateStore(storeUri.LocalPath, cache);
return (store, stateStore);
}
Constructors
| Improve this Doc View SourceStoreLoaderAttribute(String)
Instniates a new StoreLoaderAttribute with the specified
uriScheme
.
Declaration
public StoreLoaderAttribute(string uriScheme)
Parameters
Type | Name | Description |
---|---|---|
String | uriScheme | The URI scheme to associate with the attributed store loader method. |
Properties
| Improve this Doc View SourceUriScheme
The URI scheme to associate with the attributed store loader method.
Declaration
public string UriScheme { get; }
Property Value
Type | Description |
---|---|
String |
Methods
| Improve this Doc View SourceListStoreLoaders()
Lists all registered store loaders.
Declaration
public static IEnumerable<(string UriScheme, Type DeclaringType)> ListStoreLoaders()
Returns
Type | Description |
---|---|
IEnumerable<(, )<String, Type>> | Pairs of registered URI scheme and declaring type. |
LoadStore(Uri)
Loads a pair of IStore and IStateStore from the specified
storeUri
.
Declaration
public static (IStore Store, IStateStore StateStore)? LoadStore(Uri storeUri)
Parameters
Type | Name | Description |
---|---|---|
Uri | storeUri | A URI referring to a store. |
Returns
Type | Description |
---|---|
Nullable<(, )<IStore, IStateStore>> | A pair of loaded IStore and IStateStore. |