Show / Hide Table of Contents

Class TypedActionLoader

An IActionLoader implementation for multiple IAction types.

Inheritance
Object
TypedActionLoader
Implements
IActionLoader
Inherited Members
Object.Equals(Object)
Object.Equals(Object, Object)
Object.GetHashCode()
System.Object.GetType()
Object.MemberwiseClone()
Object.ReferenceEquals(Object, Object)
System.Object.ToString()
Namespace: Libplanet.Action.Loader
Assembly: Libplanet.Action.dll
Syntax
public class TypedActionLoader : IActionLoader

Constructors

| Improve this Doc View Source

TypedActionLoader(IDictionary<IValue, Type>)

Creates a new TypedActionLoader instance with an explicit Bencodex.Types.IValues to Types mapping.

The mapping can be generated semi-automatically using Create(Assembly, Type).

Declaration
public TypedActionLoader(IDictionary<IValue, Type> types)
Parameters
Type Name Description
System.Collections.Generic.IDictionary<Bencodex.Types.IValue, Type> types

The Bencodex.Types.IValues to Types mapping to use.

See Also
Create(Assembly, Type)

Properties

| Improve this Doc View Source

Types

An IActionLoader implementation for multiple IAction types.

Declaration
public IDictionary<IValue, Type> Types { get; }
Property Value
Type Description
System.Collections.Generic.IDictionary<Bencodex.Types.IValue, Type>

Methods

| Improve this Doc View Source

Create(Assembly, Type)

Creates a new TypedActionLoader instance.

The IAction type to load is restricted to given assembly and baseType, except for those handled by Registry for system IActions.

This automatically searches an Assembly with all IActions according to the following rule:

  • The Assembly to search is assembly if given, or the Assembly of baseType if not.
  • From the Assembly determined above, all IActions with ActionTypeAttribute attached are collected.
  • If baseType is provided, only those IAction types that are assignable to baseType are selected.

Then a dictionary mapping from Bencodex.Types.IValues to Types created from searched IActions and the explicit loader is created by passing the map to TypedActionLoader(IDictionary<IValue, Type>).

Declaration
public static TypedActionLoader Create(Assembly assembly = null, Type baseType = null)
Parameters
Type Name Description
Assembly assembly

The Assembly to search IAction types.

Type baseType

The type of IAction to filter.

Returns
Type Description
TypedActionLoader

A TypedActionLoader created from provided assembly and baseType.

Exceptions
Type Condition
ArgumentException

Thrown when both assembly and baseType are null.

See Also
TypedActionLoader(IDictionary<IValue, Type>)
| Improve this Doc View Source

LoadAction(Int64, IValue)

An IActionLoader implementation for multiple IAction types.

Declaration
public IAction LoadAction(long index, IValue value)
Parameters
Type Name Description
System.Int64 index
Bencodex.Types.IValue value
Returns
Type Description
IAction

Implements

IActionLoader
  • Improve this Doc
  • View Source
In This Article
Back to top Copyright © 2018–2023 Planetarium