PropertyBag.SingleOrDefault<TProperty> Method

Definition

Returns the only property of the TProperty type, or default, and throws an exception if there is more than one element.

public TProperty? SingleOrDefault<TProperty>() where TProperty : Microsoft.Testing.Platform.Extensions.Messages.IProperty;
member this.SingleOrDefault : unit -> 'Property (requires 'Property :> Microsoft.Testing.Platform.Extensions.Messages.IProperty)
Public Function SingleOrDefault(Of TProperty As IProperty) () As TProperty

Type Parameters

TProperty

The type of the property.

Returns

TProperty

The single item of the given type or default.

Exceptions

Thrown when more than one property of the given type was found.

Applies to