TypeFamily<T>

public sealed class TypeFamily<T>
A collection of types with their associated IDs. This collection is designed to store a comprehensive list of all the implementations of a specific interface or base class for the purposes of (de)serialisation.
T where IStorable

Properties

Count

#
Gets the number of stored pairs.
public int Count { get; }

Identifiers

#
Iterate over all type identifiers.
public IEnumerable<Guid> Identifiers { get; }

Indexers

this[]

#
Gets the type associated with the given ID.
public Type this[
id
] { get; }

Methods

Add

#
Add an id/type pair to this collection.
public bool Add(
guid,
type
)

Add

#
Add a type to this collection. This overload requires that the type has a Grasshopper2.IdentityAttribute associated with it.
public bool Add(
type
)
True if the type was added.

AddRange

#
Add a bunch of id/type pairs to this collection.
public Type[] AddRange(
Guid[]
guids,
Type[]
types
)

AddRange

#
Add a bunch of types to this collection. This overload requires that the types all have a Grasshopper2.IdentityAttribute associated with them.
public Type[] AddRange(
params Type[]
types
)

HasGuid

#
Test whether a GUID is already part of this list.
public bool HasGuid(
id
)

HasType

#
Test whether a GUID is already part of this list.
public bool HasType(
type
)

Instantiate

#
Construct an instance of one of the types. This method either throws or returns a constructed instance.
public T Instantiate(
id,
ID of pair.
params object[]
arguments
Optional arguments.
)
Instance of T.

TryInstantiate

#
Try to construct an instance of one of the types.
public bool TryInstantiate(
id,
ID of pair.
out T
instance,
Constructed instance.
params object[]
arguments
Optional arguments.
)
True on success, false on failure.