Table of Contents

SafeInvoke Method

Definition

Namespace
Cuemon
Assemblies
Cuemon.Kernel.dll
Source
src/Cuemon.Kernel/Patterns.cs

SafeInvoke<TResult>(Func<TResult>, Func<TResult, TResult>, Action<Exception>)

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

public static TResult SafeInvoke<TResult>(Func<TResult> initializer, Func<TResult, TResult> tester, Action<Exception> catcher = null) where TResult : class, IDisposable

Parameters

initializer Func<TResult>

The function delegate that initializes an object implementing the IDisposable interface.

tester Func<TResult, TResult>

The function delegate that is used to ensure that operations performed on TResult abides CA2000.

catcher Action<Exception>

The delegate that will handle any exceptions that might have been thrown by tester.

Returns

TResult

The return value of the function delegate initializer if the operations succeeded; otherwise null if the operation failed.

Type Parameters

TResult

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

SafeInvoke<T, TResult>(Func<TResult>, Func<TResult, T, TResult>, T, Action<Exception, T>)

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

public static TResult SafeInvoke<T, TResult>(Func<TResult> initializer, Func<TResult, T, TResult> tester, T arg, Action<Exception, T> catcher = null) where TResult : class, IDisposable

Parameters

initializer Func<TResult>

The function delegate that initializes an object implementing the IDisposable interface.

tester Func<TResult, T, TResult>

The function delegate that is used to ensure that operations performed on TResult abides CA2000.

arg T

The parameter of the function delegate tester and delegate catcher.

catcher Action<Exception, T>

The delegate that will handle any exceptions that might have been thrown by tester.

Returns

TResult

The return value of the function delegate initializer if the operations succeeded; otherwise null if the operation failed.

Type Parameters

T

The type of the parameter of the function delegate tester and delegate catcher.

TResult

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

SafeInvoke<T1, T2, TResult>(Func<TResult>, Func<TResult, T1, T2, TResult>, T1, T2, Action<Exception, T1, T2>)

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

public static TResult SafeInvoke<T1, T2, TResult>(Func<TResult> initializer, Func<TResult, T1, T2, TResult> tester, T1 arg1, T2 arg2, Action<Exception, T1, T2> catcher = null) where TResult : class, IDisposable

Parameters

initializer Func<TResult>

The function delegate that initializes an object implementing the IDisposable interface.

tester Func<TResult, T1, T2, TResult>

The function delegate that is used to ensure that operations performed on TResult abides CA2000.

arg1 T1

The first parameter of the function delegate tester and delegate catcher.

arg2 T2

The second parameter of the function delegate tester and delegate catcher.

catcher Action<Exception, T1, T2>

The delegate that will handle any exceptions that might have been thrown by tester.

Returns

TResult

The return value of the function delegate initializer if the operations succeeded; otherwise null if the operation failed.

Type Parameters

T1

The type of the first parameter of the function delegate tester and delegate catcher.

T2

The type of the second parameter of the function delegate tester and delegate catcher.

TResult

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

SafeInvoke<T1, T2, T3, TResult>(Func<TResult>, Func<TResult, T1, T2, T3, TResult>, T1, T2, T3, Action<Exception, T1, T2, T3>)

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

public static TResult SafeInvoke<T1, T2, T3, TResult>(Func<TResult> initializer, Func<TResult, T1, T2, T3, TResult> tester, T1 arg1, T2 arg2, T3 arg3, Action<Exception, T1, T2, T3> catcher = null) where TResult : class, IDisposable

Parameters

initializer Func<TResult>

The function delegate that initializes an object implementing the IDisposable interface.

tester Func<TResult, T1, T2, T3, TResult>

The function delegate that is used to ensure that operations performed on TResult abides CA2000.

arg1 T1

The first parameter of the function delegate tester and delegate catcher.

arg2 T2

The second parameter of the function delegate tester and delegate catcher.

arg3 T3

The third parameter of the function delegate tester and delegate catcher.

