pauldeen79.DialogFramework.Domain 0.1.3

dotnet add package pauldeen79.DialogFramework.Domain --version 0.1.3                
NuGet\Install-Package pauldeen79.DialogFramework.Domain -Version 0.1.3                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="pauldeen79.DialogFramework.Domain" Version="0.1.3" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add pauldeen79.DialogFramework.Domain --version 0.1.3                
#r "nuget: pauldeen79.DialogFramework.Domain, 0.1.3"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install pauldeen79.DialogFramework.Domain as a Cake Addin
#addin nuget:?package=pauldeen79.DialogFramework.Domain&version=0.1.3

// Install pauldeen79.DialogFramework.Domain as a Cake Tool
#tool nuget:?package=pauldeen79.DialogFramework.Domain&version=0.1.3                

DialogFramework

Framework for creating dialogs (conversations) between a target system and an actor (user or system)

Usage

The entry point for this framework is the DialogApplicationService. You need to have a DialogDefinition instance, and call the Start method on the DialogService with this Dialog instance as argument. This will return a Dialog. Then, you have to call Continue on the DialogApplicationService until the state of the Dialog is Completed. (which is whenever there is no next part, so the Completed part will be returned)

Besides the Continue method, you also have Abort method on the DialogApplicationService to abort the dialog, or the NavigateTo method to navigate to another dialog part.

Each method on the DialogApplicationService has a second method to check whether the method can be called in the current state. These methods begin with 'Can', for example CanStart and CanContinue.

Example

Here is some example C# code, which starts and finishes a two-step dialog:

using var provider = new ServiceCollection()
    .AddDialogFramework()
    .AddSingleton<IDialogDefinitionRepository, TestDialogDefinitionRepository>()
    .AddSingleton<ILogger, TestLogger>()
    .BuildServiceProvider();
var dialogDefinition = _provider.GetRequiredService<IDialogDefinitionRepository>().GetDialogDefinition(new DialogDefinitionIdentifier(nameof(SimpleFormFlowDialog), "1.0.0"))!;
var service = _provider.GetRequiredService<IDialogApplicationService>();

var dialog = sut.Start(dialogDefinition.Metadata).GetValueOrThrow("Start failed");
dialog = sut.Continue
(
    dialog,
    new DialogPartResultBuilder()
        .WithDialogPartId(new DialogPartIdentifierBuilder(dialog.CurrentPartId))
        .WithResultId(new DialogPartResultIdentifierBuilder().WithValue("EmailAddress"))
        .WithValue(new TextDialogPartResultValueBuilder().WithValue("email@address.com"))
        .Build(),
    new DialogPartResultBuilder()
        .WithDialogPartId(new DialogPartIdentifierBuilder(dialog.CurrentPartId))
        .WithResultId(new DialogPartResultIdentifierBuilder().WithValue("TelephoneNumber"))
        .WithValue(new TextDialogPartResultValueBuilder().WithValue("911"))
        .Build()
).GetValueOrThrow("ContactInfo failed"); // ContactInfo -> Newsletter
dialog = sut.Continue
(
    dialog,
    new DialogPartResultBuilder()
        .WithDialogPartId(new DialogPartIdentifierBuilder(dialog.CurrentPartId))
        .WithResultId(new DialogPartResultIdentifierBuilder().WithValue("SignUpForNewsletter"))
        .WithValue(new YesNoDialogPartResultValueBuilder().WithValue(false))
        .Build()
).GetValueOrThrow("Newsletter failed"); // Newsletter -> Completed

See unit tests for more examples.

Getting local environment up and running

To build the solution on your development machine, you first need to build and run the CodeGeneration project. This is because I have decided not to commit generated code to the Git repository.

To do this, simply set the CodeGeneration project as start up project in Visual Studio, and hit F5. Or, alternatively, use dotnet from the command line to build and run it. Be sure to run it from the root directory, where the solution file resides. e.g. dotnet build src/CodeGeneration/CodeGeneration.csproj dotnet src/CodeGeneration/bin/Debug/net6.0/CodeGeneration.dll

Project structure

The solution consists of the following projects:

  • DialogFramework.Abstractions: Interfaces used in code generation
  • CodeGeneration: Code generation for domain entity models and builders
  • DialogFramework.Domain: Domain entities and builders
  • DialogFramework.Application: Application logic

TODOs

  • Allow interception from outside the dialog and dialogparts, through the AfterNavigate and BeforeNavigate methods
  • Try to move interfaces from Abstractions to CodeGeneration, and remove references to Abstractions project. Use Domain implementations in signatures instead (inclusing enums, which need to be generated from Abstractions/CodeGeneration).
  • Create a minimal web api as a demo project, using some sort of state store (local in-memory cache?) for persisting state.
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on pauldeen79.DialogFramework.Domain:

Package Downloads
pauldeen79.DialogFramework.Application

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.1.3 100 10/30/2024
0.1.2 159 9/21/2024
0.1.1 149 9/11/2024
0.1.0 316 8/19/2022