Table of Contents

ActivatorOptions Class

Definition

Namespace
Cuemon.Reflection
Assemblies
Cuemon.Core.dll
Source
src/Cuemon.Core/Reflection/ActivatorOptions.cs

Configuration options for ActivatorFactory.

public class ActivatorOptions : FormattingOptions, IValidatableParameterObject, IParameterObject
Inheritance
object
ActivatorOptions
Implements
Inherited Members

Examples

The following example demonstrates how to use with to customize object creation with specific binding flags.

using System;
using System.Reflection;
using Cuemon.Reflection;

namespace MyApp.Examples;

public class ActivatorOptionsExample
{
    public void Demonstrate()
    {
        // Direct instantiation of ActivatorOptions
        var options = new ActivatorOptions
        {
            Flags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.CreateInstance
        };

        // Create a Uri instance using a factory with explicit binding flags
        var uri = ActivatorFactory.CreateInstance<string, Uri>("http://example.com", o =>
        {
            o.Flags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.CreateInstance;
        });

        Console.WriteLine(uri.Host);

}
}

Constructors

Name Description
ActivatorOptions()

Initializes a new instance of the ActivatorOptions class.

Properties

Name Description
Binder

Gets or sets the binder that uses Flags and the specified arguments to seek and identify the type constructor.

Flags

Gets the binding constraint used for discovering a suitable constructor.