Table of Contents

Class Decorator

Namespace
Cuemon
Assembly
Cuemon.Core.dll

Provides a way to support hiding of non-common extension methods by enclosing/wrapping an object within the IDecorator<T> interface.

public static class Decorator
Inheritance
Object
Decorator

Remarks

The original idea for this class was due to feedback from developers; often they are overwhelmed by vast numbers of extensions methods for various types of various libraries.

To help reduce the cognitive load inferred from this feedback (and to avoid traditional Utility/Helper classes), these interfaces and classes was added, leaving a sub-convenient way (fully backed by IntelliSense) to use non-common extension methods.

Pure extension methods should (IMO) be used in the way Microsoft has a paved path to the many NuGet packages complementing the .NET platform and overall follow these guidelines: https://learn.microsoft.com/en-us/dotnet/standard/design-guidelines/extension-methods.

Non-common extension methods could also include those rare cases were you need to support your product infrastructure cross-assembly.

Methods

Enclose<T>(T, Boolean)

Encloses the specified inner so that it can be extended by non-common extension methods.

public static Decorator<T> Enclose<T>(T inner, bool throwIfNull = true)

Parameters

inner T

The object to extend for non-common extension methods.

throwIfNull Boolean

true to throw an System.ArgumentNullException when inner is null; false to allow inner to be null. Default is true.

Returns

Decorator<T>

An instance of Decorator<T>.

Type Parameters

T

The type of the inner to wrap for non-common extension methods.

Exceptions

System.ArgumentNullException

inner cannot be null.

EncloseToExpose<T>(T, Boolean, String)

Encloses the specified inner so that it can be extended by both common and non-common extension methods.

public static Decorator<T> EncloseToExpose<T>(T inner, bool throwIfNull = true, string argumentName = null)

Parameters

inner T

The object to extend for non-common extension methods.

throwIfNull Boolean

true to throw an System.ArgumentNullException when inner is null; false to allow inner to be null. Default is true.

argumentName String

The name of the argument from which inner parameter was provided.

Returns

Decorator<T>

An instance of Decorator<T>.

Type Parameters

T

The type of the inner to wrap for non-common extension methods.

Remarks

This should be used to re-use non-common extension methods from native extension methods without double-validating arguments.

Exceptions

System.ArgumentNullException

inner cannot be null.

Syntactic<T>()

Syntactic sugar for the rare cases where retrieving properties exposed as methods is a necessity.

public static Decorator<T> Syntactic<T>()

Returns

Decorator<T>

An instance of Decorator<T> where the Inner defaults to T.

Type Parameters

T

The type to wrap for non-common extension methods.