Class TypeDecoratorExtensions
Extension methods for the Type class tailored to adhere the decorator pattern.
Namespace: Cuemon
Assembly: Cuemon.Core.dll
Syntax
public static class TypeDecoratorExtensions
Methods
| Improve this Doc View SourceGetDefaultValue(IDecorator<Type>)
Gets the default value from the underlying Type of the decorator
.
Declaration
public static object GetDefaultValue(this IDecorator<Type> decorator)
Parameters
Type | Name | Description |
---|---|---|
IDecorator<Type> | decorator |
Returns
Type | Description |
---|---|
Object | The default value from the underlying Type of the |
Remarks
Usage is primarily intended for struct
.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
GetDerivedTypes(IDecorator<Type>, Assembly[])
Gets a collection (self-to-derived) of derived / descendant types from the underlying Type of the decorator
.
Declaration
public static IEnumerable<Type> GetDerivedTypes(this IDecorator<Type> decorator, params Assembly[] assemblies)
Parameters
Type | Name | Description |
---|---|---|
IDecorator<Type> | decorator | The IDecorator<T> to extend. |
Assembly[] | assemblies | The assemblies to include in the search of derived types. |
Returns
Type | Description |
---|---|
IEnumerable<Type> | An IEnumerable<T> that contains the derived types from the underlying Type of the |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
GetHierarchyTypes(IDecorator<Type>, Assembly[])
Gets a collection (inherited-to-self-to-derived) of inherited / ancestor and derived / descendant types from the underlying Type of the decorator
.
Declaration
public static IEnumerable<Type> GetHierarchyTypes(this IDecorator<Type> decorator, params Assembly[] assemblies)
Parameters
Type | Name | Description |
---|---|---|
IDecorator<Type> | decorator | The IDecorator<T> to extend. |
Assembly[] | assemblies | The assemblies to include in the search of derived types. |
Returns
Type | Description |
---|---|
IEnumerable<Type> | An IEnumerable<T> that contains a sorted (base-to-derived) collection of inherited and derived types from the underlying Type of the |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
GetInheritedTypes(IDecorator<Type>)
Gets a collection (inherited-to-self) of inherited / ancestor types from the underlying Type of the decorator
.
Declaration
public static IEnumerable<Type> GetInheritedTypes(this IDecorator<Type> decorator)
Parameters
Type | Name | Description |
---|---|---|
IDecorator<Type> | decorator | The IDecorator<T> to extend. |
Returns
Type | Description |
---|---|
IEnumerable<Type> | An IEnumerable<T> that contains the inherited types from the underlying Type of the |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
GetRuntimePropertiesExceptOf<T>(IDecorator<Type>)
Retrieves a collection that represents all the properties defined on the enclosed Type of the decorator
except those defined on T
.
Declaration
public static IEnumerable<PropertyInfo> GetRuntimePropertiesExceptOf<T>(this IDecorator<Type> decorator)
Parameters
Type | Name | Description |
---|---|---|
IDecorator<Type> | decorator | The IDecorator<T> to extend. |
Returns
Type | Description |
---|---|
IEnumerable<PropertyInfo> | A collection of properties for the enclosed Type of the |
Type Parameters
Name | Description |
---|---|
T | The type to exclude properties on the enclosed Type of the |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
HasAnonymousCharacteristics(IDecorator<Type>)
Determines whether the underlying Type of the decorator
suggest an anonymous implementation (be that in a form of a type, delegate or lambda expression).
Declaration
public static bool HasAnonymousCharacteristics(this IDecorator<Type> decorator)
Parameters
Type | Name | Description |
---|---|---|
IDecorator<Type> | decorator | The IDecorator<T> to extend. |
Returns
Type | Description |
---|---|
Boolean |
|
Remarks
If you can avoid it, don't use this method. It is - to say the least - fragile.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
HasAttribute(IDecorator<Type>, Type[])
Determines whether the underlying Type of the decorator
implements one or more of the specified attributeTypes
.
Declaration
public static bool HasAttribute(this IDecorator<Type> decorator, params Type[] attributeTypes)
Parameters
Type | Name | Description |
---|---|---|
IDecorator<Type> | decorator | The IDecorator<T> to extend. |
Type[] | attributeTypes | The attribute types to be matched against. |
Returns
Type | Description |
---|---|
Boolean |
|
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
HasCircularReference(IDecorator<Type>, Object, Int32, Func<Object, PropertyInfo, Object>)
Determines whether the specified source
(which type must be the same as the underlying Type of the decorator
) has a circular reference.
Declaration
public static bool HasCircularReference(this IDecorator<Type> decorator, object source, int maxDepth = 2, Func<object, PropertyInfo, object> valueResolver = null)
Parameters
Type | Name | Description |
---|---|---|
IDecorator<Type> | decorator | The IDecorator<T> to extend. |
Object | source | The source to check for circular reference. |
Int32 | maxDepth | The maximum depth to traverse of |
Func<Object, PropertyInfo, Object> | valueResolver | The function delegate that is invoked when a property can be read and is of same type as the underlying Type of the |
Returns
Type | Description |
---|---|
Boolean |
|
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
InvalidOperationException |
|
HasComparableImplementation(IDecorator<Type>)
Determines whether the underlying Type of the decorator
implements either IComparable or IComparable<T>.
Declaration
public static bool HasComparableImplementation(this IDecorator<Type> decorator)
Parameters
Type | Name | Description |
---|---|---|
IDecorator<Type> | decorator | The IDecorator<T> to extend. |
Returns
Type | Description |
---|---|
Boolean |
|
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
HasComparerImplementation(IDecorator<Type>)
Determines whether the underlying Type of the decorator
implements either IComparer or IComparer<T>.
Declaration
public static bool HasComparerImplementation(this IDecorator<Type> decorator)
Parameters
Type | Name | Description |
---|---|---|
IDecorator<Type> | decorator | The IDecorator<T> to extend. |
Returns
Type | Description |
---|---|
Boolean |
|
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
HasDefaultConstructor(IDecorator<Type>)
Determines whether the underlying Type of the decorator
has a default constructor.
Declaration
public static bool HasDefaultConstructor(this IDecorator<Type> decorator)
Parameters
Type | Name | Description |
---|---|---|
IDecorator<Type> | decorator |
Returns
Type | Description |
---|---|
Boolean |
|
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
HasDictionaryImplementation(IDecorator<Type>)
Determines whether the underlying Type of the decorator
implements either IDictionary, IDictionary<TKey,TValue> or IReadOnlyDictionary<TKey,TValue>.
Declaration
public static bool HasDictionaryImplementation(this IDecorator<Type> decorator)
Parameters
Type | Name | Description |
---|---|---|
IDecorator<Type> | decorator | The IDecorator<T> to extend. |
Returns
Type | Description |
---|---|
Boolean |
|
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
HasEnumerableImplementation(IDecorator<Type>)
Determines whether the underlying Type of the decorator
implements either IEnumerable or IEnumerable<T>.
Declaration
public static bool HasEnumerableImplementation(this IDecorator<Type> decorator)
Parameters
Type | Name | Description |
---|---|---|
IDecorator<Type> | decorator | The IDecorator<T> to extend. |
Returns
Type | Description |
---|---|
Boolean |
|
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
HasEqualityComparerImplementation(IDecorator<Type>)
Determines whether the underlying Type of the decorator
implements either IEqualityComparer or IEqualityComparer<T>.
Declaration
public static bool HasEqualityComparerImplementation(this IDecorator<Type> decorator)
Parameters
Type | Name | Description |
---|---|---|
IDecorator<Type> | decorator | The IDecorator<T> to extend. |
Returns
Type | Description |
---|---|
Boolean |
|
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
HasInterface(IDecorator<Type>, Type[])
Determines whether the underlying Type of the decorator
implements one or more of the specified interfaceTypes
.
Declaration
public static bool HasInterface(this IDecorator<Type> decorator, params Type[] interfaceTypes)
Parameters
Type | Name | Description |
---|---|---|
IDecorator<Type> | decorator | The IDecorator<T> to extend. |
Type[] | interfaceTypes | The interface types to be matched against. |
Returns
Type | Description |
---|---|
Boolean |
|
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
HasKeyValuePairImplementation(IDecorator<Type>)
Determines whether the underlying Type of the decorator
implements either DictionaryEntry or KeyValuePair<TKey,TValue>.
Declaration
public static bool HasKeyValuePairImplementation(this IDecorator<Type> decorator)
Parameters
Type | Name | Description |
---|---|---|
IDecorator<Type> | decorator | The IDecorator<T> to extend. |
Returns
Type | Description |
---|---|
Boolean |
|
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
HasTypes(IDecorator<Type>, Type[])
Determines whether the enclosed Type of the decorator
contains one or more of the specified types
.
Declaration
public static bool HasTypes(this IDecorator<Type> decorator, params Type[] types)
Parameters
Type | Name | Description |
---|---|---|
IDecorator<Type> | decorator | The IDecorator<T> to extend. |
Type[] | types | The types to be matched against. |
Returns
Type | Description |
---|---|
Boolean |
|
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
IsComplex(IDecorator<Type>)
Determines whether the underlying Type of the decorator
is considered complex in its nature.
Declaration
public static bool IsComplex(this IDecorator<Type> decorator)
Parameters
Type | Name | Description |
---|---|---|
IDecorator<Type> | decorator | The IDecorator<T> to extend. |
Returns
Type | Description |
---|---|
Boolean |
|
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
IsNullable(IDecorator<Type>)
Declaration
public static bool IsNullable(this IDecorator<Type> decorator)
Parameters
Type | Name | Description |
---|---|---|
IDecorator<Type> | decorator | The IDecorator<T> to extend. |
Returns
Type | Description |
---|---|
Boolean |
|
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
MatchMember(IDecorator<Type>, String, Action<MethodBaseOptions>)
Conduct a search for memberName
using the specified setup
on the underlying Type of the decorator
.
Declaration
public static MethodBase MatchMember(this IDecorator<Type> decorator, string memberName, Action<MethodBaseOptions> setup = null)
Parameters
Type | Name | Description |
---|---|---|
IDecorator<Type> | decorator | The IDecorator<T> to extend. |
String | memberName | The name of the member on the underlying Type of the |
Action<MethodBaseOptions> | setup | The MethodBaseOptions which may be configured. |
Returns
Type | Description |
---|---|
MethodBase | A MethodBase object representing the method that matches the specified requirements, if found on the underlying Type of the |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ArgumentException |
|
ToFriendlyName(IDecorator<Type>, Action<TypeNameOptions>)
Declaration
public static string ToFriendlyName(this IDecorator<Type> decorator, Action<TypeNameOptions> setup = null)
Parameters
Type | Name | Description |
---|---|---|
IDecorator<Type> | decorator | The IDecorator<T> to extend. |
Action<TypeNameOptions> | setup | The TypeNameOptions which may be configured. |
Returns
Type | Description |
---|---|
String | A human readable String that represents the underlying Type of the |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|