Table of Contents

Interface IMarkupActivator

Namespace
Icy.Markup
Assembly
IcyUI.dll

Constructs the objects a markup document declares.

public interface IMarkupActivator
Extension Methods

Remarks

The loader never calls Activator directly; every object it produces comes through here. That makes construction a single replaceable seam, which is what lets later work slot in without reshaping the loader: a source generator can supply compiled construction for the types it knows, a container can inject dependencies, and a designer can substitute stand-ins for types that misbehave outside a running game.

Replace the configured one through Activator.

Methods

CreateInstance(Type)

Creates an instance of type.

object CreateInstance(Type type)

Parameters

type Type

The type to construct, already resolved from the markup tag.

Returns

object

The new instance. Never null.

Exceptions

MarkupException

The type could not be constructed.

CreateInstance(Type, IReadOnlyDictionary<string, object?>)

Creates an instance of type using a constructor whose parameters are all satisfied by constructorArguments, for a type that has no parameterless constructor.

object CreateInstance(Type type, IReadOnlyDictionary<string, object?> constructorArguments)

Parameters

type Type

The type to construct, already resolved from the markup tag.

constructorArguments IReadOnlyDictionary<string, object>

The already-converted argument values, keyed by constructor parameter name (case-insensitive).

Returns

object

The new instance. Never null.

Remarks

The default implementation throws, so an existing custom IMarkupActivator that only overrides CreateInstance(Type) keeps compiling and fails clearly for a type it can't construct, rather than silently misbehaving.

Exceptions

MarkupException

type has no single public constructor whose parameters are all covered by constructorArguments, or construction threw.

ResolveConstructor(Type, IReadOnlyCollection<string>)

Resolves the constructor type should be built through, given the attribute names available to bind as arguments, for a type with no parameterless constructor.

ConstructorInfo ResolveConstructor(Type type, IReadOnlyCollection<string> availableAttributeNames)

Parameters

type Type

The type to resolve a constructor for.

availableAttributeNames IReadOnlyCollection<string>

The attribute names available on the markup element (case-insensitive).

Returns

ConstructorInfo

The constructor to use.

Remarks

The default implementation throws, matching CreateInstance(Type, IReadOnlyDictionary<string, object?>)'s pattern, so an existing custom IMarkupActivator that predates this method keeps compiling.

Exceptions

MarkupException

No constructor - or more than one - has its parameters fully covered by availableAttributeNames.