Table of Contents

Class AssemblyContextOptions

Namespace
Cuemon.Reflection
Assembly
Cuemon.Core.dll

Provides configuration options for the AssemblyContext class.

public class AssemblyContextOptions : IValidatableParameterObject, IParameterObject
Inheritance
AssemblyContextOptions
Implements

Constructors

AssemblyContextOptions()

Initializes a new instance of the AssemblyContextOptions class.

public AssemblyContextOptions()

Remarks

The following table shows the initial property values for an instance of AssemblyContextOptions.

PropertyInitial Value
IncludeReferencedAssembliestrue
AssemblyFilterThe default implementation excludes assemblies whose full name starts with System, Microsoft or have a root namespace of System or Microsoft
ReferencedAssemblyFilterThe default implementation excludes assemblies whose full name starts with System or Microsoft
ExcludedAssembliesThe default implementation excludes this assembly, e.g., Cuemon.Core

Properties

AssemblyFilter

Gets or sets a predicate used to filter which assemblies are included during assembly context resolution.

public Func<Assembly, bool> AssemblyFilter { get; set; }

Property Value

Func<Assembly, bool>

A Func<T, TResult> that receives an Assembly and returns true if the assembly should be included; otherwise, false.

Remarks

This filter is applied to assemblies in the current application domain. The default predicate excludes any assembly whose FullName starts with System or Microsoft, and additionally excludes any assembly whose exported types are rooted in the System or Microsoft namespace, limiting resolution to application-level dependencies. Results of the type-scan are cached per assembly identity to avoid repeated enumeration on subsequent calls.

ExcludedAssemblies

Gets or sets the collection of assemblies that are unconditionally excluded from the result of GetCurrentDomainAssemblies(Action<AssemblyContextOptions>).

public ICollection<Assembly> ExcludedAssemblies { get; set; }

Property Value

ICollection<Assembly>

A mutable ICollection<T> of Assembly instances that will never appear in the resolved output, regardless of the AssemblyFilter or ReferencedAssemblyFilter predicates.

Remarks

By default this collection contains the assembly that defines AssemblyContextOptions itself (i.e., Cuemon.Core), preventing internal infrastructure assemblies from leaking into consumer results. Add additional assemblies to this collection when callers must suppress specific entries from the resolved set.

IncludeReferencedAssemblies

Gets or sets a value indicating whether referenced assemblies should be included when resolving assembly context.

public bool IncludeReferencedAssemblies { get; set; }

Property Value

bool

true if referenced assemblies should be included; otherwise, false.

Remarks

When set to true, the assembly context will include assemblies that are referenced by the assemblies in the current application domain. When set to false, only the assemblies in the current application domain will be included.

ReferencedAssemblyFilter

Gets or sets a predicate used to filter which referenced assemblies are included during assembly context resolution.

public Func<AssemblyName, bool> ReferencedAssemblyFilter { get; set; }

Property Value

Func<AssemblyName, bool>

A Func<T, TResult> that receives an AssemblyName and returns true if the assembly should be included; otherwise, false.

Remarks

This filter is only applied when IncludeReferencedAssemblies is true. The default predicate excludes any assembly whose FullName starts with System or Microsoft, limiting resolution to application-level dependencies.

Methods

ValidateOptions()

Determines whether the public read-write properties of this instance are in a valid state.

public void ValidateOptions()

Exceptions

InvalidOperationException

AssemblyFilter cannot be null - or - ExcludedAssemblies cannot be null - or - ReferencedAssemblyFilter cannot be null.

See Also