Show / Hide Table of Contents

Class RoleBasedScenario

A role-based scenario.

Inheritance
object
ScenarioBase
RoleBasedScenario
Implements
IMetadataAccess
IDisposable
IRoleBasedScenario
IScenario
IEquatable<IScenario>
IBasedOn<IScenario>
IBasedOn
Inherited Members
ScenarioBase.NoScenarioName
ScenarioBase.Name
ScenarioBase.Type
ScenarioBase.BasedOn
ScenarioBase.IsConcurrent
ScenarioBase.BasedOnObject
ScenarioBase.ParameterNames
ScenarioBase.GetParameterMetadata(string)
ScenarioBase.Equals(object)
ScenarioBase.GetHashCode()
ScenarioBase.ToString()
ScenarioBase.CreateMetadata()
object.Equals(object, object)
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
Namespace: Microsoft.XboxStudios.BotBrain.Overmind
Assembly: BotBrain.Overmind.dll
Syntax
public class RoleBasedScenario : ScenarioBase, IMetadataAccess, IDisposable, IRoleBasedScenario, IScenario, IEquatable<IScenario?>, IBasedOn<IScenario>, IBasedOn
Remarks

Initializes a new instance of the RoleBasedScenario class.

Constructors

View Source

RoleBasedScenario(string?, IReadOnlyCollection<IRole>?, string?, bool?, IReadOnlyCollection<IRequirement>?)

A role-based scenario.

Declaration
public RoleBasedScenario(string? name = null, IReadOnlyCollection<IRole>? roles = null, string? basedOn = null, bool? isConcurrent = null, IReadOnlyCollection<IRequirement>? stopAfter = null)
Parameters
Type Name Description
string name

The scenario name.

IReadOnlyCollection<IRole> roles

The collection of roles.

string basedOn

The name of the template to base the role on.

bool? isConcurrent

Whether or not to run the scenario concurrently.

IReadOnlyCollection<IRequirement> stopAfter

A collection of stop conditions.

Remarks

Initializes a new instance of the RoleBasedScenario class.

Properties

View Source

AssignedDevices

Gets an enumeration of devices assigned to this scenario.

Declaration
public override IEnumerable<IDevice> AssignedDevices { get; }
Property Value
Type Description
IEnumerable<IDevice>
Overrides
ScenarioBase.AssignedDevices
View Source

AssignedRoles

Gets a mapping from device to its assigned role.

Declaration
[JsonIgnore]
public IDictionary<IDevice, IRole> AssignedRoles { get; }
Property Value
Type Description
IDictionary<IDevice, IRole>
View Source

NumDevicesAssigned

Gets a value indicating how many devices this scenario has assigned.

Declaration
public override int NumDevicesAssigned { get; }
Property Value
Type Description
int
Overrides
ScenarioBase.NumDevicesAssigned
View Source

NumDevicesRequired

Gets a value indicating how many devices this scenario requires.

Declaration
public override int NumDevicesRequired { get; }
Property Value
Type Description
int
Overrides
ScenarioBase.NumDevicesRequired
View Source

Roles

Gets the roles.

Declaration
[JsonProperty(ObjectCreationHandling = ObjectCreationHandling.Replace)]
public IReadOnlyCollection<IRole> Roles { get; set; }
Property Value
Type Description
IReadOnlyCollection<IRole>
Remarks

Public setter must be exposed for JSON template deserialization.

View Source

Status

Gets a value indicating whether this scenario is queued, started or finished.

Declaration
public override ScenarioStatus Status { get; }
Property Value
Type Description
ScenarioStatus
Overrides
ScenarioBase.Status
View Source

StopAfter

Gets the collection of requirements indicating when to stop the scenario.

Declaration
[JsonProperty(ObjectCreationHandling = ObjectCreationHandling.Replace)]
public IReadOnlyCollection<IRequirement> StopAfter { get; set; }
Property Value
Type Description
IReadOnlyCollection<IRequirement>
Remarks

Public setter must be exposed for JSON template deserialization.

Methods

View Source

AddRequirement(IRequirement)

Adds a requirement to the collection indicating when to stop the scenario.

Declaration
public void AddRequirement(IRequirement requirement)
Parameters
Type Name Description
IRequirement requirement

The requirement.

View Source

AddRole(IRole)

Adds a role to the collection.

Declaration
public void AddRole(IRole role)
Parameters
Type Name Description
IRole role

The role.

View Source

ClearRequirements()

Clears the requirements.

Declaration
public void ClearRequirements()
View Source

CountActiveRoles(IRole)

Counts how many devices are actively assigned to a role.

Declaration
public int CountActiveRoles(IRole role)
Parameters
Type Name Description
IRole role

The role.

Returns
Type Description
int

The number of devices.

View Source

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

Declaration
public void Dispose()
View Source

Equals(IScenario?)

Indicates whether the current object is equal to another object of the same type.

Declaration
public override bool Equals(IScenario? other)
Parameters
Type Name Description
IScenario other

An object to compare with this object.

Returns
Type Description
bool

true if the current object is equal to the other parameter; otherwise, false.

Overrides
ScenarioBase.Equals(IScenario?)
View Source

FlagFailedIfUnfinished(OvermindState)

Checks the scenario to see if it finished, and if not then flag it as failed.

Declaration
public override void FlagFailedIfUnfinished(OvermindState state)
Parameters
Type Name Description
OvermindState state

The overmind state.

Overrides
ScenarioBase.FlagFailedIfUnfinished(OvermindState)
View Source

OnStarted(OvermindState)

Called when the scenario starts.

Declaration
protected virtual void OnStarted(OvermindState state)
Parameters
Type Name Description
OvermindState state

The overmind state.

View Source

OnStopped(OvermindState)

Called when the scenario stops.

Declaration
protected virtual void OnStopped(OvermindState state)
Parameters
Type Name Description
OvermindState state

The overmind state.

View Source

RemoveRequirement(IRequirement)

Removes a requirement from the collection indicating when to stop the scenario.

Declaration
public void RemoveRequirement(IRequirement requirement)
Parameters
Type Name Description
IRequirement requirement

The requirement.

View Source

RemoveRole(IRole)

Removes a role from the collection.

Declaration
public void RemoveRole(IRole role)
Parameters
Type Name Description
IRole role

The role.

View Source

TryAssignAsync(OvermindState, DeviceState)

Tries to assign a device to the scenario.

Declaration
public Task<bool> TryAssignAsync(OvermindState state, DeviceState subbot)
Parameters
Type Name Description
OvermindState state

The overmind state.

DeviceState subbot

The overmind device bot.

Returns
Type Description
Task<bool>

A Task representing the asynchronous operation.

View Source

Unassign(OvermindState, IDevice)

Removes a device from the scenario.

Declaration
public virtual void Unassign(OvermindState state, IDevice device)
Parameters
Type Name Description
OvermindState state

The overmind state.

IDevice device

The overmind device.

View Source

Update(OvermindState)

Called to update the scenario based on the overmind state.

Declaration
public override void Update(OvermindState state)
Parameters
Type Name Description
OvermindState state

The overmind state.

Overrides
ScenarioBase.Update(OvermindState)

Implements

IMetadataAccess
IDisposable
IRoleBasedScenario
IScenario
IEquatable<T>
IBasedOn<T>
IBasedOn

Extension Methods

IScenarioExtensions.HasEnoughDevices(IScenario)
IScenarioExtensions.IsActive(IScenario)
IScenarioExtensions.IsFinished(IScenario)
  • View Source
In this article
Back to top Generated by DocFX