Table of Contents

Class CastExtensions

Namespace
CSF.Screenplay
Assembly
CSF.Screenplay.Abstractions.dll

Extension methods for ICast.

public static class CastExtensions
Inheritance
CastExtensions
Inherited Members

Methods

GetActor<TPersona>(ICast)

Gets a single Actor based upon a persona, creating them if they do not already exist in the cast.

public static Actor GetActor<TPersona>(this ICast cast) where TPersona : class, IPersona

Parameters

cast ICast

The cast from which to get an actor

Returns

Actor

An actor based on the specified persona, either an existing instance or a newly-created actor.

Type Parameters

TPersona

A concrete type of IPersona from which to get an actor.

Remarks

This method will create the actor within the current cast, using a resolved instance of the persona as a factory, if they do not already exist. Alternatively, this method will return the existing actor, if they already exist in the cast, matched using the IPersona's Name.

Actor names are matched using a case-insensitive invariant culture string comparison. Cast implementations should match an existing actor if the specified persona name differs only in case.

This method is the recommended way of getting an actor from a persona, as it takes care of resolving the persona from dependency injection automatically.

See Also