Table of Contents

Class OutcomeGenerator<TResult>

Namespace
Polly.Simmy.Outcomes
Assembly
Polly.Core.dll

Generator that produces outcomes such as exceptions or results.

public sealed class OutcomeGenerator<TResult>

Type Parameters

TResult

The type of the result.

Inheritance
OutcomeGenerator<TResult>
Inherited Members

Remarks

An instance of this class is assignable to OutcomeGenerator.

Constructors

OutcomeGenerator()

Initializes a new instance of the OutcomeGenerator<TResult> class.

public OutcomeGenerator()

Methods

AddException(Func<ResilienceContext, Exception>, int)

Registers an exception generator delegate that accepts a ResilienceContext.

public OutcomeGenerator<TResult> AddException(Func<ResilienceContext, Exception> generator, int weight = 100)

Parameters

generator Func<ResilienceContext, Exception>

The delegate that generates the exception, accepting a ResilienceContext.

weight int

The weight assigned to this generator. Defaults to 100.

Returns

OutcomeGenerator<TResult>

The current instance of OutcomeGenerator<TResult>.

AddException(Func<Exception>, int)

Registers an exception generator delegate.

public OutcomeGenerator<TResult> AddException(Func<Exception> generator, int weight = 100)

Parameters

generator Func<Exception>

The delegate that generates the exception.

weight int

The weight assigned to this generator. Defaults to 100.

Returns

OutcomeGenerator<TResult>

The current instance of OutcomeGenerator<TResult>.

AddException<TException>(int)

Registers an exception generator for a specific exception type, using the default constructor of that exception.

public OutcomeGenerator<TResult> AddException<TException>(int weight = 100) where TException : Exception, new()

Parameters

weight int

The weight assigned to this generator. Defaults to 100.

Returns

OutcomeGenerator<TResult>

The current instance of OutcomeGenerator<TResult>.

Type Parameters

TException

The type of the exception to generate.

AddResult(Func<ResilienceContext, TResult>, int)

Registers a result generator.

public OutcomeGenerator<TResult> AddResult(Func<ResilienceContext, TResult> generator, int weight = 100)

Parameters

generator Func<ResilienceContext, TResult>

The delegate that generates the result, accepting a ResilienceContext.

weight int

The weight assigned to this generator. Defaults to 100.

Returns

OutcomeGenerator<TResult>

The current instance of OutcomeGenerator<TResult>.

AddResult(Func<TResult>, int)

Registers a result generator.

public OutcomeGenerator<TResult> AddResult(Func<TResult> generator, int weight = 100)

Parameters

generator Func<TResult>

The delegate that generates the result.

weight int

The weight assigned to this generator. Defaults to 100.

Returns

OutcomeGenerator<TResult>

The current instance of OutcomeGenerator<TResult>.