Show / Hide Table of Contents

    Class DelegateUtility

    This utility class is designed to make common delegate operations easier to work with.

    Inheritance
    System.Object
    DelegateUtility
    Namespace: Cuemon
    Assembly: Cuemon.Core.dll
    Syntax
    public static class DelegateUtility

    Methods

    | Improve this Doc

    ConfigureAction<TOptions>(Action<TOptions>, Action<TOptions>)

    Provides a generic way to support the options pattern which enables using custom options classes to represent a group of related settings.

    Declaration
    public static TOptions ConfigureAction<TOptions>(Action<TOptions> setup, Action<TOptions> initializer = null)
    Parameters
    Type Name Description
    System.Action<TOptions> setup

    The delegate that will configure the public read-write properties of TOptions.

    System.Action<TOptions> initializer

    The function delegate that will initialize the default, parameterless constructed instance of TOptions.

    Returns
    Type Description
    TOptions

    A default constructed instance of TOptions initialized with the options of setup.

    Type Parameters
    Name Description
    TOptions

    The type of the custom options class.

    | Improve this Doc

    DynamicWrap<TResult>(TResult)

    Provides a way to dynamically wrap a return value (typically from a property or field) inside an anonymous method.

    Declaration
    public static Func<TResult> DynamicWrap<TResult>(TResult output)
    Parameters
    Type Name Description
    TResult output

    The value to dynamically wrap as a return value (typically from a property of field) inside an anonymous method.

    Returns
    Type Description
    System.Func<TResult>

    An anonymous method that returns the value of output.

    Type Parameters
    Name Description
    TResult

    The type of the return value of output.

    | Improve this Doc

    InvokeIfNotNull(Action)

    If the specified body meets the condition of not being null, it will be invoked.

    Declaration
    public static void InvokeIfNotNull(Action body)
    Parameters
    Type Name Description
    System.Action body

    The delegate to invoke when assigned a method.

    | Improve this Doc

    InvokeIfNotNull<T>(Action<T>, T)

    If the specified body meets the condition of not being null, it will be invoked with a single generic parameter.

    Declaration
    public static void InvokeIfNotNull<T>(Action<T> body, T arg)
    Parameters
    Type Name Description
    System.Action<T> body

    The delegate to invoke when assigned a method.

    T arg

    The parameter of the delegate body.

    Type Parameters
    Name Description
    T

    The type of the parameter of the delegate body.

    | Improve this Doc

    InvokeIfNotNull<T1, T2>(Action<T1, T2>, T1, T2)

    If the specified body meets the condition of not being null, it will be invoked with two generic parameters.

    Declaration
    public static void InvokeIfNotNull<T1, T2>(Action<T1, T2> body, T1 arg1, T2 arg2)
    Parameters
    Type Name Description
    System.Action<T1, T2> body

    The delegate to invoke when assigned a method.

    T1 arg1

    The first parameter of the delegate body.

    T2 arg2

    The second parameter of the delegate body.

    Type Parameters
    Name Description
    T1

    The type of the first parameter of the delegate body.

    T2

    The type of the second parameter of the delegate body.

    | Improve this Doc

    InvokeIfNotNull<T1, T2, T3>(Action<T1, T2, T3>, T1, T2, T3)

    If the specified body meets the condition of not being null, it will be invoked with three generic parameters.

    Declaration
    public static void InvokeIfNotNull<T1, T2, T3>(Action<T1, T2, T3> body, T1 arg1, T2 arg2, T3 arg3)
    Parameters
    Type Name Description
    System.Action<T1, T2, T3> body

    The delegate to invoke when assigned a method.

    T1 arg1

    The first parameter of the delegate body.

    T2 arg2

    The second parameter of the delegate body.

    T3 arg3

    The third parameter of the delegate body.

    Type Parameters
    Name Description
    T1

    The type of the first parameter of the delegate body.

    T2

    The type of the second parameter of the delegate body.

    T3

    The type of the third parameter of the delegate body.

    | Improve this Doc

    InvokeIfNotNull<T1, T2, T3, T4>(Action<T1, T2, T3, T4>, T1, T2, T3, T4)

    If the specified body meets the condition of not being null, it will be invoked with four generic parameters.

    Declaration
    public static void InvokeIfNotNull<T1, T2, T3, T4>(Action<T1, T2, T3, T4> body, T1 arg1, T2 arg2, T3 arg3, T4 arg4)
    Parameters
    Type Name Description
    System.Action<T1, T2, T3, T4> body

    The delegate to invoke when assigned a method.

    T1 arg1

    The first parameter of the delegate body.

    T2 arg2

    The second parameter of the delegate body.

    T3 arg3

    The third parameter of the delegate body.

    T4 arg4

    The fourth parameter of the delegate body.

    Type Parameters
    Name Description
    T1

    The type of the first parameter of the delegate body.

    T2

    The type of the second parameter of the delegate body.

    T3

    The type of the third parameter of the delegate body.

    T4

    The type of the fourth parameter of the delegate body.

    | Improve this Doc

    InvokeIfNotNull<T1, T2, T3, T4, T5>(Action<T1, T2, T3, T4, T5>, T1, T2, T3, T4, T5)

    If the specified body meets the condition of not being null, it will be invoked with five generic parameters.

    Declaration
    public static void InvokeIfNotNull<T1, T2, T3, T4, T5>(Action<T1, T2, T3, T4, T5> body, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5)
    Parameters
    Type Name Description
    System.Action<T1, T2, T3, T4, T5> body

    The delegate to invoke when assigned a method.

    T1 arg1

    The first parameter of the delegate body.

    T2 arg2

    The second parameter of the delegate body.

    T3 arg3

    The third parameter of the delegate body.

    T4 arg4

    The fourth parameter of the delegate body.

    T5 arg5

    The fifth parameter of the delegate body.

    Type Parameters
    Name Description
    T1

    The type of the first parameter of the delegate body.

    T2

    The type of the second parameter of the delegate body.

    T3

    The type of the third parameter of the delegate body.

    T4

    The type of the fourth parameter of the delegate body.

    T5

    The type of the fifth parameter of the delegate body.

    | Improve this Doc

    SafeInvokeDisposable<TResult>(Func<TResult>)

    Provides a generic way to abide the rule description of CA2000 (Dispose objects before losing scope).

    Declaration
    public static TResult SafeInvokeDisposable<TResult>(Func<TResult> initializer)
        where TResult : class, IDisposable
    Parameters
    Type Name Description
    System.Func<TResult> initializer

    The function delegate to invoke following the rule description of CA2000 (Dispose objects before losing scope).

    Returns
    Type Description
    TResult

    The return value of the function delegate initializer.

    Type Parameters
    Name Description
    TResult

    The type of the return value of the function delegate initializer.

    | Improve this Doc

    SafeInvokeDisposable<T, TResult>(Func<T, TResult>, T)

    Provides a generic way to abide the rule description of CA2000 (Dispose objects before losing scope).

    Declaration
    public static TResult SafeInvokeDisposable<T, TResult>(Func<T, TResult> initializer, T arg)
        where TResult : class, IDisposable
    Parameters
    Type Name Description
    System.Func<T, TResult> initializer

    The function delegate to invoke following the rule description of CA2000 (Dispose objects before losing scope).

    T arg

    The parameter of the function delegate initializer.

    Returns
    Type Description
    TResult

    The return value of the function delegate initializer.

    Type Parameters
    Name Description
    T

    The type of the parameter of the function delegate initializer.

    TResult

    The type of the return value of the function delegate initializer.

    | Improve this Doc

    SafeInvokeDisposable<T1, T2, TResult>(Func<T1, T2, TResult>, T1, T2)

    Provides a generic way to abide the rule description of CA2000 (Dispose objects before losing scope).

    Declaration
    public static TResult SafeInvokeDisposable<T1, T2, TResult>(Func<T1, T2, TResult> initializer, T1 arg1, T2 arg2)
        where TResult : class, IDisposable
    Parameters
    Type Name Description
    System.Func<T1, T2, TResult> initializer

    The function delegate to invoke following the rule description of CA2000 (Dispose objects before losing scope).

    T1 arg1

    The first parameter of the function delegate initializer.

    T2 arg2

    The second parameter of the function delegate initializer.

    Returns
    Type Description
    TResult

    The return value of the function delegate initializer.

    Type Parameters
    Name Description
    T1

    The type of the first parameter of the function delegate initializer.

    T2

    The type of the second parameter of the function delegate initializer.

    TResult

    The type of the return value of the function delegate initializer.

    | Improve this Doc

    SafeInvokeDisposable<T1, T2, T3, TResult>(Func<T1, T2, T3, TResult>, T1, T2, T3)

    Provides a generic way to abide the rule description of CA2000 (Dispose objects before losing scope).

    Declaration
    public static TResult SafeInvokeDisposable<T1, T2, T3, TResult>(Func<T1, T2, T3, TResult> initializer, T1 arg1, T2 arg2, T3 arg3)
        where TResult : class, IDisposable
    Parameters
    Type Name Description
    System.Func<T1, T2, T3, TResult> initializer

    The function delegate to invoke following the rule description of CA2000 (Dispose objects before losing scope).

    T1 arg1

    The first parameter of the function delegate initializer.

    T2 arg2

    The second parameter of the function delegate initializer.

    T3 arg3

    The third parameter of the function delegate initializer.

    Returns
    Type Description
    TResult

    The return value of the function delegate initializer.

    Type Parameters
    Name Description
    T1

    The type of the first parameter of the function delegate initializer.

    T2

    The type of the second parameter of the function delegate initializer.

    T3

    The type of the third parameter of the function delegate initializer.

    TResult

    The type of the return value of the function delegate initializer.

    | Improve this Doc

    SafeInvokeDisposable<T1, T2, T3, T4, TResult>(Func<T1, T2, T3, T4, TResult>, T1, T2, T3, T4)

    Provides a generic way to abide the rule description of CA2000 (Dispose objects before losing scope).

    Declaration
    public static TResult SafeInvokeDisposable<T1, T2, T3, T4, TResult>(Func<T1, T2, T3, T4, TResult> initializer, T1 arg1, T2 arg2, T3 arg3, T4 arg4)
        where TResult : class, IDisposable
    Parameters
    Type Name Description
    System.Func<T1, T2, T3, T4, TResult> initializer

    The function delegate to invoke following the rule description of CA2000 (Dispose objects before losing scope).

    T1 arg1

    The first parameter of the function delegate initializer.

    T2 arg2

    The second parameter of the function delegate initializer.

    T3 arg3

    The third parameter of the function delegate initializer.

    T4 arg4

    The fourth parameter of the function delegate initializer.

    Returns
    Type Description
    TResult

    The return value of the function delegate initializer.

    Type Parameters
    Name Description
    T1

    The type of the first parameter of the function delegate initializer.

    T2

    The type of the second parameter of the function delegate initializer.

    T3

    The type of the third parameter of the function delegate initializer.

    T4

    The type of the fourth parameter of the function delegate initializer.

    TResult

    The type of the return value of the function delegate initializer.

    | Improve this Doc

    SafeInvokeDisposable<T1, T2, T3, T4, T5, TResult>(Func<T1, T2, T3, T4, T5, TResult>, T1, T2, T3, T4, T5)

    Provides a generic way to abide the rule description of CA2000 (Dispose objects before losing scope).

    Declaration
    public static TResult SafeInvokeDisposable<T1, T2, T3, T4, T5, TResult>(Func<T1, T2, T3, T4, T5, TResult> initializer, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5)
        where TResult : class, IDisposable
    Parameters
    Type Name Description
    System.Func<T1, T2, T3, T4, T5, TResult> initializer

    The function delegate to invoke following the rule description of CA2000 (Dispose objects before losing scope).

    T1 arg1

    The first parameter of the function delegate initializer.

    T2 arg2

    The second parameter of the function delegate initializer.

    T3 arg3

    The third parameter of the function delegate initializer.

    T4 arg4

    The fourth parameter of the function delegate initializer.

    T5 arg5

    The fifth parameter of the function delegate initializer.

    Returns
    Type Description
    TResult

    The return value of the function delegate initializer.

    Type Parameters
    Name Description
    T1

    The type of the first parameter of the function delegate initializer.

    T2

    The type of the second parameter of the function delegate initializer.

    T3

    The type of the third parameter of the function delegate initializer.

    T4

    The type of the fourth parameter of the function delegate initializer.

    T5

    The type of the fifth parameter of the function delegate initializer.

    TResult

    The type of the return value of the function delegate initializer.

    | Improve this Doc

    Wrap<TResult>(TResult)

    Provides an easy and reflection less way to get a value from a property or field that is delegate compatible (such as System.Func<TResult> and the likes thereof).

    Declaration
    public static TResult Wrap<TResult>(TResult output)
    Parameters
    Type Name Description
    TResult output

    The value of the member to be routed as output through this Wrap{TResult} method.

    Returns
    Type Description
    TResult

    The value from output.

    Type Parameters
    Name Description
    TResult

    The type of the return value of output.

    • Improve this Doc
    • View Source
    Back to top Copyright 2008-2018 Weubphoria. All rights reserved.
    Generated by DocFX