Table of Contents

Class Cast

Namespace
CSF.Screenplay.Actors
Assembly
CSF.Screenplay.dll

The default implementation of ICast which serves as a registry/factory for Actor instances.

public sealed class Cast : ICast, IHasServiceProvider, IHasPerformanceIdentity
Inheritance
Cast
Implements
Inherited Members

Constructors

Cast(IServiceProvider, Guid)

Initialises a new instance of Cast.

public Cast(IServiceProvider serviceProvider, Guid performanceIdentity)

Parameters

serviceProvider IServiceProvider

A service provider

performanceIdentity Guid

The identity of the current performance

Exceptions

ArgumentNullException

If serviceProvider is null.

Properties

PerformanceIdentity

Gets the unique IPerformance identifier

public Guid PerformanceIdentity { get; }

Property Value

Guid

Remarks

This value is used to uniquely identify a performance within a CSF.Screenplay.

ServiceProvider

Gets a service provider/resolver instance associated with this object.

public IServiceProvider ServiceProvider { get; }

Property Value

IServiceProvider

Methods

GetActor(IPersona)

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

public Actor GetActor(IPersona persona)

Parameters

persona IPersona

The persona from which to get an actor

Returns

Actor

An actor of the specified name, either an existing instance or a newly-created actor.

Remarks

This method will create the actor within the current cast, using 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.

Consider using GetActor<TPersona>(ICast) instead of this method; the generic version takes care of resolving the persona instance from dependency injection for you.

See Also

GetActor(string)

Gets a single Actor by their name, creating them if they do not already exist in the cast.

public Actor GetActor(string name)

Parameters

name string

The name of the actor to get

Returns

Actor

An actor of the specified name, either an existing instance or a newly-created actor.

Remarks

This method will create the actor within the current cast, if they do not already exist. Alternatively, this method will return the existing actor, if they already exist in the cast.

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

If you make use of a same-named actor across multiple performances then it is highly recommended to use personas in order to consistently define the actor's attributes and abilities. You would then use the overload of this method which uses that persona to define the actor.

See Also