Table of Contents

Class DefaultMarkupActivator

Namespace
Icy.Markup
Assembly
IcyUI.dll

The default IMarkupActivator: constructs types through their parameterless constructor.

public sealed class DefaultMarkupActivator : IMarkupActivator
Inheritance
DefaultMarkupActivator
Implements
Inherited Members
Extension Methods

Remarks

Every built-in control has one, and markup has no syntax for constructor arguments, so this covers the whole language as it stands.

Methods

CreateInstance(Type)

Creates an instance of type.

public 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.

public 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.

public 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.