Class StoreLoaderAttribute
Registers a static method as a store loader. The method must comply with StoreLoader delegate.
Inherited Members
System.Attribute.GetCustomAttribute(System.Reflection.Assembly, System.Type)
System.Attribute.GetCustomAttribute(System.Reflection.MemberInfo, System.Type)
System.Attribute.GetCustomAttribute(System.Reflection.Module, System.Type, System.Boolean)
System.Attribute.GetCustomAttributes(System.Reflection.Assembly)
System.Attribute.GetCustomAttributes(System.Reflection.Assembly, System.Boolean)
System.Attribute.GetCustomAttributes(System.Reflection.MemberInfo)
System.Attribute.GetCustomAttributes(System.Reflection.MemberInfo, System.Boolean)
System.Attribute.GetCustomAttributes(System.Reflection.MemberInfo, System.Type)
System.Attribute.GetCustomAttributes(System.Reflection.ParameterInfo, System.Boolean)
System.Attribute.GetHashCode()
System.Attribute.IsDefined(System.Reflection.Assembly, System.Type)
System.Attribute.IsDefined(System.Reflection.Module, System.Type)
System.Attribute.IsDefined(System.Reflection.Module, System.Type, System.Boolean)
System.Object.GetType()
System.Object.ToString()
Namespace: Libplanet.Store
Assembly: Libplanet.Store.dll
Syntax
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
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<(T1 Item1, T2 Item2)<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<(T1 Item1, T2 Item2)<IStore, IStateStore>> | A pair of loaded IStore and IStateStore. |