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

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

Identifiers

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

Indexers

this[]

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

Methods

Add

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

Add

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

AddRange

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

AddRange

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

HasGuid

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

HasType

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

Instantiate

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

TryInstantiate

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