Table of Contents

Class AnyMap

Namespace
MonkeyLoader
Assembly
MonkeyLoader.dll

Represents a type safe dictionary mapping Types to objects of the type.

public sealed class AnyMap
Inheritance
AnyMap
Inherited Members

Properties

Keys

Gets all Types that have a set value in this AnyMap.

public IEnumerable<Type> Keys { get; }

Property Value

IEnumerable<Type>

Methods

Add<T>(T)

Adds the given value for type T to this AnyMap.

public void Add<T>(T value)

Parameters

value T

The value to associate with the type.

Type Parameters

T

The type of the value.

Clear()

Removes all keys and values of this AnyMap.

public void Clear()

ContainsKey<T>()

Determines whether this AnyMap contains a value for type T.

public bool ContainsKey<T>()

Returns

bool

true if there is a value for the type; otherwise, false.

Type Parameters

T

The type of the value.

GetCastableValues<T>()

Gets all non-null values that are castable to T in this AnyMap.

public IEnumerable<T> GetCastableValues<T>()

Returns

IEnumerable<T>

All non-null values that are castable to T.

Type Parameters

T

The common type of the values.

GetOrCreateValue<T>()

Gets the value associated with the type T in this AnyMap, or creates and associates a new instance of T using its parameterless constructor.

public T GetOrCreateValue<T>() where T : new()

Returns

T

The value associated with the type or the newly created instance.

Type Parameters

T

The type of the value.

GetOrCreateValue<T>(Func<T>)

Gets the value associated with the type T in this AnyMap, or creates and associates the value returned by the given valueFactory.

public T GetOrCreateValue<T>(Func<T> valueFactory)

Parameters

valueFactory Func<T>

A factory method that creates a value when there is none yet.

Returns

T

The value associated with the type or the newly created instance.

Type Parameters

T

The type of the value.

GetValue(Type)

Gets the value associated with the given type in this AnyMap.

public object GetValue(Type type)

Parameters

type Type

Returns

object

The value associated with the given type.

Exceptions

KeyNotFoundException

When there is no value for the type.

GetValue<T>()

Gets the value associated with the type T in this AnyMap.

public T GetValue<T>()

Returns

T

The value associated with the type.

Type Parameters

T

The type of the value.

Exceptions

KeyNotFoundException

When there is no value for T.

GetValue<T>(Type)

Gets the value associated with the given type in this AnyMap.

public T GetValue<T>(Type type)

Parameters

type Type

Returns

T

The value associated with the given type.

Type Parameters

T

The type of the value. Only used for casting, not access.

Exceptions

KeyNotFoundException

When there is no value for the type.

Remove(Type)

Removes the value associated with the given type in this AnyMap.

public void Remove(Type type)

Parameters

type Type

The type of the value.

Remove<T>()

Removes the value associated with the type T in this AnyMap.

public void Remove<T>()

Type Parameters

T

The type of the value.

SetValue(Type, object?)

Sets the given value for the given type in this AnyMap.

public void SetValue(Type type, object? value)

Parameters

type Type

The type of the value.

value object

The new value to associate with the type.

Exceptions

InvalidCastException

When the given value is not assignable to the given type.

SetValue<T>(T)

Sets the given value for type T in this AnyMap.

public void SetValue<T>(T value)

Parameters

value T

The new value to associate with the type.

Type Parameters

T

The type of the value.

TryGetValue(Type, out object?)

Tries to get the value associated with the given type in this AnyMap.

public bool TryGetValue(Type type, out object? value)

Parameters

type Type

The type of the value.

value object

The value if it was found; otherwise, null.

Returns

bool

true if the value was found; otherwise, false.

TryGetValue<T>(Type, out T?)

Tries to get the value associated with the given type in this AnyMap.

public bool TryGetValue<T>(Type type, out T? value)

Parameters

type Type

The type of the value.

value T

The value if it was found; otherwise, default(T).

Returns

bool

true if the value was found; otherwise, false.

Type Parameters

T

The type of the value. Only used for casting, not access.

TryGetValue<T>(out T?)

Tries to get the value associated with the type T in this AnyMap.

public bool TryGetValue<T>(out T? value)

Parameters

value T

The value if it was found; otherwise, default(T).

Returns

bool

true if the value was found; otherwise, false.

Type Parameters

T

The type of the value.