Table of Contents

Class DefaultConstructor

Namespace
Gym.Reflection
Assembly
Gym.dll

A static-cache to the default constructor of a type given at run time, the untyped twin of DefaultConstructor<T>: one delegate per type, cached for the process's life.

[Obsolete("Part of the legacy Dict's merging: use Activator.CreateInstance(type) or a new() constraint. Removed in 2.0 with Gym.Legacy.")]
public static class DefaultConstructor
Inheritance
DefaultConstructor
Inherited Members

Remarks

Obsolete with the legacy Dict (DR-56) and removed in 2.0: use CreateInstance(Type). The cache never forgets a type, so it keeps every type it saw loaded.

Methods

Activator(Type)

Gets default constructor or a construcotr that all of his parameters are optional.

public static Func<object> Activator(Type type)

Parameters

type Type

The type to construct.

Returns

Func<object>

A delegate that creates a new type each call, through reflection.

Exceptions

ArgumentNullException

When type is null.

DefaultConstructorNotFoundException

When type has no empty constructor or constructor with all default values.