Class ResultProblemCollection
Represents a collection of problems encountered during an operation.
public class ResultProblemCollection : IEnumerable<ResultProblem>, IEnumerable
- Inheritance
-
ResultProblemCollection
- Implements
- Inherited Members
- Extension Methods
Constructors
ResultProblemCollection(params IEnumerable<ResultProblem>)
Represents a collection of problems encountered during an operation.
public ResultProblemCollection(params IEnumerable<ResultProblem> problems)
Parameters
problemsIEnumerable<ResultProblem>The problems encountered during the operation.
Properties
IsRetryable
Gets a value indicating whether the problems in this collection may be resolved by retrying: true if the collection is non-empty and every problem is retryable; otherwise false.
public bool IsRetryable { get; }
Property Value
Methods
Append(params IEnumerable<ResultProblem>)
Appends the specified problems to the collection.
public ResultProblemCollection Append(params IEnumerable<ResultProblem> resultProblems)
Parameters
resultProblemsIEnumerable<ResultProblem>The problems to append.
Returns
- ResultProblemCollection
A new collection with the specified problems appended.
GetEnumerator()
Returns an enumerator that iterates through the collection.
public IEnumerator<ResultProblem> GetEnumerator()
Returns
- IEnumerator<ResultProblem>
An enumerator that can be used to iterate through the collection.
Merge(params IEnumerable<ResultProblemCollection>)
Merges multiple problem collections together into a single collection.
public static ResultProblemCollection Merge(params IEnumerable<ResultProblemCollection> problemCollections)
Parameters
problemCollectionsIEnumerable<ResultProblemCollection>The problem collections to merge.
Returns
- ResultProblemCollection
A new collection containing all problems from the specified collections.
PickProblems<TProblem>()
Gets all problems assignable to TProblem, in enumeration order.
public IEnumerable<TProblem> PickProblems<TProblem>() where TProblem : ResultProblem
Returns
- IEnumerable<TProblem>
The matching problems, or an empty sequence if there are none.
Type Parameters
TProblemThe problem type to look for, typically a subclass of ResultProblem.
Prepend(bool, Exception, string, params object[])
Prepends a new problem from an exception to the collection using a formatted message, adding context to the existing problems.
public ResultProblemCollection Prepend(bool retryable, Exception exception, string message, params object[] args)
Parameters
retryableboolWhether the new problem is retryable.
exceptionExceptionThe exception causing the problem.
messagestringThe format string for the problem message.
argsobject[]The arguments to format the message.
Returns
- ResultProblemCollection
A new collection with the formatted problem prepended.
Prepend(bool, string, params object[])
Prepends a new problem to the collection using a formatted message, adding context to the existing problems.
public ResultProblemCollection Prepend(bool retryable, string message, params object[] args)
Parameters
retryableboolWhether the new problem is retryable.
messagestringThe format string for the problem message.
argsobject[]The arguments to format the message.
Returns
- ResultProblemCollection
A new collection with the formatted problem prepended.
Prepend(params IEnumerable<ResultProblem>)
Prepends the specified problems to the collection.
public ResultProblemCollection Prepend(params IEnumerable<ResultProblem> resultProblems)
Parameters
resultProblemsIEnumerable<ResultProblem>The problems to prepend.
Returns
- ResultProblemCollection
A new collection with the specified problems prepended.
Prepend(Exception, string, params object[])
Prepends a new problem from an exception to the collection using a formatted message, adding context to the existing problems. The new problem inherits IsRetryable from this collection.
public ResultProblemCollection Prepend(Exception exception, string message, params object[] args)
Parameters
exceptionExceptionThe exception causing the problem.
messagestringThe format string for the problem message.
argsobject[]The arguments to format the message.
Returns
- ResultProblemCollection
A new collection with the formatted problem prepended.
Prepend(string, params object[])
Prepends a new problem to the collection using a formatted message, adding context to the existing problems. The new problem inherits IsRetryable from this collection.
public ResultProblemCollection Prepend(string message, params object[] args)
Parameters
messagestringThe format string for the problem message.
argsobject[]The arguments to format the message.
Returns
- ResultProblemCollection
A new collection with the formatted problem prepended.
TryPickProblem<TProblem>(out TProblem?)
Attempts to retrieve the first problem assignable to TProblem, in enumeration order.
public bool TryPickProblem<TProblem>(out TProblem? problem) where TProblem : ResultProblem
Parameters
problemTProblemWhen this method returns true, contains the first matching problem. Otherwise, null.
Returns
Type Parameters
TProblemThe problem type to look for, typically a subclass of ResultProblem.