catcher Action<Exception, T1, T2, T3>

The delegate that will handle any exceptions that might have been thrown by tester.

Returns

TResult

The return value of the function delegate initializer if the operations succeeded; otherwise null if the operation failed.

Type Parameters

T1

The type of the first parameter of the function delegate tester and delegate catcher.

T2

The type of the second parameter of the function delegate tester and delegate catcher.

T3

The type of the third parameter of the function delegate tester and delegate catcher.

TResult

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

SafeInvoke<T1, T2, T3, T4, TResult>(Func<TResult>, Func<TResult, T1, T2, T3, T4, TResult>, T1, T2, T3, T4, Action<Exception, T1, T2, T3, T4>)

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

public static TResult SafeInvoke<T1, T2, T3, T4, TResult>(Func<TResult> initializer, Func<TResult, T1, T2, T3, T4, TResult> tester, T1 arg1, T2 arg2, T3 arg3, T4 arg4, Action<Exception, T1, T2, T3, T4> catcher = null) where TResult : class, IDisposable

Parameters

initializer Func<TResult>

The function delegate that initializes an object implementing the IDisposable interface.

tester Func<TResult, T1, T2, T3, T4, TResult>

The function delegate that is used to ensure that operations performed on TResult abides CA2000.

arg1 T1

The first parameter of the function delegate tester and delegate catcher.

arg2 T2

The second parameter of the function delegate tester and delegate catcher.

arg3 T3

The third parameter of the function delegate tester and delegate catcher.

arg4 T4

The fourth parameter of the function delegate tester and delegate catcher.

catcher Action<Exception, T1, T2, T3, T4>

The delegate that will handle any exceptions that might have been thrown by tester.

Returns

TResult

The return value of the function delegate initializer if the operations succeeded; otherwise null if the operation failed.

Type Parameters

T1

The type of the first parameter of the function delegate tester and delegate catcher.

T2

The type of the second parameter of the function delegate tester and delegate catcher.

T3

The type of the third parameter of the function delegate tester and delegate catcher.

T4

The type of the fourth parameter of the function delegate tester and delegate catcher.

TResult

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

SafeInvoke<T1, T2, T3, T4, T5, TResult>(Func<TResult>, Func<TResult, T1, T2, T3, T4, T5, TResult>, T1, T2, T3, T4, T5, Action<Exception, T1, T2, T3, T4, T5>)

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

public static TResult SafeInvoke<T1, T2, T3, T4, T5, TResult>(Func<TResult> initializer, Func<TResult, T1, T2, T3, T4, T5, TResult> tester, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, Action<Exception, T1, T2, T3, T4, T5> catcher = null) where TResult : class, IDisposable

Parameters

initializer Func<TResult>

The function delegate that initializes an object implementing the IDisposable interface.

tester Func<TResult, T1, T2, T3, T4, T5, TResult>

The function delegate that is used to ensure that operations performed on TResult abides CA2000.

arg1 T1

The first parameter of the function delegate tester and delegate catcher.

arg2 T2

The second parameter of the function delegate tester and delegate catcher.

arg3 T3

The third parameter of the function delegate tester and delegate catcher.

arg4 T4

The fourth parameter of the function delegate tester and delegate catcher.

arg5 T5

The fifth parameter of the function delegate tester and delegate catcher.

catcher Action<Exception, T1, T2, T3, T4, T5>

The delegate that will handle any exceptions that might have been thrown by tester.

Returns

TResult

The return value of the function delegate initializer if the operations succeeded; otherwise null if the operation failed.

Type Parameters

T1

The type of the first parameter of the function delegate tester and delegate catcher.

T2

The type of the second parameter of the function delegate tester and delegate catcher.

T3

The type of the third parameter of the function delegate tester and delegate catcher.

T4

The type of the fourth parameter of the function delegate tester and delegate catcher.

T5

The type of the fifth parameter of the function delegate tester and delegate catcher.

TResult

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