Change $type to $kind and move unit tests to declarative (#2994)

* Change $type to $kind DCR #3010
* Add Json annotations to all properties
* Add declarative form of TestFlow (TestScript) which allows us to convert TestFlow unit tests to * declarative .test.dialog files
* Replace TestFlow() unit tests with .test.dialog declarative tests
This commit is contained in:
Tom Laird-McConnell 2019-11-23 08:03:37 -08:00 коммит произвёл GitHub
Родитель b4016333f3
Коммит 2db0f38cf7
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
354 изменённых файлов: 12801 добавлений и 5601 удалений

Просмотреть файл

@ -13,6 +13,7 @@ using Microsoft.Bot.Builder.TraceExtensions;
using Microsoft.Bot.Configuration;
using Microsoft.Bot.Schema;
using Microsoft.Rest;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace Microsoft.Bot.Builder.AI.Luis
@ -23,6 +24,9 @@ namespace Microsoft.Bot.Builder.AI.Luis
/// </summary>
public class LuisRecognizer : ITelemetryRecognizer
{
[JsonProperty("$kind")]
public const string DeclarativeType = "Microsoft.LuisRecognizer";
/// <summary>
/// The value type for a LUIS trace activity.
/// </summary>
@ -120,6 +124,7 @@ namespace Microsoft.Bot.Builder.AI.Luis
/// Gets the currently configured <see cref="IBotTelemetryClient"/> that logs the LuisResult event.
/// </summary>
/// <value>The <see cref="IBotTelemetryClient"/> being used to log events.</value>
[JsonIgnore]
public IBotTelemetryClient TelemetryClient { get; }
/// <summary>

Просмотреть файл

@ -80,6 +80,7 @@ namespace Microsoft.Bot.Builder.AI.LuisV3
/// Gets the currently configured <see cref="IBotTelemetryClient"/> that logs the LuisResult event.
/// </summary>
/// <value>The <see cref="IBotTelemetryClient"/> being used to log events.</value>
[JsonIgnore]
public IBotTelemetryClient TelemetryClient { get; }
/// <summary>

Просмотреть файл

@ -127,6 +127,7 @@ namespace Microsoft.Bot.Builder.AI.QnA
/// Gets the currently configured <see cref="IBotTelemetryClient"/> that logs the QnaMessage event.
/// </summary>
/// <value>The <see cref="IBotTelemetryClient"/> being used to log events.</value>
[JsonIgnore]
public IBotTelemetryClient TelemetryClient { get; }
/// <summary>

Просмотреть файл

@ -1,11 +1,15 @@
// Licensed under the MIT License.
// Copyright (c) Microsoft Corporation. All rights reserved.
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
namespace Microsoft.Bot.Builder.Dialogs.Adaptive
{
/// <summary>
/// How to modify an action sequence.
/// </summary>
[JsonConverter(typeof(StringEnumConverter))]
public enum ActionChangeType
{
/// <summary>

Просмотреть файл

@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using Microsoft.Bot.Expressions;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
@ -33,6 +34,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
/// <value>
/// Configurable options for the dialog.
/// </value>
[JsonProperty("options")]
public object Options { get; set; } = new JObject();
/// <summary>
@ -41,6 +43,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
/// <value>
/// The dialog to call.
/// </value>
[JsonProperty("dialog")]
public Dialog Dialog { get; set; }
public virtual IEnumerable<Dialog> GetDependencies()

Просмотреть файл

@ -15,6 +15,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
/// </summary>
public class BeginDialog : BaseInvokeDialog
{
[JsonProperty("$kind")]
public const string DeclarativeType = "Microsoft.BeginDialog";
[JsonConstructor]
public BeginDialog(string dialogIdToCall = null, IDictionary<string, string> options = null, [CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLine = 0)
: base(dialogIdToCall, options)
@ -28,6 +31,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
/// <value>
/// The property path to store the dialog result in.
/// </value>
[JsonProperty("resultProperty")]
public string ResultProperty { get; set; }
public override async Task<DialogTurnResult> BeginDialogAsync(DialogContext dc, object options = null, CancellationToken cancellationToken = default(CancellationToken))

Просмотреть файл

@ -15,6 +15,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
/// </summary>
public class CancelAllDialogs : Dialog
{
[JsonProperty("$kind")]
public const string DeclarativeType = "Microsoft.CancelAllDialogs";
[JsonConstructor]
public CancelAllDialogs([CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLine = 0)
: base()
@ -28,6 +31,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
/// <value>
/// Event name.
/// </value>
[JsonProperty("eventName")]
public string EventName { get; set; }
/// <summary>
@ -36,6 +40,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
/// <value>
/// Value expression for EventValue.
/// </value>
[JsonProperty("eventValue")]
public string EventValue { get; set; }
public override async Task<DialogTurnResult> BeginDialogAsync(DialogContext dc, object options = null, CancellationToken cancellationToken = default(CancellationToken))

Просмотреть файл

@ -8,11 +8,15 @@ using System.Linq;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
using Newtonsoft.Json;
namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
{
public class DebugBreak : Dialog
{
[JsonProperty("$kind")]
public const string DeclarativeType = "Microsoft.DebugBreak";
public DebugBreak([CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLine = 0)
{
this.RegisterSourceLocation(callerPath, callerLine);

Просмотреть файл

@ -14,6 +14,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
/// </summary>
public class DeleteProperty : Dialog
{
[JsonProperty("$kind")]
public const string DeclarativeType = "Microsoft.DeleteProperty";
[JsonConstructor]
public DeleteProperty([CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLine = 0)
: base()
@ -40,6 +43,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
/// <value>
/// Property path to remove.
/// </value>
[JsonProperty("property")]
public string Property { get; set; }
public override async Task<DialogTurnResult> BeginDialogAsync(DialogContext dc, object options = null, CancellationToken cancellationToken = default(CancellationToken))

Просмотреть файл

@ -16,6 +16,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
/// </summary>
public class EditActions : Dialog, IDialogDependencies
{
[JsonProperty("$kind")]
public const string DeclarativeType = "Microsoft.EditActions";
/// <summary>
/// Initializes a new instance of the <see cref="EditActions"/> class.
/// </summary>

Просмотреть файл

@ -18,6 +18,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
/// </summary>
public class EditArray : Dialog
{
[JsonProperty("$kind")]
public const string DeclarativeType = "Microsoft.EditArray";
private Expression value;
private Expression itemsProperty;
private Expression resultProperty;
@ -60,6 +63,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
this.RegisterSourceLocation(callerPath, callerLine);
}
[JsonConverter(typeof(StringEnumConverter))]
public enum ArrayChangeType
{
/// <summary>
@ -94,7 +98,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
/// <value>
/// Type of change being applied.
/// </value>
[JsonConverter(typeof(StringEnumConverter))]
[JsonProperty("changeType")]
public ArrayChangeType ChangeType { get; set; }

Просмотреть файл

@ -15,6 +15,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
/// </summary>
public class EmitEvent : Dialog
{
[JsonProperty("$kind")]
public const string DeclarativeType = "Microsoft.EmitEvent";
private Expression eventValue;
[JsonConstructor]
@ -33,6 +36,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
/// <value>
/// The name of the event to emit.
/// </value>
[JsonProperty("eventName")]
public string EventName { get; set; }
/// <summary>
@ -41,6 +45,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
/// <value>
/// The memory property path to use to get the value to send as part of the event.
/// </value>
[JsonProperty("eventValue")]
public string EventValue
{
get { return eventValue?.ToString(); }
@ -53,6 +58,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
/// <value>
/// A value indicating whether gets or sets whether the event should bubble or not.
/// </value>
[JsonProperty("bubbleEvent")]
public bool BubbleEvent { get; set; }
public override async Task<DialogTurnResult> BeginDialogAsync(DialogContext dc, object options = null, CancellationToken cancellationToken = default(CancellationToken))

Просмотреть файл

@ -15,6 +15,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
/// </summary>
public class EndDialog : Dialog
{
[JsonProperty("$kind")]
public const string DeclarativeType = "Microsoft.EndDialog";
private Expression value;
[JsonConstructor]

Просмотреть файл

@ -14,6 +14,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
/// </summary>
public class EndTurn : Dialog
{
[JsonProperty("$kind")]
public const string DeclarativeType = "Microsoft.EndTurn";
[JsonConstructor]
public EndTurn([CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLine = 0)
: base()

Просмотреть файл

@ -17,6 +17,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
/// </summary>
public class Foreach : Dialog, IDialogDependencies
{
[JsonProperty("$kind")]
public const string DeclarativeType = "Microsoft.Foreach";
private const string INDEX = "dialog.foreach.index";
private const string VALUE = "dialog.foreach.value";

Просмотреть файл

@ -18,6 +18,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
/// </summary>
public class ForeachPage : Dialog, IDialogDependencies
{
[JsonProperty("$kind")]
public const string DeclarativeType = "Microsoft.ForeachPage";
private const string ForEachPage = "dialog.foreach.page";
[JsonConstructor]

Просмотреть файл

@ -25,6 +25,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
/// </summary>
public class HttpRequest : Dialog
{
[JsonProperty("$kind")]
public const string DeclarativeType = "Microsoft.HttpRequest";
private static readonly HttpClient Client = new HttpClient();
public HttpRequest(HttpMethod method, string url, string inputProperty, Dictionary<string, string> headers = null, JObject body = null, [CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLine = 0)
@ -125,6 +128,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
/// <value>
/// The property expression to store the HTTP response in.
/// </value>
[JsonProperty("resultProperty")]
public string ResultProperty { get; set; }
public override async Task<DialogTurnResult> BeginDialogAsync(DialogContext dc, object options = null, CancellationToken cancellationToken = default(CancellationToken))

Просмотреть файл

@ -17,6 +17,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
/// </summary>
public class IfCondition : Dialog, IDialogDependencies
{
[JsonProperty("$kind")]
public const string DeclarativeType = "Microsoft.IfCondition";
private Expression condition;
[JsonConstructor]

Просмотреть файл

@ -15,6 +15,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
/// </summary>
public class InitProperty : Dialog
{
[JsonProperty("$kind")]
public const string DeclarativeType = "Microsoft.InitProperty";
[JsonConstructor]
public InitProperty([CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLine = 0)
: base()
@ -28,6 +31,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
/// <value>
/// Property path to initialize.
/// </value>
[JsonProperty("property")]
public string Property { get; set; }
/// <summary>
@ -36,6 +40,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
/// <value>
/// Type, either Array or Object.
/// </value>
[JsonProperty("type")]
public string Type { get; set; }
public override async Task<DialogTurnResult> BeginDialogAsync(DialogContext dc, object options = null, CancellationToken cancellationToken = default(CancellationToken))

Просмотреть файл

@ -15,6 +15,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
/// </summary>
public class LogAction : Dialog
{
[JsonProperty("$kind")]
public const string DeclarativeType = "Microsoft.LogAction";
[JsonConstructor]
public LogAction(string text = null, [CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLine = 0)
{

Просмотреть файл

@ -12,6 +12,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
{
public class RepeatDialog : Dialog
{
[JsonProperty("$kind")]
public const string DeclarativeType = "Microsoft.RepeatDialog";
[JsonConstructor]
public RepeatDialog([CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLine = 0)
: base()

Просмотреть файл

@ -15,6 +15,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
/// </summary>
public class ReplaceDialog : BaseInvokeDialog
{
[JsonProperty("$kind")]
public const string DeclarativeType = "Microsoft.ReplaceDialog";
[JsonConstructor]
public ReplaceDialog(string dialogIdToCall = null, IDictionary<string, string> options = null, [CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLine = 0)
: base(dialogIdToCall, options)

Просмотреть файл

@ -16,6 +16,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
/// </summary>
public class SendActivity : Dialog
{
[JsonProperty("$kind")]
public const string DeclarativeType = "Microsoft.SendActivity";
public SendActivity(Activity activity, [CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLine = 0)
{
this.RegisterSourceLocation(callerPath, callerLine);
@ -35,6 +38,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
/// <value>
/// Template for the activity.
/// </value>
[JsonProperty("activity")]
public ITemplate<Activity> Activity { get; set; }
public override async Task<DialogTurnResult> BeginDialogAsync(DialogContext dc, object options = null, CancellationToken cancellationToken = default(CancellationToken))

Просмотреть файл

@ -15,6 +15,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
/// </summary>
public class SetProperty : Dialog
{
[JsonProperty("$kind")]
public const string DeclarativeType = "Microsoft.SetProperty";
private Expression value;
[JsonConstructor]

Просмотреть файл

@ -17,6 +17,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
/// </summary>
public class SwitchCondition : Dialog, IDialogDependencies
{
[JsonProperty("$kind")]
public const string DeclarativeType = "Microsoft.SwitchCondition";
private Dictionary<string, Expression> caseExpressions = null;
private Expression condition;
@ -47,6 +50,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
/// <value>
/// Default case.
/// </value>
[JsonProperty("default")]
public List<Dialog> Default { get; set; } = new List<Dialog>();
/// <summary>
@ -55,6 +59,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
/// <value>
/// Cases.
/// </value>
[JsonProperty("cases")]
public List<Case> Cases { get; set; } = new List<Case>();
public virtual IEnumerable<Dialog> GetDependencies()

Просмотреть файл

@ -16,6 +16,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
/// </summary>
public class TraceActivity : Dialog
{
[JsonProperty("$kind")]
public const string DeclarativeType = "Microsoft.TraceActivity";
[JsonConstructor]
public TraceActivity([CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLine = 0)
{
@ -28,6 +31,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
/// <value>
/// Name of the trace activity.
/// </value>
[JsonProperty("name")]
public string Name { get; set; }
/// <summary>
@ -36,6 +40,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
/// <value>
/// Value type of the trace activity.
/// </value>
[JsonProperty("valueType")]
public string ValueType { get; set; }
/// <summary>
@ -44,6 +49,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
/// <value>
/// Property binding to memory to send as the value.
/// </value>
[JsonProperty("value")]
public string Value { get; set; }
public override async Task<DialogTurnResult> BeginDialogAsync(DialogContext dc, object options = null, CancellationToken cancellationToken = default(CancellationToken))

Просмотреть файл

@ -13,6 +13,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive
{
public override bool CanRead => true;
// if this is false, don't custom serialize activitytemplate as a string
public override bool CanWrite => false;
public override bool CanConvert(Type objectType)
{
return typeof(ITemplate<Activity>) == objectType;
@ -28,14 +31,29 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive
}
else
{
var activity = JToken.Load(reader).ToObject<Activity>();
JObject obj = JObject.Load(reader);
string kind = (string)obj["$kind"] ?? (string)obj["$type"];
if (kind == "Microsoft.ActivityTemplate")
{
return obj.ToObject<ActivityTemplate>();
}
var activity = obj.ToObject<Activity>();
return new StaticActivityTemplate((Activity)activity);
}
}
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
// save template as string
if (value is ActivityTemplate activityTemplate)
{
serializer.Serialize(writer, activityTemplate.Template);
}
else
{
serializer.Serialize(writer, value);
}
}
}
}

Просмотреть файл

@ -6,8 +6,13 @@ using Microsoft.Bot.Builder.AI.Luis;
using Microsoft.Bot.Builder.AI.QnA;
using Microsoft.Bot.Builder.Dialogs.Adaptive.Actions;
using Microsoft.Bot.Builder.Dialogs.Adaptive.Conditions;
using Microsoft.Bot.Builder.Dialogs.Adaptive.Generators;
using Microsoft.Bot.Builder.Dialogs.Adaptive.Input;
using Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers;
using Microsoft.Bot.Builder.Dialogs.Adaptive.Selectors;
using Microsoft.Bot.Builder.Dialogs.Adaptive.Testing;
using Microsoft.Bot.Builder.Dialogs.Adaptive.Testing.Actions;
using Microsoft.Bot.Builder.Dialogs.Adaptive.Testing.TestActions;
using Microsoft.Bot.Builder.Dialogs.Debugging;
using Microsoft.Bot.Builder.Dialogs.Declarative;
using Microsoft.Bot.Builder.Dialogs.Declarative.Converters;
@ -23,99 +28,125 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive
public override IEnumerable<TypeRegistration> GetTypes()
{
// Conditionals
yield return new TypeRegistration<OnCondition>("Microsoft.OnCondition");
yield return new TypeRegistration<OnError>("Microsoft.OnError");
yield return new TypeRegistration<OnCondition>(OnCondition.DeclarativeType);
yield return new TypeRegistration<OnError>(OnError.DeclarativeType);
yield return new TypeRegistration<OnDialogEvent>("Microsoft.OnDialogEvent");
yield return new TypeRegistration<OnCustomEvent>("Microsoft.OnCustomEvent");
yield return new TypeRegistration<OnDialogEvent>(OnDialogEvent.DeclarativeType);
yield return new TypeRegistration<OnCustomEvent>(OnCustomEvent.DeclarativeType);
yield return new TypeRegistration<OnBeginDialog>("Microsoft.OnBeginDialog");
yield return new TypeRegistration<OnCancelDialog>("Microsoft.OnCancelDialog");
yield return new TypeRegistration<OnRepromptDialog>("Microsoft.OnRepromptDialog");
yield return new TypeRegistration<OnBeginDialog>(OnBeginDialog.DeclarativeType);
yield return new TypeRegistration<OnCancelDialog>(OnCancelDialog.DeclarativeType);
yield return new TypeRegistration<OnRepromptDialog>(OnRepromptDialog.DeclarativeType);
yield return new TypeRegistration<OnIntent>("Microsoft.OnIntent");
yield return new TypeRegistration<OnUnknownIntent>("Microsoft.OnUnknownIntent");
yield return new TypeRegistration<OnIntent>(OnIntent.DeclarativeType);
yield return new TypeRegistration<OnUnknownIntent>(OnUnknownIntent.DeclarativeType);
yield return new TypeRegistration<OnActivity>("Microsoft.OnActivity");
yield return new TypeRegistration<OnMessageActivity>("Microsoft.OnMessageActivity");
yield return new TypeRegistration<OnMessageUpdateActivity>("Microsoft.OnMessageUpdateActivity");
yield return new TypeRegistration<OnMessageDeleteActivity>("Microsoft.OnMessageDeleteActivity");
yield return new TypeRegistration<OnMessageReactionActivity>("Microsoft.OnMessageReactionActivity");
yield return new TypeRegistration<OnEventActivity>("Microsoft.OnEventActivity");
yield return new TypeRegistration<OnInvokeActivity>("Microsoft.OnInvokeActivity");
yield return new TypeRegistration<OnConversationUpdateActivity>("Microsoft.OnConversationUpdateActivity");
yield return new TypeRegistration<OnEndOfConversationActivity>("Microsoft.OnEndOfConversationActivity");
yield return new TypeRegistration<OnTypingActivity>("Microsoft.OnTypingActivity");
yield return new TypeRegistration<OnHandoffActivity>("Microsoft.OnHandoffActivity");
yield return new TypeRegistration<OnActivity>(OnActivity.DeclarativeType);
yield return new TypeRegistration<OnMessageActivity>(OnMessageActivity.DeclarativeType);
yield return new TypeRegistration<OnMessageUpdateActivity>(OnMessageUpdateActivity.DeclarativeType);
yield return new TypeRegistration<OnMessageDeleteActivity>(OnMessageDeleteActivity.DeclarativeType);
yield return new TypeRegistration<OnMessageReactionActivity>(OnMessageReactionActivity.DeclarativeType);
yield return new TypeRegistration<OnEventActivity>(OnEventActivity.DeclarativeType);
yield return new TypeRegistration<OnInvokeActivity>(OnInvokeActivity.DeclarativeType);
yield return new TypeRegistration<OnConversationUpdateActivity>(OnConversationUpdateActivity.DeclarativeType);
yield return new TypeRegistration<OnEndOfConversationActivity>(OnEndOfConversationActivity.DeclarativeType);
yield return new TypeRegistration<OnTypingActivity>(OnTypingActivity.DeclarativeType);
yield return new TypeRegistration<OnHandoffActivity>(OnHandoffActivity.DeclarativeType);
// Actions
yield return new TypeRegistration<BeginDialog>("Microsoft.BeginDialog");
yield return new TypeRegistration<CancelAllDialogs>("Microsoft.CancelAllDialogs");
yield return new TypeRegistration<DebugBreak>("Microsoft.DebugBreak");
yield return new TypeRegistration<DeleteProperty>("Microsoft.DeleteProperty");
yield return new TypeRegistration<EditArray>("Microsoft.EditArray");
yield return new TypeRegistration<EditActions>("Microsoft.EditActions");
yield return new TypeRegistration<EmitEvent>("Microsoft.EmitEvent");
yield return new TypeRegistration<EndDialog>("Microsoft.EndDialog");
yield return new TypeRegistration<EndTurn>("Microsoft.EndTurn");
yield return new TypeRegistration<Foreach>("Microsoft.Foreach");
yield return new TypeRegistration<ForeachPage>("Microsoft.ForeachPage");
yield return new TypeRegistration<HttpRequest>("Microsoft.HttpRequest");
yield return new TypeRegistration<IfCondition>("Microsoft.IfCondition");
yield return new TypeRegistration<InitProperty>("Microsoft.InitProperty");
yield return new TypeRegistration<LogAction>("Microsoft.LogAction");
yield return new TypeRegistration<RepeatDialog>("Microsoft.RepeatDialog");
yield return new TypeRegistration<ReplaceDialog>("Microsoft.ReplaceDialog");
yield return new TypeRegistration<SendActivity>("Microsoft.SendActivity");
yield return new TypeRegistration<SetProperty>("Microsoft.SetProperty");
yield return new TypeRegistration<SwitchCondition>("Microsoft.SwitchCondition");
yield return new TypeRegistration<TraceActivity>("Microsoft.TraceActivity");
yield return new TypeRegistration<BeginDialog>(BeginDialog.DeclarativeType);
yield return new TypeRegistration<CancelAllDialogs>(CancelAllDialogs.DeclarativeType);
yield return new TypeRegistration<DebugBreak>(DebugBreak.DeclarativeType);
yield return new TypeRegistration<DeleteProperty>(DeleteProperty.DeclarativeType);
yield return new TypeRegistration<EditArray>(EditArray.DeclarativeType);
yield return new TypeRegistration<EditActions>(EditActions.DeclarativeType);
yield return new TypeRegistration<EmitEvent>(EmitEvent.DeclarativeType);
yield return new TypeRegistration<EndDialog>(EndDialog.DeclarativeType);
yield return new TypeRegistration<EndTurn>(EndTurn.DeclarativeType);
yield return new TypeRegistration<Foreach>(Foreach.DeclarativeType);
yield return new TypeRegistration<ForeachPage>(ForeachPage.DeclarativeType);
yield return new TypeRegistration<HttpRequest>(HttpRequest.DeclarativeType);
yield return new TypeRegistration<IfCondition>(IfCondition.DeclarativeType);
yield return new TypeRegistration<InitProperty>(InitProperty.DeclarativeType);
yield return new TypeRegistration<LogAction>(LogAction.DeclarativeType);
yield return new TypeRegistration<RepeatDialog>(RepeatDialog.DeclarativeType);
yield return new TypeRegistration<ReplaceDialog>(ReplaceDialog.DeclarativeType);
yield return new TypeRegistration<SendActivity>(SendActivity.DeclarativeType);
yield return new TypeRegistration<SetProperty>(SetProperty.DeclarativeType);
yield return new TypeRegistration<SwitchCondition>(SwitchCondition.DeclarativeType);
yield return new TypeRegistration<TraceActivity>(TraceActivity.DeclarativeType);
// Inputs
yield return new TypeRegistration<AttachmentInput>("Microsoft.AttachmentInput");
yield return new TypeRegistration<ConfirmInput>("Microsoft.ConfirmInput");
yield return new TypeRegistration<NumberInput>("Microsoft.NumberInput");
yield return new TypeRegistration<TextInput>("Microsoft.TextInput");
yield return new TypeRegistration<ChoiceInput>("Microsoft.ChoiceInput");
yield return new TypeRegistration<DateTimeInput>("Microsoft.DateTimeInput");
yield return new TypeRegistration<OAuthInput>("Microsoft.OAuthInput");
yield return new TypeRegistration<AttachmentInput>(AttachmentInput.DeclarativeType);
yield return new TypeRegistration<ConfirmInput>(ConfirmInput.DeclarativeType);
yield return new TypeRegistration<NumberInput>(NumberInput.DeclarativeType);
yield return new TypeRegistration<TextInput>(TextInput.DeclarativeType);
yield return new TypeRegistration<ChoiceInput>(ChoiceInput.DeclarativeType);
yield return new TypeRegistration<DateTimeInput>(DateTimeInput.DeclarativeType);
yield return new TypeRegistration<OAuthInput>(OAuthInput.DeclarativeType);
// Recognizers
yield return new TypeRegistration<LuisRecognizer>("Microsoft.LuisRecognizer") { CustomDeserializer = new LuisRecognizerLoader(TypeFactory.Configuration) };
yield return new TypeRegistration<RegexRecognizer>("Microsoft.RegexRecognizer");
yield return new TypeRegistration<IntentPattern>("Microsoft.IntentPattern");
yield return new TypeRegistration<MultiLanguageRecognizer>("Microsoft.MultiLanguageRecognizer");
yield return new TypeRegistration<LuisRecognizer>(LuisRecognizer.DeclarativeType) { CustomDeserializer = new LuisRecognizerLoader(TypeFactory.Configuration) };
yield return new TypeRegistration<RegexRecognizer>(RegexRecognizer.DeclarativeType);
yield return new TypeRegistration<IntentPattern>(IntentPattern.DeclarativeType);
yield return new TypeRegistration<MultiLanguageRecognizer>(MultiLanguageRecognizer.DeclarativeType);
// Entity recognizers
yield return new TypeRegistration<AgeEntityRecognizer>("Microsoft.AgeEntityRecognizer");
yield return new TypeRegistration<ConfirmationEntityRecognizer>("Microsoft.ConfirmationEntityRecognizer");
yield return new TypeRegistration<CurrencyEntityRecognizer>("Microsoft.CurrencyEntityRecognizer");
yield return new TypeRegistration<DateTimeEntityRecognizer>("Microsoft.DateTimeEntityRecognizer");
yield return new TypeRegistration<DimensionEntityRecognizer>("Microsoft.DimensionEntityRecognizer");
yield return new TypeRegistration<EmailEntityRecognizer>("Microsoft.EmailEntityRecognizer");
yield return new TypeRegistration<EntityRecognizer>("Microsoft.EntityRecognizer");
yield return new TypeRegistration<EntityRecognizerSet>("Microsoft.EntityRecognizerSet");
yield return new TypeRegistration<GuidEntityRecognizer>("Microsoft.GuidEntityRecognizer");
yield return new TypeRegistration<HashtagEntityRecognizer>("Microsoft.HashtagEntityRecognizer");
yield return new TypeRegistration<IpEntityRecognizer>("Microsoft.IpEntityRecognizer");
yield return new TypeRegistration<MentionEntityRecognizer>("Microsoft.MentionEntityRecognizer");
yield return new TypeRegistration<NumberEntityRecognizer>("Microsoft.NumberEntityRecognizer");
yield return new TypeRegistration<NumberRangeEntityRecognizer>("Microsoft.NumberRangeEntityRecognizer");
yield return new TypeRegistration<OrdinalEntityRecognizer>("Microsoft.OrdinalEntityRecognizer");
yield return new TypeRegistration<PercentageEntityRecognizer>("Microsoft.PercentageEntityRecognizer");
yield return new TypeRegistration<PhoneNumberEntityRecognizer>("Microsoft.PhoneNumberEntityRecognizer");
yield return new TypeRegistration<TemperatureEntityRecognizer>("Microsoft.TemperatureEntityRecognizer");
yield return new TypeRegistration<UrlEntityRecognizer>("Microsoft.UrlEntityRecognizer");
yield return new TypeRegistration<AgeEntityRecognizer>(AgeEntityRecognizer.DeclarativeType);
yield return new TypeRegistration<ConfirmationEntityRecognizer>(ConfirmationEntityRecognizer.DeclarativeType);
yield return new TypeRegistration<CurrencyEntityRecognizer>(CurrencyEntityRecognizer.DeclarativeType);
yield return new TypeRegistration<DateTimeEntityRecognizer>(DateTimeEntityRecognizer.DeclarativeType);
yield return new TypeRegistration<DimensionEntityRecognizer>(DimensionEntityRecognizer.DeclarativeType);
yield return new TypeRegistration<EmailEntityRecognizer>(EmailEntityRecognizer.DeclarativeType);
yield return new TypeRegistration<EntityRecognizerSet>(EntityRecognizerSet.DeclarativeType);
yield return new TypeRegistration<GuidEntityRecognizer>(GuidEntityRecognizer.DeclarativeType);
yield return new TypeRegistration<HashtagEntityRecognizer>(HashtagEntityRecognizer.DeclarativeType);
yield return new TypeRegistration<IpEntityRecognizer>(IpEntityRecognizer.DeclarativeType);
yield return new TypeRegistration<MentionEntityRecognizer>(MentionEntityRecognizer.DeclarativeType);
yield return new TypeRegistration<NumberEntityRecognizer>(NumberEntityRecognizer.DeclarativeType);
yield return new TypeRegistration<NumberRangeEntityRecognizer>(NumberRangeEntityRecognizer.DeclarativeType);
yield return new TypeRegistration<OrdinalEntityRecognizer>(OrdinalEntityRecognizer.DeclarativeType);
yield return new TypeRegistration<PercentageEntityRecognizer>(PercentageEntityRecognizer.DeclarativeType);
yield return new TypeRegistration<PhoneNumberEntityRecognizer>(PhoneNumberEntityRecognizer.DeclarativeType);
yield return new TypeRegistration<TemperatureEntityRecognizer>(TemperatureEntityRecognizer.DeclarativeType);
yield return new TypeRegistration<UrlEntityRecognizer>(UrlEntityRecognizer.DeclarativeType);
// selectors
yield return new TypeRegistration<ConditionalSelector>(ConditionalSelector.DeclarativeType);
yield return new TypeRegistration<FirstSelector>(FirstSelector.DeclarativeType);
yield return new TypeRegistration<MostSpecificSelector>(MostSpecificSelector.DeclarativeType);
yield return new TypeRegistration<RandomSelector>(RandomSelector.DeclarativeType);
yield return new TypeRegistration<TrueSelector>(TrueSelector.DeclarativeType);
// Generators
yield return new TypeRegistration<ResourceMultiLanguageGenerator>(ResourceMultiLanguageGenerator.DeclarativeType);
yield return new TypeRegistration<MultiLanguageGenerator>(MultiLanguageGenerator.DeclarativeType);
yield return new TypeRegistration<TemplateEngineLanguageGenerator>(TemplateEngineLanguageGenerator.DeclarativeType);
// Dialogs
yield return new TypeRegistration<AdaptiveDialog>("Microsoft.AdaptiveDialog");
yield return new TypeRegistration<QnAMakerDialog>("Microsoft.QnAMakerDialog");
yield return new TypeRegistration<AdaptiveDialog>(AdaptiveDialog.DeclarativeType);
yield return new TypeRegistration<QnAMakerDialog>(QnAMakerDialog.DeclarativeType);
// Testing
yield return new TypeRegistration<TestScript>(TestScript.DeclarativeType);
yield return new TypeRegistration<UserSays>(UserSays.DeclarativeType);
yield return new TypeRegistration<UserTyping>(UserTyping.DeclarativeType);
yield return new TypeRegistration<UserConversationUpdate>(UserConversationUpdate.DeclarativeType);
yield return new TypeRegistration<UserActivity>(UserActivity.DeclarativeType);
yield return new TypeRegistration<UserDelay>(UserDelay.DeclarativeType);
yield return new TypeRegistration<AssertReply>(AssertReply.DeclarativeType);
yield return new TypeRegistration<AssertReplyOneOf>(AssertReplyOneOf.DeclarativeType);
yield return new TypeRegistration<AssertReplyActivity>(AssertReplyActivity.DeclarativeType);
}
public override IEnumerable<JsonConverter> GetConverters(ISourceMap sourceMap, IRefResolver refResolver, Stack<string> paths)
{
yield return new InterfaceConverter<OnCondition>(refResolver, sourceMap, paths);
yield return new InterfaceConverter<TestAction>(refResolver, sourceMap, paths);
yield return new InterfaceConverter<EntityRecognizer>(refResolver, sourceMap, paths);
yield return new InterfaceConverter<ITriggerSelector>(refResolver, sourceMap, paths);
yield return new ExpressionPropertyConverter<ChoiceSet>();
yield return new ActivityTemplateConverter();
}
}
}

Просмотреть файл

@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
@ -14,6 +15,7 @@ using Microsoft.Bot.Builder.Dialogs.Adaptive.Selectors;
using Microsoft.Bot.Builder.Dialogs.Debugging;
using Microsoft.Bot.Expressions;
using Microsoft.Bot.Schema;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace Microsoft.Bot.Builder.Dialogs.Adaptive
@ -23,6 +25,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive
/// </summary>
public class AdaptiveDialog : DialogContainer
{
[JsonProperty("$kind")]
public const string DeclarativeType = "Microsoft.AdaptiveDialog";
private const string AdaptiveKey = "adaptiveDialogState";
private readonly string changeKey = Guid.NewGuid().ToString();
@ -35,8 +40,10 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive
RegisterSourceLocation(callerPath, callerLine);
}
[JsonIgnore]
public IStatePropertyAccessor<BotState> BotState { get; set; }
[JsonIgnore]
public IStatePropertyAccessor<Dictionary<string, object>> UserState { get; set; }
/// <summary>
@ -45,6 +52,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive
/// <value>
/// Recognizer for processing incoming user input.
/// </value>
[JsonProperty("recognizer")]
public IRecognizer Recognizer { get; set; }
/// <summary>
@ -53,6 +61,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive
/// <value>
/// Language Generator override.
/// </value>
[JsonProperty("generator")]
public ILanguageGenerator Generator { get; set; }
/// <summary>
@ -61,6 +70,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive
/// <value>
/// Trigger handlers to respond to conditions which modifying the executing plan.
/// </value>
[JsonProperty("triggers")]
public virtual List<OnCondition> Triggers { get; set; } = new List<OnCondition>();
/// <summary>
@ -73,6 +83,8 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive
/// <value>
/// Whether to end the dialog when there are no actions to execute.
/// </value>
[DefaultValue(true)]
[JsonProperty("autoEndDialog")]
public bool AutoEndDialog { get; set; } = true;
/// <summary>
@ -81,6 +93,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive
/// <value>
/// The selector for picking the possible events to execute.
/// </value>
[JsonProperty("selector")]
public ITriggerSelector Selector { get; set; }
/// <summary>
@ -89,8 +102,10 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive
/// <value>
/// The property to return as the result when the dialog ends when there are no more Actions and AutoEndDialog = true.
/// </value>
[JsonProperty("defaultResultProperty")]
public string DefaultResultProperty { get; set; } = "dialog.result";
[JsonIgnore]
public override IBotTelemetryClient TelemetryClient
{
get
@ -208,6 +223,20 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive
return null;
}
public IEnumerable<Dialog> GetDependencies()
{
foreach (var trigger in Triggers)
{
if (trigger is IDialogDependencies depends)
{
foreach (var dlg in depends.GetDependencies())
{
yield return dlg;
}
}
}
}
protected override async Task<bool> OnPreBubbleEventAsync(DialogContext dc, DialogEvent dialogEvent, CancellationToken cancellationToken = default)
{
var sequenceContext = ToSequenceContext(dc);
@ -395,20 +424,20 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive
var instanceId = GetUniqueInstanceId(sequenceContext);
// Execute queued actions
var action = CreateChildContext(sequenceContext) as SequenceContext;
while (action != null)
var actionContext = CreateChildContext(sequenceContext) as SequenceContext;
while (actionContext != null)
{
// Continue current step
// DEBUG: To debug step execution set a breakpoint on line below and add a watch
// statement for sequenceContext.Actions.
var result = await action.ContinueDialogAsync(cancellationToken).ConfigureAwait(false);
var result = await actionContext.ContinueDialogAsync(cancellationToken).ConfigureAwait(false);
// Start step if not continued
if (result.Status == DialogTurnStatus.Empty && GetUniqueInstanceId(sequenceContext) == instanceId)
{
// Call begin dialog on our next step, passing the effective options we computed
var nextAction = action.Actions.First();
result = await action.BeginDialogAsync(nextAction.DialogId, nextAction.Options, cancellationToken).ConfigureAwait(false);
var nextAction = actionContext.Actions.First();
result = await actionContext.BeginDialogAsync(nextAction.DialogId, nextAction.Options, cancellationToken).ConfigureAwait(false);
}
// Is the step waiting for input or were we cancelled?
@ -446,7 +475,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive
// Apply any local changes and fetch next action
await sequenceContext.ApplyChangesAsync(cancellationToken).ConfigureAwait(false);
action = CreateChildContext(sequenceContext) as SequenceContext;
actionContext = CreateChildContext(sequenceContext) as SequenceContext;
}
return await OnEndOfActionsAsync(sequenceContext, cancellationToken).ConfigureAwait(false);
@ -570,9 +599,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive
{
installedDependencies = true;
foreach (var @event in Triggers)
foreach (var trigger in Triggers)
{
if (@event is IDialogDependencies depends)
if (trigger is IDialogDependencies depends)
{
foreach (var dlg in depends.GetDependencies())
{

Просмотреть файл

@ -65,8 +65,8 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Generators
else
{
var diagnosticMessage = string.IsNullOrWhiteSpace(type) ?
"'type' or '$type' is not exist in lg output json object."
: $"Type '{type}' is not support currently.";
"'lgType' does not exist in lg output json object."
: $"Type '{type}' is not supported currently.";
result.Add(BuildDiagnostic(diagnosticMessage));
}
@ -281,7 +281,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Generators
return result;
}
var properties = value.Properties().Select(u => u.Name.ToLowerInvariant()).Where(u => u != "$type");
var properties = value.Properties().Select(u => u.Name.ToLowerInvariant()).Where(u => u != "lgtype");
IList<string> objectProperties;
if (type == typeof(Activity))
@ -313,7 +313,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Generators
return string.Empty;
}
var type = jObj["$type"]?.ToString()?.Trim();
var type = jObj["lgType"]?.ToString()?.Trim();
if (string.IsNullOrEmpty(type))
{
// Adaptive card type

Просмотреть файл

@ -88,20 +88,26 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Generators
{
var activity = new JObject
{
["Type"] = ActivityTypes.Message
["type"] = ActivityTypes.Message
};
foreach (var item in lgJObj)
{
var property = item.Key.Trim();
if (property == "lgType")
{
continue;
}
var value = item.Value;
switch (property.ToLowerInvariant())
{
case "attachments":
activity["Attachments"] = JArray.FromObject(GetAttachments(value));
activity["attachments"] = JArray.FromObject(GetAttachments(value));
break;
case "suggestedactions":
activity["SuggestedActions"] = JObject.FromObject(GetSuggestions(value));
activity["suggestedActions"] = JObject.FromObject(GetSuggestions(value));
break;
default:
activity[property] = value;
@ -147,7 +153,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Generators
var type = GetStructureType(actionJObj);
var cardActionJson = new JObject()
{
["Type"] = ActionTypes.ImBack
["type"] = ActionTypes.ImBack
};
if (type == nameof(CardAction).ToLowerInvariant())
@ -171,7 +177,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Generators
return string.Empty;
}
var type = jObj["$type"]?.ToString()?.Trim();
var type = jObj["lgType"]?.ToString()?.Trim();
if (string.IsNullOrEmpty(type))
{
// Adaptive card type
@ -239,15 +245,15 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Generators
var type = value.ToString().ToLowerInvariant();
if (GenericCardTypeMapping.ContainsKey(type))
{
attachmentJson["ContentType"] = GenericCardTypeMapping[type];
attachmentJson["contentType"] = GenericCardTypeMapping[type];
}
else if (type == "adaptivecard")
{
attachmentJson["ContentType"] = AdaptiveCardType;
attachmentJson["contentType"] = AdaptiveCardType;
}
else
{
attachmentJson["ContentType"] = type;
attachmentJson["contentType"] = type;
}
break;

Просмотреть файл

@ -4,6 +4,7 @@
using System;
using System.Collections.Concurrent;
using Microsoft.Bot.Builder.Dialogs;
using Newtonsoft.Json;
namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Generators
{
@ -12,6 +13,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Generators
/// </summary>
public class MultiLanguageGenerator : MultiLanguageGeneratorBase
{
[JsonProperty("$kind")]
public const string DeclarativeType = "Microsoft.MultiLanguageGenerator";
/// <summary>
/// Initializes a new instance of the <see cref="MultiLanguageGenerator"/> class.
/// </summary>
@ -25,6 +29,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Generators
/// <value>
/// The language generators for multiple languages.
/// </value>
[JsonProperty("languageGenerators")]
public ConcurrentDictionary<string, ILanguageGenerator> LanguageGenerators { get; set; } = new ConcurrentDictionary<string, ILanguageGenerator>(StringComparer.OrdinalIgnoreCase);
/// <summary>

Просмотреть файл

@ -14,6 +14,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Generators
/// </remarks>
public class ResourceMultiLanguageGenerator : MultiLanguageGeneratorBase
{
[JsonProperty("$kind")]
public const string DeclarativeType = "Microsoft.ResourceMultiLanguageGenerator";
/// <summary>
/// Initializes a new instance of the <see cref="ResourceMultiLanguageGenerator"/> class.
/// </summary>

Просмотреть файл

@ -8,6 +8,7 @@ using System.Linq;
using System.Threading.Tasks;
using Microsoft.Bot.Builder.Dialogs.Declarative.Resources;
using Microsoft.Bot.Builder.LanguageGeneration;
using Newtonsoft.Json;
namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Generators
{
@ -16,6 +17,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Generators
/// </summary>
public class TemplateEngineLanguageGenerator : ILanguageGenerator
{
[JsonProperty("$kind")]
public const string DeclarativeType = "Microsoft.TemplateEngineLanguageGenerator";
private const string DEFAULTLABEL = "Unknown";
private readonly Dictionary<string, TemplateEngine> multiLangEngines = new Dictionary<string, TemplateEngine>();
@ -94,6 +98,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Generators
/// <value>
/// Id of the source of this template (used for labeling errors).
/// </value>
[JsonProperty("id")]
public string Id { get; set; } = string.Empty;
/// <summary>

Просмотреть файл

@ -2,6 +2,7 @@
// Licensed under the MIT License.
using System.Threading.Tasks;
using Newtonsoft.Json;
namespace Microsoft.Bot.Builder.Dialogs.Adaptive
{

Просмотреть файл

@ -5,12 +5,15 @@ using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using Microsoft.Bot.Schema;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input
{
/// <summary>
/// Format specifier for outputs.
/// </summary>
[JsonConverter(typeof(StringEnumConverter))]
public enum AttachmentOutputFormat
{
/// <summary>
@ -26,11 +29,15 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input
public class AttachmentInput : InputDialog
{
[JsonProperty("$kind")]
public const string DeclarativeType = "Microsoft.AttachmentInput";
public AttachmentInput([CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLine = 0)
{
this.RegisterSourceLocation(callerPath, callerLine);
}
[JsonProperty("outputFormat")]
public AttachmentOutputFormat OutputFormat { get; set; } = AttachmentOutputFormat.First;
protected override Task<InputState> OnRecognizeInput(DialogContext dc)

Просмотреть файл

@ -11,6 +11,7 @@ using Microsoft.Bot.Builder.Dialogs.Choices;
using Microsoft.Bot.Builder.Dialogs.Declarative;
using Microsoft.Bot.Schema;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using static Microsoft.Recognizers.Text.Culture;
namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input
@ -33,6 +34,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input
/// </summary>
public class ChoiceInput : InputDialog
{
[JsonProperty("$kind")]
public const string DeclarativeType = "Microsoft.ChoiceInput";
private static readonly Dictionary<string, ChoiceFactoryOptions> DefaultChoiceOptions = new Dictionary<string, ChoiceFactoryOptions>(StringComparer.OrdinalIgnoreCase)
{
{ Spanish, new ChoiceFactoryOptions { InlineSeparator = ", ", InlineOr = " o ", InlineOrMore = ", o ", IncludeNumbers = true } },
@ -56,6 +60,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input
/// <value>
/// Value Expression or List of choices (string or Choice objects) to present to user.
/// </value>
[JsonProperty("choices")]
public ChoiceSet Choices { get; set; }
/// <summary>
@ -64,6 +69,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input
/// <value>
/// ListStyle to use to render the choices.
/// </value>
[JsonProperty("style")]
public ListStyle Style { get; set; } = ListStyle.Auto;
/// <summary>
@ -72,6 +78,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input
/// <value>
/// DefaultLocale.
/// </value>
[JsonProperty("defaultLocale")]
public string DefaultLocale { get; set; } = null;
/// <summary>
@ -80,6 +87,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input
/// <value>
/// Control the format of the response (value or the index of the choice).
/// </value>
[JsonProperty("outputFormat")]
public ChoiceOutputFormat OutputFormat { get; set; } = ChoiceOutputFormat.Value;
/// <summary>
@ -88,6 +96,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input
/// <value>
/// ChoiceOptions controls display options for customizing language.
/// </value>
[JsonProperty("choiceOptions")]
public ChoiceFactoryOptions ChoiceOptions { get; set; } = null;
/// <summary>
@ -96,6 +105,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input
/// <value>
/// Customize how to use the choices to recognize the response from the user.
/// </value>
[JsonProperty("recognizerOptions")]
public FindChoicesOptions RecognizerOptions { get; set; } = null;
public override Task<DialogTurnResult> ResumeDialogAsync(DialogContext dc, DialogReason reason, object result = null, CancellationToken cancellationToken = default(CancellationToken))

Просмотреть файл

@ -3,11 +3,13 @@
using System.Collections.Generic;
using Microsoft.Bot.Builder.Dialogs.Choices;
using Newtonsoft.Json;
namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input
{
public class ChoiceInputOptions : InputDialogOptions
{
[JsonProperty("choices")]
public List<Choice> Choices { get; set; }
}
}

Просмотреть файл

@ -41,7 +41,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive
return strings.Select(s => new Choice(s)).ToList();
}
// support JArray to => hoice
// support JArray to => choice
if (result is JArray array)
{
var choices = new List<Choice>();

Просмотреть файл

@ -8,6 +8,7 @@ using System.Threading.Tasks;
using Microsoft.Bot.Builder.Dialogs.Choices;
using Microsoft.Bot.Schema;
using Microsoft.Recognizers.Text.Choice;
using Newtonsoft.Json;
using static Microsoft.Recognizers.Text.Culture;
namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input
@ -17,6 +18,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input
/// </summary>
public class ConfirmInput : InputDialog
{
[JsonProperty("$kind")]
public const string DeclarativeType = "Microsoft.ConfirmInput";
private static readonly Dictionary<string, (Choice, Choice, ChoiceFactoryOptions)> ChoiceDefaults = new Dictionary<string, (Choice, Choice, ChoiceFactoryOptions)>(StringComparer.OrdinalIgnoreCase)
{
{ Spanish, (new Choice("Sí"), new Choice("No"), new ChoiceFactoryOptions(", ", " o ", ", o ", true)) },
@ -34,12 +38,16 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input
this.RegisterSourceLocation(callerPath, callerLine);
}
[JsonProperty("defaultLocale")]
public string DefaultLocale { get; set; } = null;
[JsonProperty("style")]
public ListStyle Style { get; set; } = ListStyle.Auto;
[JsonProperty("choiceOptions")]
public ChoiceFactoryOptions ChoiceOptions { get; set; } = null;
[JsonProperty("confirmChoices")]
public List<Choice> ConfirmChoices { get; set; } = null;
protected override Task<InputState> OnRecognizeInput(DialogContext dc)

Просмотреть файл

@ -5,17 +5,22 @@ using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using Microsoft.Recognizers.Text.DateTime;
using Newtonsoft.Json;
using static Microsoft.Recognizers.Text.Culture;
namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input
{
public class DateTimeInput : InputDialog
{
[JsonProperty("$kind")]
public const string DeclarativeType = "Microsoft.DateTimeInput";
public DateTimeInput([CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLine = 0)
{
this.RegisterSourceLocation(callerPath, callerLine);
}
[JsonProperty("defaultLocale")]
public string DefaultLocale { get; set; } = null;
protected override Task<InputState> OnRecognizeInput(DialogContext dc)

Просмотреть файл

@ -5,6 +5,8 @@ using System;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using Microsoft.Recognizers.Text.Number;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using static Microsoft.Recognizers.Text.Culture;
namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input
@ -12,6 +14,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input
/// <summary>
/// What format to output the number in.
/// </summary>
[JsonConverter(typeof(StringEnumConverter))]
public enum NumberOutputFormat
{
/// <summary>
@ -27,13 +30,18 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input
public class NumberInput : InputDialog
{
[JsonProperty("$kind")]
public const string DeclarativeType = "Microsoft.NumberInput";
public NumberInput([CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLine = 0)
{
this.RegisterSourceLocation(callerPath, callerLine);
}
[JsonProperty("defaultLocale")]
public string DefaultLocale { get; set; } = null;
[JsonProperty("outputFormat")]
public NumberOutputFormat OutputFormat { get; set; } = NumberOutputFormat.Float;
protected override Task<InputState> OnRecognizeInput(DialogContext dc)

Просмотреть файл

@ -9,12 +9,16 @@ using System.Threading;
using System.Threading.Tasks;
using Microsoft.Bot.Connector;
using Microsoft.Bot.Schema;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input
{
public class OAuthInput : Dialog
{
[JsonProperty("$kind")]
public const string DeclarativeType = "Microsoft.OAuthInput";
private const string PersistedOptions = "options";
private const string PersistedState = "state";
private const string PersistedExpires = "expires";
@ -27,18 +31,21 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input
/// Gets or sets the name of the OAuth connection.
/// </summary>
/// <value>The name of the OAuth connection.</value>
[JsonProperty("connectionName")]
public string ConnectionName { get; set; }
/// <summary>
/// Gets or sets the title of the sign-in card.
/// </summary>
/// <value>The title of the sign-in card.</value>
[JsonProperty("title")]
public string Title { get; set; }
/// <summary>
/// Gets or sets any additional text to include in the sign-in card.
/// </summary>
/// <value>Any additional text to include in the sign-in card.</value>
[JsonProperty("text")]
public string Text { get; set; }
/// <summary>
@ -46,6 +53,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input
/// Default is 900,000 (15 minutes).
/// </summary>
/// <value>The number of milliseconds the prompt waits for the user to authenticate.</value>
[JsonProperty("timeout")]
public int Timeout { get; set; } = 900000;
/// <summary>
@ -54,6 +62,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input
/// <value>
/// The memory property to use for token result.
/// </value>
[JsonProperty("tokenProperty")]
public string TokenProperty { get; set; }
/// <summary>

Просмотреть файл

@ -3,6 +3,7 @@
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using Newtonsoft.Json;
namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input
{
@ -37,11 +38,15 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input
/// </summary>
public class TextInput : InputDialog
{
[JsonProperty("$kind")]
public const string DeclarativeType = "Microsoft.TextInput";
public TextInput([CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLine = 0)
{
this.RegisterSourceLocation(callerPath, callerLine);
}
[JsonProperty("outputFormat")]
public TextOutputFormat OutputFormat { get; set; } = TextOutputFormat.None;
protected override Task<InputState> OnRecognizeInput(DialogContext dc)

Просмотреть файл

@ -17,9 +17,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive
{
public override IEnumerable<TypeRegistration> GetTypes()
{
yield return new TypeRegistration<TextTemplate>("Microsoft.TextTemplate");
yield return new TypeRegistration<ActivityTemplate>("Microsoft.ActivityTemplate");
yield return new TypeRegistration<StaticActivityTemplate>("Microsoft.StaticActivityTemplate");
yield return new TypeRegistration<TextTemplate>(TextTemplate.DeclarativeType);
yield return new TypeRegistration<ActivityTemplate>(ActivityTemplate.DeclarativeType);
yield return new TypeRegistration<StaticActivityTemplate>(StaticActivityTemplate.DeclarativeType);
}
public override IEnumerable<JsonConverter> GetConverters(ISourceMap sourceMap, IRefResolver refResolver, Stack<string> paths)

Просмотреть файл

@ -18,6 +18,10 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive
{
}
public override bool CanRead => true;
public override bool CanWrite => true;
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
if (reader.ValueType == typeof(string))
@ -29,5 +33,10 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive
return base.ReadJson(reader, objectType, existingValue, serializer);
}
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
base.WriteJson(writer, value, serializer);
}
}
}

Просмотреть файл

@ -14,7 +14,7 @@ namespace Microsoft.Bot.Builder.AI.QnA
public override IEnumerable<TypeRegistration> GetTypes()
{
// Dialogs
yield return new TypeRegistration<QnAMakerDialog>("Microsoft.QnAMakerDialog");
yield return new TypeRegistration<QnAMakerDialog>(QnAMakerDialog.DeclarativeType);
}
public override IEnumerable<JsonConverter> GetConverters(ISourceMap sourceMap, IRefResolver refResolver, Stack<string> paths)

Просмотреть файл

@ -21,6 +21,9 @@ namespace Microsoft.Bot.Builder.AI.QnA
/// </summary>
public class QnAMakerDialog : Dialog
{
[JsonProperty("$kind")]
public const string DeclarativeType = "Microsoft.QnAMakerDialog";
private readonly HttpClient httpClient;
private Expression knowledgebaseId;
private Expression endpointkey;

Просмотреть файл

@ -1,11 +1,15 @@
using System.Collections.Generic;
using Microsoft.Recognizers.Text;
using Microsoft.Recognizers.Text.NumberWithUnit;
using Newtonsoft.Json;
namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers
{
public class AgeEntityRecognizer : EntityRecognizer
{
[JsonProperty("$kind")]
public const string DeclarativeType = "Microsoft.AgeEntityRecognizer";
public AgeEntityRecognizer()
{
}

Просмотреть файл

@ -1,6 +1,7 @@
using System.Collections.Generic;
using Microsoft.Recognizers.Text;
using Microsoft.Recognizers.Text.Choice;
using Newtonsoft.Json;
namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers
{
@ -9,6 +10,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers
/// </summary>
public class ConfirmationEntityRecognizer : EntityRecognizer
{
[JsonProperty("$kind")]
public const string DeclarativeType = "Microsoft.ConfirmationEntityRecognizer";
public ConfirmationEntityRecognizer()
{
}

Просмотреть файл

@ -1,11 +1,15 @@
using System.Collections.Generic;
using Microsoft.Recognizers.Text;
using Microsoft.Recognizers.Text.NumberWithUnit;
using Newtonsoft.Json;
namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers
{
public class CurrencyEntityRecognizer : EntityRecognizer
{
[JsonProperty("$kind")]
public const string DeclarativeType = "Microsoft.CurrencyEntityRecognizer";
public CurrencyEntityRecognizer()
{
}

Просмотреть файл

@ -1,11 +1,15 @@
using System.Collections.Generic;
using Microsoft.Recognizers.Text;
using Microsoft.Recognizers.Text.DateTime;
using Newtonsoft.Json;
namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers
{
public class DateTimeEntityRecognizer : EntityRecognizer
{
[JsonProperty("$kind")]
public const string DeclarativeType = "Microsoft.DateTimeEntityRecognizer";
public DateTimeEntityRecognizer()
{
}

Просмотреть файл

@ -1,11 +1,15 @@
using System.Collections.Generic;
using Microsoft.Recognizers.Text;
using Microsoft.Recognizers.Text.NumberWithUnit;
using Newtonsoft.Json;
namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers
{
public class DimensionEntityRecognizer : EntityRecognizer
{
[JsonProperty("$kind")]
public const string DeclarativeType = "Microsoft.DimensionEntityRecognizer";
public DimensionEntityRecognizer()
{
}

Просмотреть файл

@ -1,11 +1,15 @@
using System.Collections.Generic;
using Microsoft.Recognizers.Text;
using Microsoft.Recognizers.Text.Sequence;
using Newtonsoft.Json;
namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers
{
public class EmailEntityRecognizer : EntityRecognizer
{
[JsonProperty("$kind")]
public const string DeclarativeType = "Microsoft.EmailEntityRecognizer";
public EmailEntityRecognizer()
{
}

Просмотреть файл

@ -3,6 +3,7 @@ using System.Linq;
using System.Threading.Tasks;
using Microsoft.Bot.Schema;
using Microsoft.Recognizers.Text;
using Newtonsoft.Json;
namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers
{

Просмотреть файл

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Bot.Schema;
using Newtonsoft.Json;
namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers
{
@ -11,6 +12,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers
/// </summary>
public class EntityRecognizerSet : List<EntityRecognizer>
{
[JsonProperty("$kind")]
public const string DeclarativeType = "Microsoft.EntityRecognizerSet";
public EntityRecognizerSet()
{
}

Просмотреть файл

@ -1,11 +1,15 @@
using System.Collections.Generic;
using Microsoft.Recognizers.Text;
using Microsoft.Recognizers.Text.Sequence;
using Newtonsoft.Json;
namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers
{
public class GuidEntityRecognizer : EntityRecognizer
{
[JsonProperty("$kind")]
public const string DeclarativeType = "Microsoft.GuidEntityRecognizer";
public GuidEntityRecognizer()
{
}

Просмотреть файл

@ -1,11 +1,15 @@
using System.Collections.Generic;
using Microsoft.Recognizers.Text;
using Microsoft.Recognizers.Text.Sequence;
using Newtonsoft.Json;
namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers
{
public class HashtagEntityRecognizer : EntityRecognizer
{
[JsonProperty("$kind")]
public const string DeclarativeType = "Microsoft.HashtagEntityRecognizer";
public HashtagEntityRecognizer()
{
}

Просмотреть файл

@ -1,11 +1,15 @@
using System.Collections.Generic;
using Microsoft.Recognizers.Text;
using Microsoft.Recognizers.Text.Sequence;
using Newtonsoft.Json;
namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers
{
public class IpEntityRecognizer : EntityRecognizer
{
[JsonProperty("$kind")]
public const string DeclarativeType = "Microsoft.IpEntityRecognizer";
public IpEntityRecognizer()
{
}

Просмотреть файл

@ -1,11 +1,15 @@
using System.Collections.Generic;
using Microsoft.Recognizers.Text;
using Microsoft.Recognizers.Text.Sequence;
using Newtonsoft.Json;
namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers
{
public class MentionEntityRecognizer : EntityRecognizer
{
[JsonProperty("$kind")]
public const string DeclarativeType = "Microsoft.MentionEntityRecognizer";
public MentionEntityRecognizer()
{
}

Просмотреть файл

@ -1,11 +1,15 @@
using System.Collections.Generic;
using Microsoft.Recognizers.Text;
using Microsoft.Recognizers.Text.Number;
using Newtonsoft.Json;
namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers
{
public class NumberEntityRecognizer : EntityRecognizer
{
[JsonProperty("$kind")]
public const string DeclarativeType = "Microsoft.NumberEntityRecognizer";
public NumberEntityRecognizer()
{
}

Просмотреть файл

@ -1,11 +1,15 @@
using System.Collections.Generic;
using Microsoft.Recognizers.Text;
using Microsoft.Recognizers.Text.Number;
using Newtonsoft.Json;
namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers
{
public class NumberRangeEntityRecognizer : EntityRecognizer
{
[JsonProperty("$kind")]
public const string DeclarativeType = "Microsoft.NumberRangeEntityRecognizer";
public NumberRangeEntityRecognizer()
{
}

Просмотреть файл

@ -1,11 +1,15 @@
using System.Collections.Generic;
using Microsoft.Recognizers.Text;
using Microsoft.Recognizers.Text.Number;
using Newtonsoft.Json;
namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers
{
public class OrdinalEntityRecognizer : EntityRecognizer
{
[JsonProperty("$kind")]
public const string DeclarativeType = "Microsoft.OrdinalEntityRecognizer";
public OrdinalEntityRecognizer()
{
}

Просмотреть файл

@ -1,11 +1,15 @@
using System.Collections.Generic;
using Microsoft.Recognizers.Text;
using Microsoft.Recognizers.Text.Number;
using Newtonsoft.Json;
namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers
{
public class PercentageEntityRecognizer : EntityRecognizer
{
[JsonProperty("$kind")]
public const string DeclarativeType = "Microsoft.PercentageEntityRecognizer";
public PercentageEntityRecognizer()
{
}

Просмотреть файл

@ -1,11 +1,15 @@
using System.Collections.Generic;
using Microsoft.Recognizers.Text;
using Microsoft.Recognizers.Text.Sequence;
using Newtonsoft.Json;
namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers
{
public class PhoneNumberEntityRecognizer : EntityRecognizer
{
[JsonProperty("$kind")]
public const string DeclarativeType = "Microsoft.PhoneNumberEntityRecognizer";
public PhoneNumberEntityRecognizer()
{
}

Просмотреть файл

@ -9,6 +9,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers
{
public class RegexEntityRecognizer : EntityRecognizer
{
[JsonProperty("$kind")]
public const string DeclarativeType = "Microsoft.RegexEntityRecognizer";
private string pattern;
private Regex regex;

Просмотреть файл

@ -1,11 +1,15 @@
using System.Collections.Generic;
using Microsoft.Recognizers.Text;
using Microsoft.Recognizers.Text.NumberWithUnit;
using Newtonsoft.Json;
namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers
{
public class TemperatureEntityRecognizer : EntityRecognizer
{
[JsonProperty("$kind")]
public const string DeclarativeType = "Microsoft.TemperatureEntityRecognizer";
public TemperatureEntityRecognizer()
{
}

Просмотреть файл

@ -1,11 +1,15 @@
using System.Collections.Generic;
using Microsoft.Recognizers.Text;
using Microsoft.Recognizers.Text.Sequence;
using Newtonsoft.Json;
namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers
{
public class UrlEntityRecognizer : EntityRecognizer
{
[JsonProperty("$kind")]
public const string DeclarativeType = "Microsoft.UrlEntityRecognizer";
public UrlEntityRecognizer()
{
}

Просмотреть файл

@ -2,6 +2,7 @@
// Licensed under the MIT License.
using System.Text.RegularExpressions;
using Newtonsoft.Json;
namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers
{
@ -10,6 +11,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers
/// </summary>
public class IntentPattern
{
[JsonProperty("$kind")]
public const string DeclarativeType = "Microsoft.IntentPattern";
private Regex regex;
private string pattern;
@ -29,6 +33,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers
/// <value>
/// The intent.
/// </value>
[JsonProperty("intent")]
public string Intent { get; set; }
/// <summary>
@ -37,6 +42,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers
/// <value>
/// The regex pattern to match.
/// </value>
[JsonProperty("pattern")]
public string Pattern
{
get
@ -51,6 +57,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers
}
}
[JsonIgnore]
public Regex Regex => this.regex;
}
}

Просмотреть файл

@ -14,6 +14,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers
/// </summary>
public class MultiLanguageRecognizer : IRecognizer
{
[JsonProperty("$kind")]
public const string DeclarativeType = "Microsoft.MultiLanguageRecognizer";
public MultiLanguageRecognizer()
{
}

Просмотреть файл

@ -17,6 +17,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers
/// </summary>
public class RegexRecognizer : IRecognizer
{
[JsonProperty("$kind")]
public const string DeclarativeType = "Microsoft.RegexRecognizer";
public RegexRecognizer()
{
}

Просмотреть файл

@ -6,7 +6,7 @@
"type": "object",
"properties": {
"dialog": {
"$type": "Microsoft.IDialog",
"$kind": "Microsoft.IDialog",
"title": "Dialog name",
"description": "Name of the dialog to call.",
"examples": [

Просмотреть файл

@ -24,7 +24,7 @@
"actions": {
"type": "array",
"items": {
"$type": "Microsoft.IDialog"
"$kind": "Microsoft.IDialog"
},
"title": "Actions",
"description": "Actions to apply."

Просмотреть файл

@ -16,7 +16,7 @@
"actions": {
"type": "array",
"items": {
"$type": "Microsoft.IDialog"
"$kind": "Microsoft.IDialog"
},
"title": "Actions",
"description": "Actions to execute for each item. Use '$foreach.value' to access the value of each item. Use '$foreach.index' to access the index of each item."

Просмотреть файл

@ -16,7 +16,7 @@
"actions": {
"type": "array",
"items": {
"$type": "Microsoft.IDialog"
"$kind": "Microsoft.IDialog"
},
"title": "Actions",
"description": "Actions to execute for each page. Use '$foreach.page' to access each page."

Просмотреть файл

@ -20,7 +20,7 @@
"actions": {
"type": "array",
"items": {
"$type": "Microsoft.IDialog"
"$kind": "Microsoft.IDialog"
},
"title": "Actions",
"description": "Actions to execute if condition is true."
@ -28,7 +28,7 @@
"elseActions": {
"type": "array",
"items": {
"$type": "Microsoft.IDialog"
"$kind": "Microsoft.IDialog"
},
"title": "Else",
"description": "Actions to execute if condition is false."

Просмотреть файл

@ -6,7 +6,7 @@
"description": "Replace current dialog with another dialog.",
"properties": {
"dialog": {
"$type": "Microsoft.IDialog",
"$kind": "Microsoft.IDialog",
"title": "Dialog name",
"description": "Current dialog will be replaced by this dialog."
},

Просмотреть файл

@ -6,7 +6,7 @@
"type": "object",
"properties": {
"activity": {
"$type": "Microsoft.IActivityTemplate",
"$kind": "Microsoft.IActivityTemplate",
"title": "Activity",
"description": "Activity to send."
}

Просмотреть файл

@ -35,7 +35,7 @@
"actions": {
"type": "array",
"items": {
"$type": "Microsoft.IDialog"
"$kind": "Microsoft.IDialog"
},
"title": "Actions",
"description": "Actions to execute."
@ -50,7 +50,7 @@
"default": {
"type": "array",
"items": {
"$type": "Microsoft.IDialog"
"$kind": "Microsoft.IDialog"
},
"title": "Default",
"description": "Actions to execute if none of the cases meet the condition."

Просмотреть файл

@ -28,7 +28,7 @@
]
},
"noAnswer": {
"$type": "Microsoft.IActivityTemplate",
"$kind": "Microsoft.IActivityTemplate",
"title": "Fallback answer",
"description": "Default answer to return when none found in KB.",
"default": "Sorry, I did not find an answer."
@ -52,7 +52,7 @@
"default": "None of the above."
},
"cardNoMatchResponse ": {
"$type": "Microsoft.IActivityTemplate",
"$kind": "Microsoft.IActivityTemplate",
"title": "Card no match response",
"description": "Custom response when no match option was selected.",
"default": "Thanks for the feedback."

Просмотреть файл

@ -23,17 +23,17 @@
"default": "dialog.result"
},
"recognizer": {
"$type": "Microsoft.IRecognizer",
"$kind": "Microsoft.IRecognizer",
"title": "Recognizer",
"description": "Language Understanding recognizer that interprets user input into intent and entities."
},
"generator": {
"$type": "Microsoft.ILanguageGenerator",
"$kind": "Microsoft.ILanguageGenerator",
"title": "Language Generator",
"description": "Language generator that generates bot responses."
},
"selector": {
"$type": "Microsoft.ITriggerSelector",
"$kind": "Microsoft.ITriggerSelector",
"title": "Selector",
"description": "Policy to determine which trigger is executed. Defaults to a 'best match' selector (optional)."
},
@ -42,7 +42,7 @@
"description": "List of triggers defined for this dialog.",
"title": "Triggers",
"items": {
"$type": "Microsoft.ITriggerCondition"
"$kind": "Microsoft.ITriggerCondition"
}
}
}

Просмотреть файл

@ -0,0 +1,6 @@
{
"$schema": "https://raw.githubusercontent.com/microsoft/botbuilder-dotnet/master/schemas/component.schema",
"title": "Microsoft Test ITestAction",
"description": "Union of components which implement the Test.ITestAction interface",
"$role": "unionType"
}

Просмотреть файл

@ -6,7 +6,7 @@
"type": "object",
"properties": {
"languagePolicy": {
"$type": "Microsoft.LanguagePolicy",
"$kind": "Microsoft.LanguagePolicy",
"type": "object",
"title": "Language policy",
"description": "Defines fall back languages to try per user input language."
@ -16,7 +16,7 @@
"title": "Recognizers",
"description": "Map of language -> IRecognizer",
"additionalProperties": {
"$type": "Microsoft.IRecognizer"
"$kind": "Microsoft.IRecognizer"
}
}
},

Просмотреть файл

@ -28,7 +28,7 @@
"entities": {
"type": "array",
"items": {
"$type": "Microsoft.EntityRecognizers"
"$kind": "Microsoft.EntityRecognizers"
},
"title": "Entity recognizers",
"description": "Collection of entity recognizers to use."

Просмотреть файл

@ -9,10 +9,10 @@
"$role": "expression"
},
"ifTrue": {
"$type": "Microsoft.ITriggerSelector"
"$kind": "Microsoft.ITriggerSelector"
},
"ifFalse": {
"$type": "Microsoft.ITriggerSelector"
"$kind": "Microsoft.ITriggerSelector"
}
},
"required": [

Просмотреть файл

@ -6,7 +6,7 @@
"type": "object",
"properties": {
"selector": {
"$type": "Microsoft.ITriggerSelector"
"$kind": "Microsoft.ITriggerSelector"
}
}
}

Просмотреть файл

@ -0,0 +1,45 @@
{
"$schema": "https://raw.githubusercontent.com/microsoft/botbuilder-dotnet/master/schemas/component.schema",
"$role": "unionType(Microsoft.Test.ITestAction)",
"title": "Assert Reply",
"description": "Asserts that a reply text is valid.",
"type": "object",
"required": [
"text"
],
"properties": {
"text": {
"type": "string",
"title": "Reply Text",
"description": "Expected reply text"
},
"exact": {
"type": "boolean",
"title": "Exact Match",
"description": "If true then an exact match must happen, if false then the reply activity.text must contain the reply text. [Default:false]"
},
"description": {
"type": "string",
"title": "Description",
"description": "The description of what the assertion is testing"
},
"timeout": {
"type": "number",
"title": "Timeout",
"description": "The amount of time in milliseconds to wait for a reply (default is 3000)"
},
"assertions": {
"type": "array",
"title": "Assertions to perform to validate Activity that is sent by the dialog",
"description": "Sequence of expressions which must evaluate to true.",
"items": {
"$role": "expression",
"title": "Assertion",
"description": "Assertion as an expression, which must evaluate to true or it will fail the test script.",
"examples": [
"user.vip == true"
]
}
}
}
}

Просмотреть файл

@ -0,0 +1,35 @@
{
"$schema": "https://raw.githubusercontent.com/microsoft/botbuilder-dotnet/master/schemas/component.schema",
"$role": "unionType(Microsoft.Test.ITestAction)",
"title": "Assert Reply Activity",
"description": "Asserts that a reply activity is valid.",
"type": "object",
"required": [
"assertions"
],
"properties": {
"description": {
"type": "string",
"title": "Description",
"description": "The description of what the assertion is testing"
},
"timeout": {
"type": "number",
"title": "Timeout",
"description": "The amount of time in milliseconds to wait for a reply (default is 3000)"
},
"assertions": {
"type": "array",
"title": "Assertions to perform to validate Activity that is sent by the dialog",
"description": "Sequence of expressions which must evaluate to true.",
"items": {
"$role": "expression",
"title": "Assertion",
"description": "Assertion as an expression, which must evaluate to true or it will fail the test script.",
"examples": [
"user.vip == true"
]
}
}
}
}

Просмотреть файл

@ -0,0 +1,48 @@
{
"$schema": "https://raw.githubusercontent.com/microsoft/botbuilder-dotnet/master/schemas/component.schema",
"$role": "unionType(Microsoft.Test.ITestAction)",
"title": "Assert Reply OneOf",
"description": "Asserts that a reply text is one of multiple optional responses.",
"type": "object",
"required": [
"replies"
],
"properties": {
"text": {
"type": "array",
"title": "Replies",
"description": "Expected replies (one of which must match",
"items": {
"type": "string"
}
},
"exact": {
"type": "boolean",
"title": "Exact Match",
"description": "If true then an exact match must happen, if false then the reply activity.text must contain the reply text. [Default:false]"
},
"description": {
"type": "string",
"title": "Description",
"description": "The description of what the assertion is testing"
},
"timeout": {
"type": "number",
"title": "Timeout",
"description": "The amount of time in milliseconds to wait for a reply (default is 3000)"
},
"assertions": {
"type": "array",
"title": "Assertions to perform to validate Activity that is sent by the dialog",
"description": "Sequence of expressions which must evaluate to true.",
"items": {
"$role": "expression",
"title": "Assertion",
"description": "Assertion as an expression, which must evaluate to true or it will fail the test script.",
"examples": [
"user.vip == true"
]
}
}
}
}

Просмотреть файл

@ -0,0 +1,35 @@
{
"$schema": "https://raw.githubusercontent.com/microsoft/botbuilder-dotnet/master/schemas/component.schema",
"title": "Test Script",
"description": "Defines a sequence of test actions to perform to validate the behavior of dialogs.",
"type": "object",
"properties": {
"dialog": {
"$kind": "Microsoft.IDialog",
"title": "Dialog",
"description": "The root dialog to execute the test script against."
},
"description": {
"type": "string",
"title": "Description",
"description": "Description of the test script"
},
"script": {
"type": "array",
"description": "Sequence of test actions to execute.",
"items": {
"$kind": "Microsoft.Test.ITestAction"
}
},
"enableTrace": {
"type": "boolean",
"title": "Enable Trace Activity",
"description": "Enable trace activities in the unit test (default is false)",
"default": false
}
},
"required": [
"dialog",
"testActions"
]
}

Просмотреть файл

@ -0,0 +1,21 @@
{
"$schema": "https://raw.githubusercontent.com/microsoft/botbuilder-dotnet/master/schemas/component.schema",
"$role": "unionType(Microsoft.Test.ITestAction)",
"title": "Send Activity",
"description": "Sends activity to the bot.",
"type": "object",
"required": [
"activity"
],
"properties": {
"activity": {
"type": "object",
"additionalProperties": true
},
"user": {
"type": "string",
"title": "User Name",
"description": "The activity.from.id and activity.from.name will be this if specified."
}
}
}

Просмотреть файл

@ -0,0 +1,26 @@
{
"$schema": "https://raw.githubusercontent.com/microsoft/botbuilder-dotnet/master/schemas/component.schema",
"$role": "unionType(Microsoft.Test.ITestAction)",
"title": "Send ConversationUpdate",
"description": "Sends ConversationUpdate activity to the bot.",
"type": "object",
"required": [],
"properties": {
"membersAdded": {
"type": "array",
"title": "Members Added",
"description": "Names of the members to add",
"items": {
"type": "string"
}
},
"membersRemoved": {
"type": "array",
"title": "Members Removed",
"description": "Names of the members to remove",
"items": {
"type": "string"
}
}
}
}

Просмотреть файл

@ -0,0 +1,17 @@
{
"$schema": "https://raw.githubusercontent.com/microsoft/botbuilder-dotnet/master/schemas/component.schema",
"$role": "unionType(Microsoft.Test.ITestAction)",
"title": "Delay Execution",
"description": "Delays text script for time period.",
"type": "object",
"required": [
"timespan"
],
"properties": {
"timespan": {
"type": "number",
"title": "Timespan",
"description": "The amount of time in milliseconds to delay the execution of the test script"
}
}
}

Просмотреть файл

@ -0,0 +1,22 @@
{
"$schema": "https://raw.githubusercontent.com/microsoft/botbuilder-dotnet/master/schemas/component.schema",
"$role": "unionType(Microsoft.Test.ITestAction)",
"title": "User Text",
"description": "Sends text to the bot from the user.",
"type": "object",
"required": [
"text"
],
"properties": {
"text": {
"type": "string",
"title": "Text",
"description": "Text to send to the bot."
},
"user": {
"type": "string",
"title": "User Name",
"description": "The activity.from.id and activity.from.name will be this if specified."
}
}
}

Просмотреть файл

@ -0,0 +1,15 @@
{
"$schema": "https://raw.githubusercontent.com/microsoft/botbuilder-dotnet/master/schemas/component.schema",
"$role": "unionType(Microsoft.Test.ITestAction)",
"title": "Send Typing",
"description": "Sends typing activity to the bot.",
"type": "object",
"required": [],
"properties": {
"user": {
"type": "string",
"title": "User Name",
"description": "The activity.from.id and activity.from.name will be this if specified."
}
}
}

Просмотреть файл

@ -17,7 +17,7 @@
"type": "array",
"description": "Sequence of actions to execute.",
"items": {
"$type": "Microsoft.IDialog"
"$kind": "Microsoft.IDialog"
}
}
},

Просмотреть файл

@ -7,6 +7,7 @@ using System.Threading;
using System.Threading.Tasks;
using Microsoft.Bot.Builder.Dialogs.Adaptive.Conditions;
using Microsoft.Bot.Expressions;
using Newtonsoft.Json;
namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Selectors
{
@ -15,6 +16,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Selectors
/// </summary>
public class ConditionalSelector : ITriggerSelector
{
[JsonProperty("$kind")]
public const string DeclarativeType = "Microsoft.ConditionalSelector";
private IReadOnlyList<OnCondition> _conditionals;
private bool _evaluate;
private Expression condition;
@ -37,6 +41,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Selectors
/// <value>
/// Selector if <see cref="Condition"/> is true.
/// </value>
[JsonProperty("ifTrue")]
public ITriggerSelector IfTrue { get; set; }
/// <summary>
@ -45,6 +50,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Selectors
/// <value>
/// Selector if <see cref="Condition"/> is false.
/// </value>
[JsonProperty("ifFalse")]
public ITriggerSelector IfFalse { get; set; }
public void Initialize(IEnumerable<OnCondition> conditionals, bool evaluate = true)

Просмотреть файл

@ -7,6 +7,7 @@ using System.Threading;
using System.Threading.Tasks;
using Microsoft.Bot.Builder.Dialogs.Adaptive.Conditions;
using Microsoft.Bot.Expressions;
using Newtonsoft.Json;
namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Selectors
{
@ -15,6 +16,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Selectors
/// </summary>
public class FirstSelector : ITriggerSelector
{
[JsonProperty("$kind")]
public const string DeclarativeType = "Microsoft.FirstSelector";
private List<OnCondition> _conditionals;
private bool _evaluate;
private readonly IExpressionParser _parser = new ExpressionEngine();

Просмотреть файл

@ -9,6 +9,7 @@ using System.Threading.Tasks;
using Microsoft.Bot.Builder.Dialogs.Adaptive.Conditions;
using Microsoft.Bot.Expressions;
using Microsoft.Bot.Expressions.TriggerTrees;
using Newtonsoft.Json;
namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Selectors
{
@ -17,6 +18,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Selectors
/// </summary>
public class MostSpecificSelector : ITriggerSelector
{
[JsonProperty("$kind")]
public const string DeclarativeType = "Microsoft.MostSpecificSelector";
private readonly TriggerTree _tree = new TriggerTree();
/// <summary>

Просмотреть файл

@ -8,6 +8,7 @@ using System.Threading;
using System.Threading.Tasks;
using Microsoft.Bot.Builder.Dialogs.Adaptive.Conditions;
using Microsoft.Bot.Expressions;
using Newtonsoft.Json;
namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Selectors
{
@ -16,6 +17,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Selectors
/// </summary>
public class RandomSelector : ITriggerSelector
{
[JsonProperty("$kind")]
public const string DeclarativeType = "Microsoft.RandomSelector";
private List<OnCondition> _conditionals;
private bool _evaluate;
private Random _rand;
@ -29,6 +33,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Selectors
/// <value>
/// Optional seed for random number generator.
/// </value>
[JsonProperty("seed")]
public int Seed
{
get => _seed;

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше