Class BotBrainViewModel
The view model for a bot brain.
Inheritance
Implements
Inherited Members
Namespace: Phoenix.BotBrain
Assembly: Phoenix.Plugin.BotBrain.BrainEditor.dll
Syntax
public class BotBrainViewModel : BotViewModelBase, IBotBrainViewModel, IBotViewModelWithBrain, IBotViewModel, INotifyPropertyChanged, IOnSelected, IDisposable
Constructors
View SourceBotBrainViewModel(IServiceProvider, BotBrainLogForwarder?, Transient<BrainLogViewModel>?)
Initializes a new instance of the BotBrainViewModel class.
Declaration
public BotBrainViewModel(IServiceProvider services, BotBrainLogForwarder? logForwarder = null, Transient<BrainLogViewModel>? logViewModel = null)
Parameters
Type | Name | Description |
---|---|---|
IServiceProvider | services | The service provider. |
BotBrainLogForwarder | logForwarder | A log event forwarder. |
Transient<BrainLogViewModel> | logViewModel | The log view model. |
Properties
View SourceAllConsiderations
Gets the set of all possible considerations.
Declaration
protected virtual IEnumerable<ConsiderationInfo> AllConsiderations { get; }
Property Value
Type | Description |
---|---|
IEnumerable<ConsiderationInfo> |
AllListViewChoices
Gets all possible titles for the list view, if the bot has many component types, such as actions, urges, and/or considerations.
Declaration
public override IEnumerable<string> AllListViewChoices { get; }
Property Value
Type | Description |
---|---|
IEnumerable<string> |
Overrides
View SourceAllUrges
Gets the set of all possible urges.
Declaration
protected virtual IEnumerable<UrgeInfo> AllUrges { get; }
Property Value
Type | Description |
---|---|
IEnumerable<UrgeInfo> |
BotBrainTelemetryClient
Gets the bot brain telemetry client.
Declaration
protected IBotBrainTelemetryClient? BotBrainTelemetryClient { get; }
Property Value
Type | Description |
---|---|
IBotBrainTelemetryClient |
Bots
Gets the bots controlled by this brain.
Declaration
public ObservableCollection<IBotBrainClient> Bots { get; }
Property Value
Type | Description |
---|---|
ObservableCollection<IBotBrainClient> |
Brain
Gets or sets the brain.
Declaration
public virtual IBotBrain? Brain { get; set; }
Property Value
Type | Description |
---|---|
IBotBrain |
CanStart
Gets a value indicating whether or not the brain can start the selected devices.
Declaration
public override bool CanStart { get; }
Property Value
Type | Description |
---|---|
bool |
Overrides
View SourceCanStop
Gets a value indicating whether or not the brain can stop the selected devices.
Declaration
public override bool CanStop { get; }
Property Value
Type | Description |
---|---|
bool |
Overrides
View SourceConsiderations
Gets the considerations.
Declaration
public ListViewModel<IConsiderationViewModel> Considerations { get; }
Property Value
Type | Description |
---|---|
ListViewModel<IConsiderationViewModel> |
DetailsTitle
Gets the title of the primary view for controlling this bot.
Declaration
public override string DetailsTitle { get; }
Property Value
Type | Description |
---|---|
string |
Overrides
View SourceIsRunning
Gets a value indicating whether or not the bot is running.
Declaration
public override bool IsRunning { get; }
Property Value
Type | Description |
---|---|
bool |
Overrides
View SourceListDetailsTitle
Gets the title for presenting details about the selected list view item.
Declaration
public override string ListDetailsTitle { get; }
Property Value
Type | Description |
---|---|
string |
Overrides
View SourceLogViewModel
Gets the brain log view model.
Declaration
public BrainLogViewModel LogViewModel { get; }
Property Value
Type | Description |
---|---|
BrainLogViewModel |
Status
Gets the brain status.
Declaration
public override string Status { get; }
Property Value
Type | Description |
---|---|
string |
Overrides
View SourceTelemetryClient
Gets the telemetry client.
Declaration
protected override ITelemetryClient? TelemetryClient { get; }
Property Value
Type | Description |
---|---|
ITelemetryClient |
Overrides
View SourceUrges
Gets the urges.
Declaration
public ListViewModel<IUrgeViewModel> Urges { get; }
Property Value
Type | Description |
---|---|
ListViewModel<IUrgeViewModel> |
Methods
View SourceCanCreateBot(IDevice)
Determines whether or not a bot can be created for a device.
Declaration
protected virtual bool CanCreateBot(IDevice device)
Parameters
Type | Name | Description |
---|---|---|
IDevice | device | The device. |
Returns
Type | Description |
---|---|
bool | True if a bot can be created. |
CanCreateConsideration(ConsiderationInfo?)
Determines if the given consideration can be added to the brain.
Declaration
protected virtual bool CanCreateConsideration(ConsiderationInfo? info)
Parameters
Type | Name | Description |
---|---|---|
ConsiderationInfo | info | The consideration info. |
Returns
Type | Description |
---|---|
bool | True if the consideration can be added. |
CanCreateUrge(UrgeInfo?)
Determines if the given urge can be added to the brain.
Declaration
protected virtual bool CanCreateUrge(UrgeInfo? info)
Parameters
Type | Name | Description |
---|---|---|
UrgeInfo | info | The urge info. |
Returns
Type | Description |
---|---|
bool | True if the urge can be added. |
CreateBot(IDevice)
Creates a bot for a device.
Declaration
protected virtual IBotBrainClient CreateBot(IDevice device)
Parameters
Type | Name | Description |
---|---|---|
IDevice | device | The device. |
Returns
Type | Description |
---|---|
IBotBrainClient | The bot. |
CreateConsideration(object?)
Creates a consideration.
Declaration
public IConsideration? CreateConsideration(object? i)
Parameters
Type | Name | Description |
---|---|---|
object | i | The consideration info. |
Returns
Type | Description |
---|---|
IConsideration | The consideration. |
CreateConsiderationViewModel(IConsideration)
Creates a consideration view model.
Declaration
public IConsiderationViewModel? CreateConsiderationViewModel(IConsideration consideration)
Parameters
Type | Name | Description |
---|---|---|
IConsideration | consideration | The consideration. |
Returns
Type | Description |
---|---|
IConsiderationViewModel | The consideration view model. |
CreateUrge(object?)
Creates an urge.
Declaration
public IUrge? CreateUrge(object? i)
Parameters
Type | Name | Description |
---|---|---|
object | i | The urge info. |
Returns
Type | Description |
---|---|
IUrge | The urge. |
CreateUrgeViewModel(IUrge)
Creates an urge view model.
Declaration
public IUrgeViewModel? CreateUrgeViewModel(IUrge urge)
Parameters
Type | Name | Description |
---|---|---|
IUrge | urge | The urge. |
Returns
Type | Description |
---|---|
IUrgeViewModel | The urge view model. |
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Declaration
public virtual void Dispose()
GetBot(IDevice)
Gets the bot for a device.
Declaration
public IBotBrainClient? GetBot(IDevice device)
Parameters
Type | Name | Description |
---|---|---|
IDevice | device | The device. |
Returns
Type | Description |
---|---|
IBotBrainClient | The bot. |
IsRunningOn(IDevice)
Gets a value indicating whether or not the bot is running on the device.
Declaration
public override bool IsRunningOn(IDevice device)
Parameters
Type | Name | Description |
---|---|---|
IDevice | device | The device. |
Returns
Type | Description |
---|---|
bool | True if it is running on the device. |
Overrides
View SourceLoad(string)
Loads a serialized representation of a bot.
Declaration
public override void Load(string data)
Parameters
Type | Name | Description |
---|---|---|
string | data | The data to load. |
Overrides
View SourceOnCanExecuteChanged()
Handles UI updates when the bot's status changes.
Declaration
public override void OnCanExecuteChanged()
Overrides
View SourceOnSelected(object?)
Occurs when the item is selected.
Declaration
public override void OnSelected(object? sender)
Parameters
Type | Name | Description |
---|---|---|
object | sender | The sender. |
Overrides
View SourceRefreshConsiderations()
Updates the consideration view models.
Declaration
protected virtual void RefreshConsiderations()
RefreshUrges()
Updates the urge view models.
Declaration
protected virtual void RefreshUrges()
ReinitializeBrain()
Re-initializes the bot brain based on the UI choices.
Declaration
protected void ReinitializeBrain()
SaveToString()
Saves the bot brain to a string.
Declaration
protected override string SaveToString()
Returns
Type | Description |
---|---|
string | A string. |
Overrides
View SourceStartAsync()
Starts the bot.
Declaration
public override Task StartAsync()
Returns
Type | Description |
---|---|
Task | A task. |
Overrides
View SourceStop(IEnumerable<IDevice>)
Stops the brain on the given devices.
Declaration
public Task Stop(IEnumerable<IDevice> devices)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<IDevice> | devices | The devices. |
Returns
Type | Description |
---|---|
Task | A task. |
StopAll()
Stops the brain on all devices.
Declaration
public void StopAll()
StopAsync()
Stops the bot.
Declaration
public override Task StopAsync()
Returns
Type | Description |
---|---|
Task | A task. |