Table of Contents

Class TempState

Namespace
Microsoft.Agents.Builder.State
Assembly
Microsoft.Agents.Builder.dll
public class TempState : IAgentState
Inheritance
TempState
Implements
Inherited Members

Constructors

TempState()

public TempState()

Fields

InputFilesKey

Name of the input files key

public const string InputFilesKey = "inputFiles"

Field Value

string

ScopeName

public static readonly string ScopeName

Field Value

string

Properties

AuthTokens

All tokens acquired after sign-in for current activity

[Obsolete("Use AgentApplication.Authorization.GetToken(handleName)")]
public Dictionary<string, string> AuthTokens { get; set; }

Property Value

Dictionary<string, string>

InputFiles

Downloaded files included in the Activity

public IList<InputFile> InputFiles { get; set; }

Property Value

IList<InputFile>

Name

The scope name of the state.

public string Name { get; }

Property Value

string

Methods

ClearState()

Clears the state.

public void ClearState()

Remarks

This method clears the state cache. Call SaveChangesAsync(ITurnContext, bool, CancellationToken) to persist this change in the storage layer.

DeleteStateAsync(ITurnContext, CancellationToken)

Deletes state in storage.

public Task DeleteStateAsync(ITurnContext turnContext, CancellationToken cancellationToken = default)

Parameters

turnContext ITurnContext

The context object for this turn.

cancellationToken CancellationToken

A cancellation token that can be used by other objects or threads to receive notice of cancellation.

Returns

Task

A task that represents the work queued to execute.

Exceptions

ArgumentNullException

turnContext is null.

DeleteValue(string)

Delete a property.

public void DeleteValue(string name)

Parameters

name string

The name of the property.

GetValue<T>()

public T GetValue<T>()

Returns

T

Type Parameters

T

GetValue<T>(string, Func<T>)

Get a property value.

public T GetValue<T>(string name, Func<T> defaultValueFactory = null)

Parameters

name string

The name of the property.

defaultValueFactory Func<T>

Defines the default value. Invoked when no value been set for the requested state property. If defaultValueFactory is defined as null in that case, the method returns null.

Returns

T

Type Parameters

T

HasValue(string)

Checks for the existence of a property.

public bool HasValue(string name)

Parameters

name string

The name of the property.

Returns

bool

IsLoaded()

True if state has been loaded.

public bool IsLoaded()

Returns

bool

LoadAsync(ITurnContext, bool, CancellationToken)

Populates state from the storage layer.

public Task LoadAsync(ITurnContext turnContext, bool force = false, CancellationToken cancellationToken = default)

Parameters

turnContext ITurnContext

The context object for this turn.

force bool

Optional, true to overwrite any existing state cache; or false to load state from storage only if the cache doesn't already exist.

cancellationToken CancellationToken

A cancellation token that can be used by other objects or threads to receive notice of cancellation.

Returns

Task

A task that represents the work queued to execute.

Remarks

LoadAsync loads State for the specified turn.

Exceptions

ArgumentNullException

turnContext is null.

SaveChangesAsync(ITurnContext, bool, CancellationToken)

Writes state to the storage layer.

public Task SaveChangesAsync(ITurnContext turnContext, bool force = false, CancellationToken cancellationToken = default)

Parameters

turnContext ITurnContext

The context object for this turn.

force bool

Optional, true to save the state cache to storage; or false to save state to storage only if a property in the cache has changed.

cancellationToken CancellationToken

A cancellation token that can be used by other objects or threads to receive notice of cancellation.

Returns

Task

A task that represents the work queued to execute.

Exceptions

ArgumentNullException

turnContext is null.

SetValue<T>(string, T)

Set a property value.

public void SetValue<T>(string name, T value)

Parameters

name string

The name of the property.

value T

The property value.

Type Parameters

T

SetValue<T>(T)

public void SetValue<T>(T value)

Parameters

value T

Type Parameters

T