This commit is contained in:
LocalizationBuildProcess 2019-08-15 12:52:19 -07:00
Родитель 765e0d8883
Коммит 9669c24047
132 изменённых файлов: 606 добавлений и 453 удалений

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

@ -64,7 +64,6 @@ namespace Microsoft.Bot.Builder.AI.TriggerTrees
/// </summary>
public TriggerTree Tree { get; }
#if TraceTree
public static bool ShowTrace = true;
#endif
@ -487,6 +486,7 @@ namespace Microsoft.Bot.Builder.AI.TriggerTrees
Debug.Assert(CheckInvariants(), "bad invariants");
#endif
}
return added;
}
@ -531,6 +531,7 @@ namespace Microsoft.Bot.Builder.AI.TriggerTrees
break;
}
}
if (add)
{
#if TraceTree

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

@ -18,7 +18,8 @@ namespace Microsoft.Bot.Builder.AI.TriggerTrees
/// <summary>
/// Create a new clause for each possible binding of variable.
/// </summary>
Any };
Any }
;
/// <summary>
/// Quantifier for allowing runtime expansion of expressions.
@ -56,7 +57,6 @@ namespace Microsoft.Bot.Builder.AI.TriggerTrees
public override string ToString()
{
return $"{Type} {Variable} {Bindings.Count()}";
}
}
}

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

@ -196,6 +196,7 @@ namespace Microsoft.Bot.Builder.AI.TriggerTrees
soFar.Clear();
break;
}
if (first)
{
soFar.AddRange(clauses);
@ -214,14 +215,17 @@ namespace Microsoft.Bot.Builder.AI.TriggerTrees
newClauses.Add(new Clause(children));
}
}
soFar = newClauses;
}
}
foreach (var clause in soFar)
{
yield return clause;
}
}
break;
case ExpressionType.Or:
{
@ -233,6 +237,7 @@ namespace Microsoft.Bot.Builder.AI.TriggerTrees
}
}
}
break;
case TriggerTree.Optional:
{
@ -242,6 +247,7 @@ namespace Microsoft.Bot.Builder.AI.TriggerTrees
yield return clause;
}
}
break;
default:
// True becomes empty expression and false drops clause
@ -256,6 +262,7 @@ namespace Microsoft.Bot.Builder.AI.TriggerTrees
{
yield return new Clause(expression);
}
break;
}
}
@ -281,11 +288,13 @@ namespace Microsoft.Bot.Builder.AI.TriggerTrees
break;
}
}
if (!found)
{
children.Add(pred);
}
}
_clauses[i] = new Clause(children);
}
}
@ -349,6 +358,7 @@ namespace Microsoft.Bot.Builder.AI.TriggerTrees
{
newClauses.AddRange(ExpandQuantifier(quantifier, clause));
}
_clauses = newClauses;
}
}
@ -375,11 +385,13 @@ namespace Microsoft.Bot.Builder.AI.TriggerTrees
children.Add(SubstituteVariable(variable, binding, child, out var childChanged));
changed = changed || childChanged;
}
if (changed)
{
newExpr = new Expression(expression.Evaluator, children.ToArray());
}
}
return newExpr;
}
@ -416,6 +428,7 @@ namespace Microsoft.Bot.Builder.AI.TriggerTrees
}
}
}
yield return new Clause(children);
}
else
@ -433,10 +446,12 @@ namespace Microsoft.Bot.Builder.AI.TriggerTrees
changed = changed || predicateChanged;
children.Add(newPredicate);
}
if (changed)
{
newClause.AnyBindings.Add(quantifier.Variable, binding);
}
newClause.Children = children.ToArray();
yield return newClause;
if (!changed)
@ -458,6 +473,7 @@ namespace Microsoft.Bot.Builder.AI.TriggerTrees
break;
}
}
if (!changed)
{
yield return clause;
@ -488,6 +504,7 @@ namespace Microsoft.Bot.Builder.AI.TriggerTrees
}
}
}
clause.Children = predicates.ToArray();
}
}

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

@ -108,6 +108,7 @@ namespace Microsoft.Bot.Builder.AI.TriggerTrees
{
eval = BuiltInFunctions.Lookup(type);
}
return eval;
}
@ -233,6 +234,7 @@ namespace Microsoft.Bot.Builder.AI.TriggerTrees
output.WriteLine(" -> {");
first = false;
}
output.WriteLine($"{spaces}{NameNode(child)}");
}

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

@ -35,7 +35,6 @@ namespace Microsoft.Bot.Builder.Azure
private readonly IDocumentClient _client;
private string _collectionLink = null;
/// <summary>
/// Initializes a new instance of the <see cref="CosmosDbStorage"/> class.
/// using the provided CosmosDB credentials, database ID, and collection ID.

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

@ -18,6 +18,22 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
/// Action which calls another dialog.
public abstract class BaseInvokeDialog : DialogAction
{
public BaseInvokeDialog(string dialogIdToCall = null, string property = null, IDictionary<string, string> bindingOptions = null)
: base()
{
this.DialogId = dialogIdToCall;
if (bindingOptions != null)
{
this.Options = bindingOptions;
}
if (!string.IsNullOrEmpty(property))
{
Property = property;
}
}
/// <summary>
/// Gets or sets configurable options for the dialog.
/// </summary>
@ -45,22 +61,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
}
}
public BaseInvokeDialog(string dialogIdToCall = null, string property = null, IDictionary<string, string> bindingOptions = null)
: base()
{
this.DialogId = dialogIdToCall;
if (bindingOptions != null)
{
this.Options = bindingOptions;
}
if (!string.IsNullOrEmpty(property))
{
Property = property;
}
}
public override List<IDialog> ListDependencies()
{
return new List<IDialog>();

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

@ -11,13 +11,14 @@ using Microsoft.Bot.Builder.Dialogs;
namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
{
using CodeActionHandler = Func<DialogContext, object, Task<DialogTurnResult>>;
using CodeActionHandler = System.Func<Microsoft.Bot.Builder.Dialogs.DialogContext, object, System.Threading.Tasks.Task<Microsoft.Bot.Builder.Dialogs.DialogTurnResult>>;
public class CodeAction : DialogAction
{
private readonly CodeActionHandler codeHandler;
public CodeAction(CodeActionHandler codeHandler, [CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLine = 0) : base()
public CodeAction(CodeActionHandler codeHandler, [CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLine = 0)
: base()
{
this.RegisterSourceLocation(callerPath, callerLine);
this.codeHandler = codeHandler ?? throw new ArgumentNullException(nameof(codeHandler));

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

@ -25,6 +25,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
{
Debugger.Break();
}
return await dc.EndDialogAsync(cancellationToken: cancellationToken).ConfigureAwait(false);
}

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

@ -20,7 +20,8 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
public string Property { get; set; }
[JsonConstructor]
public DeleteProperty([CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLine = 0) : base()
public DeleteProperty([CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLine = 0)
: base()
{
this.RegisterSourceLocation(callerPath, callerLine);
}

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

@ -14,6 +14,16 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
/// </summary>
public class EditActions : DialogAction, IDialogDependencies
{
/// <summary>
/// Initializes a new instance of the <see cref="EditActions"/> class.
/// </summary>
[JsonConstructor]
public EditActions([CallerFilePath] string sourceFilePath = "", [CallerLineNumber] int sourceLineNumber = 0)
: base()
{
this.RegisterSourceLocation(sourceFilePath, sourceLineNumber);
}
/// <summary>
/// Gets or sets the actions to be applied to the active action.
/// </summary>
@ -26,19 +36,13 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
[JsonProperty("changeType")]
public ActionChangeType ChangeType { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="EditActions"/> class.
/// </summary>
[JsonConstructor]
public EditActions([CallerFilePath] string sourceFilePath = "", [CallerLineNumber] int sourceLineNumber = 0)
: base()
public override List<IDialog> ListDependencies()
{
this.RegisterSourceLocation(sourceFilePath, sourceLineNumber);
return this.Actions;
}
protected override async Task<DialogTurnResult> OnRunCommandAsync(DialogContext dc, object options = null, CancellationToken cancellationToken = default(CancellationToken))
{
if (dc is SequenceContext sc)
{
var planActions = Actions.Select(s => new ActionState()
@ -74,11 +78,5 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
var idList = Actions.Select(s => s.Id);
return $"{nameof(EditActions)}({this.ChangeType}|{string.Join(",", idList)})";
}
public override List<IDialog> ListDependencies()
{
return this.Actions;
}
}
}

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

@ -21,6 +21,10 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
/// </summary>
public class EditArray : DialogAction
{
private Expression value;
private Expression arrayProperty;
private Expression resultProperty;
public enum ArrayChangeType
{
/// <summary>
@ -49,10 +53,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
Clear
}
private Expression value;
private Expression arrayProperty;
private Expression resultProperty;
[JsonConstructor]
public EditArray([CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLine = 0)
: base()
@ -60,11 +60,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
this.RegisterSourceLocation(callerPath, callerLine);
}
protected override string OnComputeId()
{
return $"array[{ChangeType + ": " + ArrayProperty}]";
}
/// <summary>
/// Gets or sets type of change being applied
/// </summary>
@ -72,6 +67,11 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
[JsonProperty("changeType")]
public ArrayChangeType ChangeType { get; set; }
protected override string OnComputeId()
{
return $"array[{ChangeType + ": " + ArrayProperty}]";
}
/// <summary>
/// Gets or sets memory expression of the array to manipulate.
/// </summary>Edit
@ -142,7 +142,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
if (string.IsNullOrEmpty(ArrayProperty))
{
throw new Exception($"EditArray: \"{ ChangeType }\" operation couldn't be performed because the arrayProperty wasn't specified.");
throw new Exception($"EditArray: \"{ChangeType}\" operation couldn't be performed because the arrayProperty wasn't specified.");
}
var array = dc.State.GetValue<JArray>(this.arrayProperty, new JArray());
@ -217,6 +217,5 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
throw new Exception($"EditArray: \"{ChangeType}\" operation couldn't be performed for array \"{ArrayProperty}\" because a value wasn't specified.");
}
}
}
}

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

@ -16,9 +16,21 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
private const string eventValueProperty = "eventValue";
public string EventName { get; set; }
public object EventValue { get; set; }
public bool BubbleEvent { get; set; }
[JsonConstructor]
public EmitEvent(string eventName = null, object eventValue = null, bool bubble = true, [CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLine = 0)
: base()
{
this.RegisterSourceLocation(callerPath, callerLine);
this.EventName = eventName;
this.EventValue = EventValue;
this.BubbleEvent = bubble;
}
public string EventValueProperty
{
get
@ -27,6 +39,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
{
return InputBindings[eventValueProperty];
}
return string.Empty;
}
@ -50,16 +63,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
// }
//}
[JsonConstructor]
public EmitEvent(string eventName = null, object eventValue = null, bool bubble = true, [CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLine = 0)
: base()
{
this.RegisterSourceLocation(callerPath, callerLine);
this.EventName = eventName;
this.EventValue = EventValue;
this.BubbleEvent = bubble;
}
protected override async Task<DialogTurnResult> OnRunCommandAsync(DialogContext dc, object options = null, CancellationToken cancellationToken = default(CancellationToken))
{
if (options is CancellationToken)

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

@ -14,11 +14,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
/// </summary>
public class EndDialog : DialogAction
{
/// <summary>
/// Gets or sets the property to return as the result ending the dialog.
/// </summary>
public string ResultProperty { get; set; } = "dialog.result";
[JsonConstructor]
public EndDialog(string resultProperty = null, [CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLine = 0)
: base()
@ -31,6 +26,11 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
}
}
/// <summary>
/// Gets or sets the property to return as the result ending the dialog.
/// </summary>
public string ResultProperty { get; set; } = "dialog.result";
protected override async Task<DialogTurnResult> OnRunCommandAsync(DialogContext dc, object options = null, CancellationToken cancellationToken = default(CancellationToken))
{
if (options is CancellationToken)

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

@ -38,7 +38,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
throw new ArgumentException($"{nameof(options)} cannot be a cancellation token");
}
return Dialog.EndOfTurn;
}
}

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

@ -22,12 +22,19 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
{
private Expression listProperty;
[JsonConstructor]
public Foreach([CallerFilePath] string sourceFilePath = "", [CallerLineNumber] int sourceLineNumber = 0)
: base()
{
this.RegisterSourceLocation(sourceFilePath, sourceLineNumber);
}
// Expression used to compute the list that should be enumerated.
[JsonProperty("listProperty")]
public string ListProperty
{
get { return listProperty?.ToString(); }
set {this.listProperty = (value != null) ? new ExpressionEngine().Parse(value) : null; }
set { this.listProperty = (value != null) ? new ExpressionEngine().Parse(value) : null; }
}
// In-memory property that will contain the current items index. Defaults to `dialog.index`.
@ -42,11 +49,16 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
[JsonProperty("actions")]
public List<IDialog> Actions { get; set; } = new List<IDialog>();
[JsonConstructor]
public Foreach([CallerFilePath] string sourceFilePath = "", [CallerLineNumber] int sourceLineNumber = 0)
: base()
public override List<IDialog> ListDependencies()
{
this.RegisterSourceLocation(sourceFilePath, sourceLineNumber);
return this.Actions;
}
public class ForeachOptions
{
public Expression list { get; set; }
public int offset { get; set; }
}
protected override async Task<DialogTurnResult> OnRunCommandAsync(DialogContext dc, object options = null, CancellationToken cancellationToken = default(CancellationToken))
@ -111,6 +123,11 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
}
}
protected override string OnComputeId()
{
return $"{nameof(Foreach)}({this.ListProperty})";
}
private object GetItem(object list, int index)
{
JToken result = null;
@ -125,23 +142,8 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
{
result = ((JObject)list).SelectToken(index.ToString());
}
return result;
}
protected override string OnComputeId()
{
return $"{nameof(Foreach)}({this.ListProperty})";
}
public override List<IDialog> ListDependencies()
{
return this.Actions;
}
public class ForeachOptions
{
public Expression list { get; set; }
public int offset { get; set; }
}
}
}

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

@ -138,8 +138,10 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
}
}
}
return page;
}
protected override string OnComputeId()
{
return $"{nameof(Foreach)}({this.ListProperty})";
@ -153,7 +155,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
public class ForeachPageOptions
{
public Expression list { get; set; }
public int offset { get; set; }
public int pageSize { get; set; }
}
}

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

@ -17,7 +17,8 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
public class InitProperty : DialogAction
{
[JsonConstructor]
public InitProperty([CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLine = 0) : base()
public InitProperty([CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLine = 0)
: base()
{
this.RegisterSourceLocation(callerPath, callerLine);
}
@ -31,6 +32,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
{
return OutputBinding;
}
set
{
InputBindings[DialogContextState.DIALOG_VALUE] = value;
@ -50,7 +52,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
throw new ArgumentException($"{nameof(options)} cannot be a cancellation token");
}
// Ensure planning context
if (dc is SequenceContext planning)
{

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

@ -21,7 +21,8 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
private Expression property;
[JsonConstructor]
public SetProperty([CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLine = 0) : base()
public SetProperty([CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLine = 0)
: base()
{
this.RegisterSourceLocation(callerPath, callerLine);
}
@ -33,7 +34,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
public string Value
{
get { return value?.ToString(); }
set {this.value = (value != null) ? new ExpressionEngine().Parse(value) : null; }
set { this.value = (value != null) ? new ExpressionEngine().Parse(value) : null; }
}
/// <summary>

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

@ -82,7 +82,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
public string Condition
{
get { return condition?.ToString(); }
set {condition = (value != null) ? new ExpressionEngine().Parse(value) : null; }
set { condition = (value != null) ? new ExpressionEngine().Parse(value) : null; }
}
/// <summary>
@ -96,7 +96,8 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
public List<IDialog> Default { get; set; } = new List<IDialog>();
[JsonConstructor]
public SwitchCondition([CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLine = 0) : base()
public SwitchCondition([CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLine = 0)
: base()
{
this.RegisterSourceLocation(callerPath, callerLine);
}
@ -132,7 +133,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
foreach (var caseCondition in this.Cases)
{
var (value, error) = this.caseExpressions[caseCondition.Value].TryEvaluate(dc.State);
if (error != null)

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

@ -16,7 +16,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
/// </summary>
public class TraceActivity : DialogAction
{
/// <summary>
/// Name of the trace activity
/// </summary>

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

@ -19,7 +19,6 @@ using static Microsoft.Bot.Builder.Dialogs.Debugging.DebugSupport;
namespace Microsoft.Bot.Builder.Dialogs.Adaptive
{
/// <summary>
/// The Adaptive Dialog models conversation using events and events to adapt dynamicaly to changing conversation flow
/// </summary>
@ -230,6 +229,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive
handled = false;
}
}
break;
}
}
@ -457,7 +457,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive
},
Entities = JObject.Parse("{}")
};
}
}
@ -477,6 +476,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive
return true;
}
}
return false;
}
@ -521,6 +521,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive
Selector = new FirstSelector()
};
}
this.Selector.Initialize(this.Events, true);
}
}

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

@ -11,6 +11,5 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive
public class BotState : DialogState
{
public string LastAccess { get; set; }
}
}

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

@ -11,7 +11,6 @@ using Newtonsoft.Json.Linq;
namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Events
{
/// <summary>
/// Event triggered when a Activity of a given type is received
/// </summary>
@ -38,7 +37,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Events
protected override Expression BuildExpression(IExpressionParser factory)
{
// add constraints for activity type
return Expression.AndExpression(factory.Parse($"turn.dialogEvent.value.type == '{this.Type}'"),
base.BuildExpression(factory));
@ -62,5 +60,4 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Events
return $"{this.GetType().Name}({this.Type})[{this.Constraint}]";
}
}
}

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

@ -17,5 +17,4 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Events
public OnConversationUpdateActivity(List<IDialog> actions = null, string constraint= null, [CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLine = 0)
: base(type: ActivityTypes.ConversationUpdate, actions: actions, constraint: constraint, callerPath: callerPath, callerLine: callerLine) { }
}
}

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

@ -17,5 +17,4 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Events
public OnEndOfConversationActivity(List<IDialog> actions = null, string constraint= null, [CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLine = 0)
: base(type: ActivityTypes.EndOfConversation, actions: actions, constraint: constraint, callerPath: callerPath, callerLine: callerLine) { }
}
}

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

@ -120,7 +120,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Events
throw new Exception($"Invalid constraint expression: {this.Constraint}, {e.Message}");
}
}
}
/// <summary>
@ -134,7 +133,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Events
return await OnExecuteAsync(planningContext).ConfigureAwait(false);
}
/// <summary>
/// Method called to process the request to execute the actions
/// </summary>

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

@ -17,5 +17,4 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Events
public OnEventActivity(List<IDialog> actions = null, string constraint= null, [CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLine = 0)
: base(type: ActivityTypes.Event, actions: actions, constraint: constraint, callerPath: callerPath, callerLine: callerLine) { }
}
}

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

@ -17,5 +17,4 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Events
public OnHandoffActivity(List<IDialog> actions = null, string constraint= null, [CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLine = 0)
: base(type: ActivityTypes.Handoff, actions: actions, constraint: constraint, callerPath: callerPath, callerLine: callerLine) { }
}
}

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

@ -42,7 +42,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Events
protected override Expression BuildExpression(IExpressionParser factory)
{
// add constraints for the intents property
if (string.IsNullOrEmpty(this.Intent))
{

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

@ -17,5 +17,4 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Events
public OnInvokeActivity(List<IDialog> actions = null, string constraint= null, [CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLine = 0)
: base(type: ActivityTypes.Invoke, actions: actions, constraint: constraint, callerPath: callerPath, callerLine: callerLine) { }
}
}

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

@ -17,5 +17,4 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Events
public OnMessageActivity(List<IDialog> actions = null, string constraint= null, [CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLine = 0)
: base(type: ActivityTypes.Message, actions: actions, constraint: constraint, callerPath: callerPath, callerLine: callerLine) { }
}
}

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

@ -17,5 +17,4 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Events
public OnMessageDeleteActivity(List<IDialog> actions = null, string constraint= null, [CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLine = 0)
: base(type: ActivityTypes.MessageDelete, actions: actions, constraint: constraint, callerPath: callerPath, callerLine: callerLine) { }
}
}

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

@ -17,5 +17,4 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Events
public OnMessageReactionActivity(List<IDialog> actions = null, string constraint= null, [CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLine = 0)
: base(type: ActivityTypes.MessageReaction, actions: actions, constraint: constraint, callerPath: callerPath, callerLine: callerLine) { }
}
}

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

@ -17,5 +17,4 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Events
public OnMessageUpdateActivity(List<IDialog> actions = null, string constraint= null, [CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLine = 0)
: base(type: ActivityTypes.MessageUpdate, actions: actions, constraint: constraint, callerPath: callerPath, callerLine: callerLine) { }
}
}

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

@ -17,5 +17,4 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Events
public OnTypingActivity(List<IDialog> actions = null, string constraint= null, [CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLine = 0)
: base(type: ActivityTypes.Typing, actions: actions, constraint: constraint, callerPath: callerPath, callerLine: callerLine) { }
}
}

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

@ -201,7 +201,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input
}
catch
{
}
if (choices == null || choices.Count == 0)
@ -213,7 +212,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input
}
catch
{
}
}
}

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

@ -8,7 +8,6 @@ using Microsoft.Bot.Schema;
using Microsoft.Recognizers.Text.DateTime;
using static Microsoft.Recognizers.Text.Culture;
namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input
{
public class DateTimeInput : InputDialog

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

@ -104,6 +104,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input
{
return OutputBinding;
}
set
{
InputBindings[DialogContextState.DIALOG_VALUE] = value;
@ -312,6 +313,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input
{
return await this.InvalidPrompt.BindToData(dc.Context, dc.State).ConfigureAwait(false);
}
break;
case InputState.Invalid:
@ -323,8 +325,8 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input
{
return await this.UnrecognizedPrompt.BindToData(dc.Context, dc.State).ConfigureAwait(false);
}
break;
break;
}
return await this.Prompt.BindToData(dc.Context, dc.State);
@ -392,6 +394,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input
return InputState.Invalid;
}
}
return InputState.Valid;
}
else

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

@ -57,6 +57,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input
{
return OutputBinding;
}
set
{
InputBindings[DialogContextState.DIALOG_VALUE] = value;

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

@ -13,7 +13,8 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input
Trim,
Lowercase,
UpperCase
};
}
;
/// <summary>
/// Declarative text input to gather text data from users

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

@ -13,7 +13,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers
/// </summary>
public class MultiLanguageRecognizer : IRecognizer
{
/// <summary>
/// Policy for languages fallback
/// </summary>
@ -28,7 +27,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers
public MultiLanguageRecognizer()
{
}
public Task<RecognizerResult> RecognizeAsync(ITurnContext turnContext, CancellationToken cancellationToken)
@ -43,6 +41,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers
return recognizer.RecognizeAsync(turnContext, cancellationToken);
}
}
// nothing recognized
return Task.FromResult(new RecognizerResult() { });
}
@ -59,6 +58,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers
return recognizer.RecognizeAsync<T>(turnContext, cancellationToken);
}
}
// nothing recognized
return Task.FromResult(default(T));
}

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

@ -24,7 +24,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Selectors
public string Condition
{
get { return condition?.ToString(); }
set {this.condition = (value != null) ? new ExpressionEngine().Parse(value) : null; }
set { this.condition = (value != null) ? new ExpressionEngine().Parse(value) : null; }
}
/// <summary>
@ -58,6 +58,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Selectors
selector = IfFalse;
IfFalse.Initialize(_rules, _evaluate);
}
return await selector.Select(context, cancel).ConfigureAwait(false);
}
}

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

@ -47,11 +47,13 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Selectors
selection = 0;
}
}
var result = new List<int>();
if (selection != -1)
{
result.Add(selection);
}
return Task.FromResult((IReadOnlyList<int>)result);
}
}

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

@ -47,6 +47,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Selectors
matches.Add(pos);
}
}
selections = matches;
}
else
@ -59,11 +60,13 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Selectors
matches.Add((ValueTuple<int, IOnEvent>)trigger.Action);
}
}
// Sort rules by original order and then pass to child selector
matches = (from candidate in matches orderby candidate.Item1 ascending select candidate).ToList();
Selector.Initialize(matches.Select(m => m.Item2), false);
selections = (from match in await Selector.Select(context, cancel).ConfigureAwait(false) select matches[match].Item1).ToList();
}
return selections;
}
}

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

@ -64,12 +64,14 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Selectors
candidates.Add(i);
}
}
var result = new List<int>();
if (candidates.Count > 0)
{
var selection = _rand.Next(candidates.Count);
result.Add(candidates[selection]);
}
return Task.FromResult((IReadOnlyList<int>)result);
}
}

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

@ -44,6 +44,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Selectors
candidates.Add(i);
}
}
return Task.FromResult((IReadOnlyList<int>)candidates);
}
}

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

@ -101,6 +101,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive
{
this.Actions.Clear();
}
await EmitEventAsync(name: AdaptiveEvents.SequenceEnded, value: null, bubble: false).ConfigureAwait(false);
break;
case ActionChangeType.ReplaceSequence:
@ -108,6 +109,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive
{
this.Actions.Clear();
}
await UpdateSequenceAsync(change, cancellationToken).ConfigureAwait(false);
break;
}

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

@ -10,7 +10,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Composition.Recognizers
{
public BaseEntityRecognizer()
{
}
protected abstract List<ModelResult> Recognize(string text, string culture);
@ -35,6 +34,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Composition.Recognizers
}
}
}
return Task.FromResult((IList<Entity>)newEntities);
}
}

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

@ -6,7 +6,6 @@ using Microsoft.Bot.Schema;
namespace Microsoft.Bot.Builder.Dialogs.Composition.Recognizers
{
/// <summary>
/// EntityRecognizerSet - Implements a workflow against a pool of IEntityRecognizer instances, iterating until nobody has anything new to add.
/// </summary>
@ -45,7 +44,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Composition.Recognizers
{
try
{
// get new entities
var newEntities = await recognizer.RecognizeEntities(turnContext, entitiesToProcess).ConfigureAwait(false);
@ -70,7 +68,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Composition.Recognizers
// switch to next pool of new entities to process
entitiesToProcess = newEntitiesToProcess;
} while (entitiesToProcess.Count > 0);
return allNewEntities;

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

@ -9,7 +9,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Composition
/// </summary>
public interface IEntityRecognizer
{
/// <summary>
/// RecognizerEntities() - given a pool of entities and context add additional entities
/// </summary>

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

@ -11,7 +11,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Composition.Recognizers
{
public OrdinalEntityRecognizer()
{
}
protected override List<ModelResult> Recognize(string text, string culture)

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

@ -5,8 +5,12 @@ namespace Microsoft.Bot.Builder.Dialogs.Composition.Recognizers
public class TextEntity : Entity
{
public const string TypeName = "Text";
public TextEntity() : base(TypeName) { }
public TextEntity(string text) : base(TypeName)
public TextEntity()
: base(TypeName) { }
public TextEntity(string text)
: base(TypeName)
{
Text = text;
}

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

@ -8,6 +8,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging
public interface ICodeModel
{
string NameFor(object item);
IReadOnlyList<ICodePoint> PointsFor(DialogContext dialogContext, object item, string more);
}
@ -58,9 +59,13 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging
public interface ICodePoint
{
object Item { get; }
string More { get; }
string Name { get; }
object Data { get; }
object Evaluate(string expression);
}
@ -75,11 +80,15 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging
}
private ICodeModel CodeModel { get; }
private DialogContext DialogContext { get; }
public object Item { get; }
public string More { get; }
public string Name => CodeModel.NameFor(Item) + (More != null ? ":" + More : string.Empty);
public object Data
{
get

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

@ -16,6 +16,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging
public Coercion()
{
}
object ICoercion.Coerce(object source, Type target)
{
var token = source as JToken;

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

@ -12,130 +12,189 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging
get;
set;
}
int Rank { get; }
bool IsScalar(object context);
IEnumerable<object> Names(object context);
string ToString(object context);
}
public sealed class NullDataModel : IDataModel
{
public static readonly IDataModel Instance = new NullDataModel();
private NullDataModel()
{
}
object IDataModel.this[object context, object name] { get => throw new NotSupportedException(); set => throw new NotSupportedException(); }
int IDataModel.Rank => 0;
bool IDataModel.IsScalar(object context) => true;
IEnumerable<object> IDataModel.Names(object context) => Enumerable.Empty<object>();
string IDataModel.ToString(object context) => "null";
}
public sealed class ScalarDataModel : IDataModel
{
public static readonly IDataModel Instance = new ScalarDataModel();
private ScalarDataModel()
{
}
object IDataModel.this[object context, object name] { get => throw new NotSupportedException(); set => throw new NotSupportedException(); }
int IDataModel.Rank => 1;
bool IDataModel.IsScalar(object context) => true;
IEnumerable<object> IDataModel.Names(object context) => Enumerable.Empty<object>();
string IDataModel.ToString(object context) => context.ToString();
}
public abstract class DataModelBase<Context, Name, Value> : IDataModel
{
private readonly ICoercion coercion;
protected DataModelBase(ICoercion coercion)
{
this.coercion = coercion ?? throw new ArgumentNullException(nameof(coercion));
}
protected T Coerce<T>(object item) => (T)this.coercion.Coerce(item, typeof(T));
public abstract int Rank { get; }
public abstract Value this[Context context, Name name]
{
get;
set;
}
public virtual bool IsScalar(Context context) => false;
public abstract IEnumerable<Name> Names(Context context);
public virtual string ToString(Context context) => (context is ICollection collection)
? $"Count = {collection.Count}"
: context.ToString();
object IDataModel.this[object context, object name]
{
get => this[(Context)context, Coerce<Name>(name)];
set => this[(Context)context, Coerce<Name>(name)] = Coerce<Value>(value);
}
bool IDataModel.IsScalar(object context) => IsScalar((Context)context);
string IDataModel.ToString(object context) => ToString((Context)context);
IEnumerable<object> IDataModel.Names(object context) => Names((Context)context).Cast<object>();
}
public sealed class DictionaryDataModel<K, V> : DataModelBase<IDictionary<K, V>, K, V>
{
public DictionaryDataModel(ICoercion coercion) : base(coercion) { }
public DictionaryDataModel(ICoercion coercion)
: base(coercion) { }
public override int Rank => 6;
public override V this[IDictionary<K, V> context, K name]
{
get => context[name];
set => context[name] = value;
}
public override IEnumerable<K> Names(IDictionary<K, V> context) => context.Keys;
}
public sealed class ReadOnlyDictionaryDataModel<K, V> : DataModelBase<IReadOnlyDictionary<K, V>, K, V>
{
public ReadOnlyDictionaryDataModel(ICoercion coercion) : base(coercion) { }
public ReadOnlyDictionaryDataModel(ICoercion coercion)
: base(coercion) { }
public override int Rank => 5;
public override V this[IReadOnlyDictionary<K, V> context, K name]
{
get => context[name];
set => throw new NotSupportedException();
}
public override IEnumerable<K> Names(IReadOnlyDictionary<K, V> context) => context.Keys;
}
public sealed class ListDataModel<T> : DataModelBase<IList<T>, int, T>
{
public ListDataModel(ICoercion coercion) : base(coercion) { }
public ListDataModel(ICoercion coercion)
: base(coercion) { }
public override int Rank => 4;
public override T this[IList<T> context, int name]
{
get => context[name];
set => context[name] = value;
}
public override IEnumerable<int> Names(IList<T> context) => Enumerable.Range(0, context.Count);
}
public sealed class EnumerableDataModel<T> : DataModelBase<IEnumerable<T>, int, T>
{
public EnumerableDataModel(ICoercion coercion) : base(coercion) { }
public EnumerableDataModel(ICoercion coercion)
: base(coercion) { }
public override int Rank => 3;
public override T this[IEnumerable<T> context, int name]
{
get => context.ElementAt(name);
set => throw new NotSupportedException();
}
public override IEnumerable<int> Names(IEnumerable<T> context) => context.Select((_, index) => index);
}
public sealed class ReflectionDataModel<T> : DataModelBase<object, string, object>
{
public ReflectionDataModel(ICoercion coercion) : base(coercion) { }
public ReflectionDataModel(ICoercion coercion)
: base(coercion) { }
public override int Rank => 2;
public override object this[object context, string name]
{
get => context.GetType().GetProperty(name).GetValue(context);
set => context.GetType().GetProperty(name).SetValue(context, value);
}
public override IEnumerable<string> Names(object context) =>
context.GetType().GetProperties().Where(p => p.GetIndexParameters().Length == 0).Select(p => p.Name);
}
public sealed class DataModel : IDataModel
{
private readonly ICoercion coercion;
public DataModel(ICoercion coercion)
{
this.coercion = coercion ?? throw new ArgumentNullException(nameof(coercion));
}
private readonly Dictionary<Type, IDataModel> modelByType = new Dictionary<Type, IDataModel>();
private IDataModel Create(Type definition, params Type[] typeArguments) =>
(IDataModel)Activator.CreateInstance(definition.MakeGenericType(typeArguments), this.coercion);
private IEnumerable<IDataModel> Options(Type type)
{
if (type.IsPrimitive || type == typeof(string))
@ -175,6 +234,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging
yield return Create(typeof(ReflectionDataModel<>), type);
}
}
private IDataModel ModelFor(object context)
{
if (context == null)
@ -192,14 +252,19 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging
return model;
}
int IDataModel.Rank => int.MaxValue;
object IDataModel.this[object context, object name]
{
get => ModelFor(context)[context, name];
set => ModelFor(context)[context, name] = value;
}
bool IDataModel.IsScalar(object context) => ModelFor(context).IsScalar(context);
IEnumerable<object> IDataModel.Names(object context) => ModelFor(context).Names(context);
string IDataModel.ToString(object context) => ModelFor(context).ToString(context);
}
}

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

@ -37,15 +37,25 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging
TurnContext = turnContext;
CodeModel = codeModel;
}
public ITurnContext TurnContext { get; }
public ICodeModel CodeModel { get; }
public string Name => TurnContext.Activity.Text;
public IReadOnlyList<ICodePoint> Frames => CodeModel.PointsFor(LastContext, LastItem, LastMore);
public RunModel Run { get; } = new RunModel();
public Identifier<ICodePoint> FrameCodes { get; } = new Identifier<ICodePoint>();
public Identifier<object> ValueCodes { get; } = new Identifier<object>();
public DialogContext LastContext { get; set; }
public object LastItem { get; set; }
public string LastMore { get; set; }
}
@ -54,7 +64,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging
public sealed class RunModel
{
public Phase? PhaseSent { get; set; }
public Phase Phase { get; set; } = Phase.Started;
public object Gate { get; } = new object();
public void Post(Phase what)
@ -327,6 +339,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging
}
private int sequence = 0;
private int NextSeq => Interlocked.Increment(ref sequence);
private Protocol.Capabilities MakeCapabilities()

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

@ -35,7 +35,5 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging
dataModel: dataModel,
logger: logger));
}
}
}

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

@ -11,10 +11,12 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging
public struct Releaser : IDisposable
{
public SemaphoreSlim Semaphore { get; }
public Releaser(SemaphoreSlim semaphore)
{
Semaphore = semaphore ?? throw new ArgumentNullException(nameof(semaphore));
}
public void Dispose()
{
Semaphore.Release();

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

@ -10,10 +10,13 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging
public sealed class ReferenceEquality<T> : IEqualityComparer<T>
{
public static readonly IEqualityComparer<T> Instance = new ReferenceEquality<T>();
private ReferenceEquality()
{
}
bool IEqualityComparer<T>.Equals(T x, T y) => object.ReferenceEquals(x, y);
int IEqualityComparer<T>.GetHashCode(T obj) => RuntimeHelpers.GetHashCode(obj);
}
@ -21,6 +24,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging
{
private const ulong MORE = 0x80;
private const ulong DATA = 0x7F;
private static void Encode(ulong source, ref ulong target, ref int offset)
{
while (source > DATA)
@ -37,6 +41,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging
offset += 8;
}
}
private static void Decode(ref ulong source, out ulong target)
{
target = 0;
@ -55,6 +60,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging
offset += 7;
}
}
public static ulong Encode(ulong one, ulong two)
{
ulong target = 0;
@ -102,6 +108,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging
return code;
}
}
public void Remove(T item)
{
lock (gate)
@ -143,6 +150,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging
}
}
}
public ulong this[T item]
{
get

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

@ -16,7 +16,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging
public abstract class Message
{
public int seq { get; set; }
public string type { get; set; }
[JsonExtensionData]
public JObject Rest { get; set; }
}
@ -24,6 +26,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging
public class Request : Message
{
public string command { get; set; }
public override string ToString() => command;
}
@ -31,108 +34,153 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging
{
public Arguments arguments { get; set; }
}
public class Attach
{
}
public class Launch
{
}
public class Initialize
{
public string clientID { get; set; }
public string clientName { get; set; }
public string adapterID { get; set; }
public string pathFormat { get; set; }
public bool linesStartAt1 { get; set; }
public bool columnsStartAt1 { get; set; }
public bool supportsVariableType { get; set; }
public bool supportsVariablePaging { get; set; }
public bool supportsRunInTerminalRequest { get; set; }
public string locale { get; set; }
}
public class SetBreakpoints
{
public Source source { get; set; }
public SourceBreakpoint[] breakpoints { get; set; }
public bool sourceModified { get; set; }
}
public class SetFunctionBreakpoints
{
public FunctionBreakpoint[] breakpoints { get; set; }
}
public class SetExceptionBreakpoints
{
public string[] filters { get; set; }
}
public class Threads
{
}
public class Capabilities
{
public bool supportsConfigurationDoneRequest { get; set; }
public bool supportsSetVariable { get; set; }
public bool supportsEvaluateForHovers { get; set; }
public bool supportsFunctionBreakpoints { get; set; }
public ExceptionBreakpointFilter[] exceptionBreakpointFilters { get; set; }
public bool supportTerminateDebuggee { get; set; }
public bool supportsTerminateRequest { get; set; }
}
public class ExceptionBreakpointFilter
{
public string filter { get; set; }
public string label { get; set; }
public bool @default { get; set; }
}
public abstract class PerThread
{
public ulong threadId { get; set; }
}
public class StackTrace : PerThread
{
public int? startFrame { get; set; }
public int? levels { get; set; }
}
public class Continue : PerThread
{
}
public class Pause : PerThread
{
}
public class Next : PerThread
{
}
public class Scopes
{
public ulong frameId { get; set; }
}
public class Variables
{
public ulong variablesReference { get; set; }
}
public class SetVariable
{
public ulong variablesReference { get; set; }
public string name { get; set; }
public string value { get; set; }
}
public class Evaluate
{
public ulong frameId { get; set; }
public string expression { get; set; }
}
public class ConfigurationDone
{
}
public class Disconnect
{
public bool restart { get; set; }
public bool terminateDebuggee { get; set; }
}
public class Terminate
{
public bool restart { get; set; }
}
public class Event : Message
{
public Event(int seq, string @event)
@ -141,15 +189,19 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging
this.type = "event";
this.@event = @event;
}
public string @event { get; set; }
public static Event<Body> From<Body>(int seq, string @event, Body body) => new Event<Body>(seq, @event) { body = body };
}
public class Event<Body> : Event
{
public Event(int seq, string @event)
: base(seq, @event)
{
}
public Body body { get; set; }
}
@ -163,11 +215,17 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging
this.success = true;
this.command = request.command;
}
public int request_seq { get; set; }
public bool success { get; set; }
public string message { get; set; }
public string command { get; set; }
public static Response<Body> From<Body>(int seq, Request request, Body body) => new Response<Body>(seq, request) { body = body };
public static Response<string> Fail(int seq, Request request, string message) => new Response<string>(seq, request) { body = message, message = message, success = false };
}
@ -177,6 +235,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging
: base(seq, request)
{
}
public Body body { get; set; }
}
@ -188,15 +247,20 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging
public class Range : Reference
{
public Source source { get; set; }
public int? line { get; set; }
public int? column { get; set; }
public int? endLine { get; set; }
public int? endColumn { get; set; }
}
public class Breakpoint : Range
{
public bool verified { get; set; }
public string message { get; set; }
}
@ -219,12 +283,15 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging
}
public string name { get; set; }
public string path { get; set; }
}
public sealed class SourceBreakpoint
{
public int line { get; set; }
}
public sealed class FunctionBreakpoint
{
public string name { get; set; }
@ -259,6 +326,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging
case "disconnect": return token.ToObject<Request<Disconnect>>();
default: return token.ToObject<Request>();
}
default:
throw new NotImplementedException();
}

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

@ -9,9 +9,13 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging
public interface IBreakpoints
{
bool IsBreakPoint(object item);
object ItemFor(Protocol.Breakpoint breakpoint);
IReadOnlyList<Protocol.Breakpoint> SetBreakpoints(Protocol.Source source, IReadOnlyList<Protocol.SourceBreakpoint> sourceBreakpoints);
IReadOnlyList<Protocol.Breakpoint> SetBreakpoints(IReadOnlyList<Protocol.FunctionBreakpoint> functionBreakpoints);
IReadOnlyList<Protocol.Breakpoint> ApplyUpdates();
}
@ -64,14 +68,20 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging
Source = source;
SourceBreakpoint = sourceBreakpoint;
}
public Row(Protocol.FunctionBreakpoint functionBreakpoint)
{
FunctionBreakpoint = functionBreakpoint;
}
public Protocol.Source Source { get; }
public Protocol.SourceBreakpoint SourceBreakpoint { get; }
public Protocol.FunctionBreakpoint FunctionBreakpoint { get; }
public Protocol.Breakpoint Breakpoint { get; } = new Protocol.Breakpoint();
public object item { get; set; }
}

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

@ -32,6 +32,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Declarative.Converters
Text = (string)reader.Value
};
}
return JToken.Load(reader).ToObject<Activity>();
}

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

@ -23,6 +23,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Declarative.Converters
{
return new ExpressionEngine().Parse((string)reader.Value);
}
throw new JsonSerializationException("Expected string expression.");
}
@ -31,5 +32,4 @@ namespace Microsoft.Bot.Builder.Dialogs.Declarative.Converters
serializer.Serialize(writer, value);
}
}
}

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

@ -15,7 +15,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Declarative.Converters
{
public class LanguageGeneratorConverter : InterfaceConverter<ILanguageGenerator>
{
public LanguageGeneratorConverter(IRefResolver refResolver, Source.IRegistry registry, Stack<string> paths)
: base(refResolver, registry, paths)
{ }
@ -27,6 +26,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Declarative.Converters
string readerValue = reader.Value.ToString();
return TypeFactory.Build<ILanguageGenerator>("DefaultLanguageGenerator", readerValue, serializer);
}
return base.ReadJson(reader, objectType, existingValue, serializer);
}
}

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

@ -88,9 +88,11 @@ namespace Microsoft.Bot.Builder.Dialogs.Declarative
{
path = path.Substring(9);
}
// just use configurations ability to query for x:y:z
value = ConfigurationBinder.GetValue<string>(configuration, path);
}
return value;
}
}

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

@ -6,8 +6,11 @@ namespace Microsoft.Bot.Builder.Dialogs.Declarative.Plugins
public class FileDependencyInfo
{
public string AssemblyPath { get; set; }
public string SchemaUri { get; set; }
public string ClassName { get; set; }
public string CustomLoaderClassName { get; set; }
}
}

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

@ -10,8 +10,11 @@ namespace Microsoft.Bot.Builder.Dialogs.Declarative.Plugins
public interface IPlugin
{
string SchemaUri { get; }
Type Type { get; }
ICustomDeserializer Loader { get; }
Task Load();
}
}

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

@ -53,12 +53,14 @@ namespace Microsoft.Bot.Builder.Dialogs.Declarative.Resolvers
JObject targetProperty = json[prop.Name] as JObject;
targetProperty.Merge(prop.Value);
}
// JToken is an object, so we merge objects
else if (json[prop.Name] != null && json[prop.Name].Type == JTokenType.Array)
{
JArray targetArray = json[prop.Name] as JArray;
targetArray.Merge(prop.Value);
}
// JToken is a value, simply assign
else
{
@ -84,6 +86,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Declarative.Resolvers
{
return token.Value<string>();
}
// Else try to get a reference from the token
return token?
.Children<JProperty>()

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

@ -73,12 +73,14 @@ namespace Microsoft.Bot.Builder.Dialogs.Declarative.Resolvers
JObject targetProperty = json[prop.Name] as JObject;
targetProperty.Merge(prop.Value);
}
// JToken is an object, so we merge objects
else if (json[prop.Name] != null && json[prop.Name].Type == JTokenType.Array)
{
JArray targetArray = json[prop.Name] as JArray;
targetArray.Merge(prop.Value);
}
// JToken is a value, simply assign
else
{

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

@ -71,6 +71,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Declarative.Resources
return await textReader.ReadToEndAsync().ConfigureAwait(false);
});
}
return this.textTask;
}

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

@ -11,7 +11,6 @@ using System.Threading.Tasks;
namespace Microsoft.Bot.Builder.Dialogs.Declarative.Resources
{
/// <summary>
/// Folder/FileResources
/// </summary>
@ -129,7 +128,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Declarative.Resources
}
}
/// <summary>
/// GetResource by id
/// </summary>
@ -169,7 +167,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Declarative.Resources
public static class FolderResourceProviderExtensions
{
/// <summary>
/// Add a folder resource
/// </summary>
@ -211,8 +208,8 @@ namespace Microsoft.Bot.Builder.Dialogs.Declarative.Resources
{
explorer.AddFolder(folder, includeSubFolders: true, monitorChanges: monitorChanges);
}
return explorer;
}
}
}

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

@ -24,6 +24,5 @@ namespace Microsoft.Bot.Builder.Dialogs.Declarative.Resources
/// </summary>
/// <returns></returns>
Task<Stream> OpenStreamAsync();
}
}

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

@ -95,6 +95,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Declarative.Resources
throw new ArgumentNullException(nameof(projectFile));
}
}
string projectFolder = Path.GetDirectoryName(projectFile);
XmlDocument xmlDoc = new XmlDocument();
@ -121,6 +122,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Declarative.Resources
explorer.AddResourceProvider(new FolderResourceProvider(path, includeSubFolders: true, monitorChanges: monitorChanges));
}
}
var packages = Path.GetFullPath("packages");
var relativePackagePath = Path.Combine(@"..", "packages");
while (!Directory.Exists(packages) && Path.GetDirectoryName(packages) != Path.GetPathRoot(packages))
@ -131,6 +133,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Declarative.Resources
throw new ArgumentNullException("Can't find packages folder");
}
}
var pathResolver = new PackagePathResolver(packages);
// add nuget package references
@ -184,6 +187,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Declarative.Resources
return resource;
}
}
return null;
}

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

@ -77,6 +77,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Declarative.Types
{
throw new ArgumentException($"Type {name} not registered in factory.");
}
var found = builders.TryGetValue(type, out builder);
if (!found)

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

@ -29,6 +29,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Declarative.Types
{
return type;
}
return base.BindToType(assemblyName, typeName);
}
}

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

@ -100,15 +100,6 @@ namespace Microsoft.Bot.Builder.Dialogs
}
}
protected async Task EnsureInitialized(DialogContext outerDc)
{
if (!this.initialized)
{
this.initialized = true;
await OnInitialize(outerDc).ConfigureAwait(false);
}
}
public override async Task<DialogTurnResult> ResumeDialogAsync(DialogContext outerDc, DialogReason reason, object result = null, CancellationToken cancellationToken = default(CancellationToken))
{
if (result is CancellationToken)
@ -184,26 +175,13 @@ namespace Microsoft.Bot.Builder.Dialogs
return childDc;
}
private DialogContext CreateInnerDc(ITurnContext context, DialogInstance instance, IDictionary<string, object> userState, IDictionary<string, object> conversationState)
protected async Task EnsureInitialized(DialogContext outerDc)
{
DialogState state;
if (instance.State.ContainsKey(PersistedDialogState))
if (!this.initialized)
{
state = instance.State[PersistedDialogState] as DialogState;
this.initialized = true;
await OnInitialize(outerDc).ConfigureAwait(false);
}
else
{
state = new DialogState();
instance.State[PersistedDialogState] = state;
}
if (state.DialogStack == null)
{
state.DialogStack = new List<DialogInstance>();
}
return new DialogContext(this._dialogs, context, state, conversationState, userState);
}
protected virtual Task OnInitialize(DialogContext dc)
@ -245,5 +223,27 @@ namespace Microsoft.Bot.Builder.Dialogs
{
return $"component[{this.BindingPath()}]";
}
private DialogContext CreateInnerDc(ITurnContext context, DialogInstance instance, IDictionary<string, object> userState, IDictionary<string, object> conversationState)
{
DialogState state;
if (instance.State.ContainsKey(PersistedDialogState))
{
state = instance.State[PersistedDialogState] as DialogState;
}
else
{
state = new DialogState();
instance.State[PersistedDialogState] = state;
}
if (state.DialogStack == null)
{
state.DialogStack = new List<DialogInstance>();
}
return new DialogContext(this._dialogs, context, state, conversationState, userState);
}
}
}

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

@ -6,7 +6,6 @@ using Microsoft.Extensions.Configuration;
namespace Microsoft.Bot.Builder.Dialogs
{
public static class Configuration
{
/// <summary>

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

@ -10,13 +10,13 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging
{
public static partial class DebugSupport
{
public static IRegistry SourceRegistry { get; set; } = NullRegistry.Instance;
public interface IDebugger
{
Task StepAsync(DialogContext context, object item, string more, CancellationToken cancellationToken);
}
public static IRegistry SourceRegistry { get; set; } = NullRegistry.Instance;
public static IDebugger GetDebugger(this ITurnContext context) =>
context.TurnState.Get<IDebugger>() ?? NullDebugger.Instance;

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

@ -13,6 +13,10 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging
{
public struct Point
{
public int LineIndex { get; set; }
public int CharIndex { get; set; }
public static Point From(JsonReader reader)
=> (reader is IJsonLineInfo info)
? new Point() { LineIndex = info.LineNumber, CharIndex = info.LinePosition }
@ -34,13 +38,16 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging
return item;
}
public int LineIndex { get; set; }
public int CharIndex { get; set; }
public override string ToString() => $"{LineIndex}:{CharIndex}";
}
public interface IRegistry
{
void Add(object item, Range range);
bool TryGetValue(object item, out Range range);
}
public sealed class Range
{
public string Path { get; set; }
@ -52,13 +59,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging
public override string ToString() => $"{System.IO.Path.GetFileName(Path)}:{Start}->{After}";
}
public interface IRegistry
{
void Add(object item, Range range);
bool TryGetValue(object item, out Range range);
}
public sealed class NullRegistry : IRegistry
{
public static readonly IRegistry Instance = new NullRegistry();

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

@ -20,6 +20,8 @@ namespace Microsoft.Bot.Builder.Dialogs
private IBotTelemetryClient _telemetryClient;
private string id;
/// <summary>
/// Initializes a new instance of the <see cref="Dialog"/> class.
/// Called from constructors in derived classes to initialize the <see cref="Dialog"/> class.
@ -31,8 +33,6 @@ namespace Microsoft.Bot.Builder.Dialogs
_telemetryClient = NullBotTelemetryClient.Instance;
}
private string id;
/// <summary>
/// Unique id for the dialog.
/// </summary>

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

@ -480,6 +480,7 @@ namespace Microsoft.Bot.Builder.Dialogs
await EndActiveDialogAsync(DialogReason.ReplaceCalled, cancellationToken: cancellationToken).ConfigureAwait(false);
this.State.Turn["__repeatDialogId"] = dialogId;
// Start replacement dialog
return await BeginDialogAsync(dialogId, options, cancellationToken).ConfigureAwait(false);
}

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

@ -13,24 +13,9 @@ using Newtonsoft.Json.Serialization;
namespace Microsoft.Bot.Builder.Dialogs
{
/// <summary>
/// Defines the shape of the state object returned by calling DialogContext.State.ToJson()
/// </summary>
public class DialogContextVisibleState
{
[JsonProperty(PropertyName = "user")]
public IDictionary<string, object> User { get; set; }
[JsonProperty(PropertyName = "conversation")]
public IDictionary<string, object> Conversation { get; set; }
[JsonProperty(PropertyName = "dialog")]
public IDictionary<string, object> Dialog { get; set; }
}
public class DialogContextState : IDictionary<string, object>
{
private const string prefixCallBack = "callstackScope('";
private const string PrefixCallBack = "callstackScope('";
private static JsonSerializerSettings expressionCaseSettings = new JsonSerializerSettings
{
@ -40,15 +25,6 @@ namespace Microsoft.Bot.Builder.Dialogs
private readonly DialogContext dialogContext;
public DialogContextState(DialogContext dc, IDictionary<string, object> settings, IDictionary<string, object> userState, IDictionary<string, object> conversationState, IDictionary<string, object> turnState)
{
this.dialogContext = dc ?? throw new ArgumentNullException(nameof(dc));
this.Settings = settings;
this.User = userState;
this.Conversation = conversationState;
this.Turn = turnState;
}
/// <summary>
/// Common state properties paths.
/// </summary>
@ -64,6 +40,15 @@ namespace Microsoft.Bot.Builder.Dialogs
public const string STEP_OPTIONS_PROPERTY = "dialog.step.options";
public DialogContextState(DialogContext dc, IDictionary<string, object> settings, IDictionary<string, object> userState, IDictionary<string, object> conversationState, IDictionary<string, object> turnState)
{
this.dialogContext = dc ?? throw new ArgumentNullException(nameof(dc));
this.Settings = settings;
this.User = userState;
this.Conversation = conversationState;
this.Turn = turnState;
}
/// <summary>
/// Gets or sets settings for the application.
/// </summary>
@ -319,10 +304,10 @@ namespace Microsoft.Bot.Builder.Dialogs
}
var e = pathExpression.ToString();
if (e.StartsWith(prefixCallBack))
if (e.StartsWith(PrefixCallBack))
{
// turn $foo which comes in as callbackStack('foo') => dialog.foo
pathExpression = new ExpressionEngine().Parse($"dialog.{e.Substring(prefixCallBack.Length, e.Length - prefixCallBack.Length - 2)}");
pathExpression = new ExpressionEngine().Parse($"dialog.{e.Substring(PrefixCallBack.Length, e.Length - PrefixCallBack.Length - 2)}");
}
ObjectPath.SetValue(this, pathExpression, value);
@ -424,4 +409,19 @@ namespace Microsoft.Bot.Builder.Dialogs
throw new NotImplementedException();
}
}
/// <summary>
/// Defines the shape of the state object returned by calling DialogContext.State.ToJson()
/// </summary>
public class DialogContextVisibleState
{
[JsonProperty(PropertyName = "user")]
public IDictionary<string, object> User { get; set; }
[JsonProperty(PropertyName = "conversation")]
public IDictionary<string, object> Conversation { get; set; }
[JsonProperty(PropertyName = "dialog")]
public IDictionary<string, object> Dialog { get; set; }
}
}

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

@ -148,7 +148,7 @@ namespace Microsoft.Bot.Builder.Dialogs
{
await storage.WriteAsync(new Dictionary<string, object>()
{
{ keys.UserState, newState.UserState},
{ keys.UserState, newState.UserState },
{ keys.ConversationState, newState.ConversationState },
{ keys.DialogState, newState.DialogStack },
}).ConfigureAwait(false);

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

@ -8,14 +8,14 @@ using Microsoft.Bot.Schema;
namespace Microsoft.Bot.Builder.Dialogs
{
class DialogManagerAdapter : BotAdapter
public class DialogManagerAdapter : BotAdapter
{
public readonly List<Activity> Activities = new List<Activity>();
public DialogManagerAdapter()
{
}
public readonly List<Activity> Activities = new List<Activity>();
public override Task<ResourceResponse[]> SendActivitiesAsync(ITurnContext turnContext, Activity[] activities, CancellationToken cancellationToken)
{
this.Activities.AddRange(activities);

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

@ -91,7 +91,6 @@ namespace Microsoft.Bot.Builder.Dialogs
/// <returns></returns>
Task EndDialogAsync(ITurnContext turnContext, DialogInstance instance, DialogReason reason, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Called when an event has been raised, using `DialogContext.emitEvent()`, by either the current dialog or a dialog that the current dialog started.
/// </summary>

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

@ -8,7 +8,9 @@ namespace Microsoft.Bot.Builder.Dialogs
public class StoredBotState
{
public IDictionary<string, object> UserState { get; set; }
public IDictionary<string, object> ConversationState { get; set; }
public IList<DialogInstance> DialogStack { get; set; }
}
}

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

@ -6,7 +6,6 @@ using Microsoft.Bot.Schema;
namespace Microsoft.Bot.Builder.Dialogs
{
/// <summary>
/// Defines an activity Template where the template expression is local aka "inline".
/// </summary>

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

@ -7,6 +7,5 @@ namespace Microsoft.Bot.Builder.Dialogs
/// </summary>
public interface IActivityTemplate : ITemplate<Activity>
{
}
}

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

@ -5,6 +5,5 @@
/// </summary>
public interface ITextTemplate : ITemplate<string>
{
}
}

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

@ -5,7 +5,6 @@ using Microsoft.Bot.Schema;
namespace Microsoft.Bot.Builder.Dialogs
{
/// <summary>
/// Defins a static activity as a template.
/// </summary>

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

@ -127,7 +127,7 @@ namespace Microsoft.Bot.Builder.Dialogs
}
}
if (!String.IsNullOrEmpty(line))
if (!string.IsNullOrEmpty(line))
{
var i = line.IndexOf("||");
if (i > 0)
@ -155,78 +155,7 @@ namespace Microsoft.Bot.Builder.Dialogs
return activity;
}
private async Task AddAttachment(ITurnContext turnContext, ILanguageGenerator languageGenerator, IMessageActivity activity, string line, object data)
{
var parts = line.Split('=');
if (parts.Length == 1)
{
throw new ArgumentOutOfRangeException($"Missing = seperator in {line}");
}
var value = parts[1].TrimEnd(']').Trim();
var parts2 = value.Split(' ');
var contentUrl = parts2[0];
var attachment = new Attachment(contentUrl: contentUrl);
if (parts2.Length == 2)
{
switch (parts2[1].ToLower())
{
case "animation":
attachment.ContentType = AnimationCard.ContentType;
attachment.Content = await readAttachmentFile(turnContext, languageGenerator, contentUrl, attachment.ContentType, isCard: true, data: data).ConfigureAwait(false);
break;
case "audio":
attachment.ContentType = AudioCard.ContentType;
attachment.Content = await readAttachmentFile(turnContext, languageGenerator, contentUrl, attachment.ContentType, isCard: true, data: data).ConfigureAwait(false);
break;
case "hero":
attachment.ContentType = HeroCard.ContentType;
attachment.Content = await readAttachmentFile(turnContext, languageGenerator, contentUrl, attachment.ContentType, isCard: true, data: data).ConfigureAwait(false);
break;
case "receipt":
attachment.ContentType = ReceiptCard.ContentType;
attachment.Content = await readAttachmentFile(turnContext, languageGenerator, contentUrl, attachment.ContentType, isCard: true, data: data).ConfigureAwait(false);
break;
case "thumbnail":
attachment.ContentType = ThumbnailCard.ContentType;
attachment.Content = await readAttachmentFile(turnContext, languageGenerator, contentUrl, attachment.ContentType, isCard: true, data: data).ConfigureAwait(false);
break;
case "signin":
attachment.ContentType = SigninCard.ContentType;
attachment.Content = await readAttachmentFile(turnContext, languageGenerator, contentUrl, attachment.ContentType, isCard: true, data: data).ConfigureAwait(false);
break;
case "video":
attachment.ContentType = VideoCard.ContentType;
attachment.Content = await readAttachmentFile(turnContext, languageGenerator, contentUrl, attachment.ContentType, isCard: true, data: data).ConfigureAwait(false);
break;
case "adaptivecard":
attachment.ContentType = "application/vnd.microsoft.card.adaptive";
attachment.Content = await readAttachmentFile(turnContext, languageGenerator, contentUrl, attachment.ContentType, isCard: true, data: data).ConfigureAwait(false);
break;
default:
attachment.ContentType = parts2[1].Trim();
attachment.Content = await readAttachmentFile(turnContext, languageGenerator, contentUrl, attachment.ContentType, isCard: false, data: data).ConfigureAwait(false);
break;
}
}
if (attachment.Content != null && attachment.Content is string && ((string)attachment.Content).StartsWith("data:"))
{
attachment.ContentUrl = (string)attachment.Content;
attachment.Content = null;
}
if (attachment.Content != null)
{
// if we are sending content, then no need for contentUrl
attachment.ContentUrl = null;
}
activity.Attachments.Add(attachment);
}
protected async Task<object> readAttachmentFile(ITurnContext turnContext, ILanguageGenerator languageGenerator, string fileLocation, string contentType, bool isCard, object data)
protected async Task<object> ReadAttachmentFile(ITurnContext turnContext, ILanguageGenerator languageGenerator, string fileLocation, string contentType, bool isCard, object data)
{
if (Uri.TryCreate(fileLocation, UriKind.Absolute, out Uri uri))
{
@ -250,7 +179,7 @@ namespace Microsoft.Bot.Builder.Dialogs
if (languageGeneratorr != null)
{
var template = $"```\n{jsonContents}\n```";
// databind json
var result = await languageGenerator.Generate(turnContext, template, data).ConfigureAwait(false);
if (result != null)
@ -271,6 +200,77 @@ namespace Microsoft.Bot.Builder.Dialogs
}
}
private async Task AddAttachment(ITurnContext turnContext, ILanguageGenerator languageGenerator, IMessageActivity activity, string line, object data)
{
var parts = line.Split('=');
if (parts.Length == 1)
{
throw new ArgumentOutOfRangeException($"Missing = seperator in {line}");
}
var value = parts[1].TrimEnd(']').Trim();
var parts2 = value.Split(' ');
var contentUrl = parts2[0];
var attachment = new Attachment(contentUrl: contentUrl);
if (parts2.Length == 2)
{
switch (parts2[1].ToLower())
{
case "animation":
attachment.ContentType = AnimationCard.ContentType;
attachment.Content = await ReadAttachmentFile(turnContext, languageGenerator, contentUrl, attachment.ContentType, isCard: true, data: data).ConfigureAwait(false);
break;
case "audio":
attachment.ContentType = AudioCard.ContentType;
attachment.Content = await ReadAttachmentFile(turnContext, languageGenerator, contentUrl, attachment.ContentType, isCard: true, data: data).ConfigureAwait(false);
break;
case "hero":
attachment.ContentType = HeroCard.ContentType;
attachment.Content = await ReadAttachmentFile(turnContext, languageGenerator, contentUrl, attachment.ContentType, isCard: true, data: data).ConfigureAwait(false);
break;
case "receipt":
attachment.ContentType = ReceiptCard.ContentType;
attachment.Content = await ReadAttachmentFile(turnContext, languageGenerator, contentUrl, attachment.ContentType, isCard: true, data: data).ConfigureAwait(false);
break;
case "thumbnail":
attachment.ContentType = ThumbnailCard.ContentType;
attachment.Content = await ReadAttachmentFile(turnContext, languageGenerator, contentUrl, attachment.ContentType, isCard: true, data: data).ConfigureAwait(false);
break;
case "signin":
attachment.ContentType = SigninCard.ContentType;
attachment.Content = await ReadAttachmentFile(turnContext, languageGenerator, contentUrl, attachment.ContentType, isCard: true, data: data).ConfigureAwait(false);
break;
case "video":
attachment.ContentType = VideoCard.ContentType;
attachment.Content = await ReadAttachmentFile(turnContext, languageGenerator, contentUrl, attachment.ContentType, isCard: true, data: data).ConfigureAwait(false);
break;
case "adaptivecard":
attachment.ContentType = "application/vnd.microsoft.card.adaptive";
attachment.Content = await ReadAttachmentFile(turnContext, languageGenerator, contentUrl, attachment.ContentType, isCard: true, data: data).ConfigureAwait(false);
break;
default:
attachment.ContentType = parts2[1].Trim();
attachment.Content = await ReadAttachmentFile(turnContext, languageGenerator, contentUrl, attachment.ContentType, isCard: false, data: data).ConfigureAwait(false);
break;
}
}
if (attachment.Content != null && attachment.Content is string && ((string)attachment.Content).StartsWith("data:"))
{
attachment.ContentUrl = (string)attachment.Content;
attachment.Content = null;
}
if (attachment.Content != null)
{
// if we are sending content, then no need for contentUrl
attachment.ContentUrl = null;
}
activity.Attachments.Add(attachment);
}
private static int AddJsonAttachment(IMessageActivity activity, string[] lines, int iLine)
{
StringBuilder sb = new StringBuilder();

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

@ -4,7 +4,6 @@ using System.Threading.Tasks;
namespace Microsoft.Bot.Builder.Dialogs
{
/// <summary>
/// Defines an text Template where the template expression is local aka "inline".
/// </summary>
@ -46,6 +45,5 @@ namespace Microsoft.Bot.Builder.Dialogs
{
return $"{nameof(TextTemplate)}({this.Template})";
}
}
}

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

@ -495,7 +495,6 @@ namespace Microsoft.Bot.Builder.Expressions
return (value, error);
};
/// <summary>
/// walk dialog callstack looking for property
/// </summary>

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

@ -44,6 +44,7 @@ namespace Microsoft.Bot.Builder.Dialogs
{
botAdapter.UseLanguageGeneration(resourceExplorer, new ResourceMultiLanguageGenerator(defaultLg));
}
return botAdapter;
}

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

@ -6,7 +6,6 @@ using Microsoft.Bot.Builder.Dialogs;
namespace Microsoft.Bot.Builder.LanguageGeneration
{
/// <summary>
/// ILanguageGenerator which uses implements a map of locale->ILanguageGenerator for the locale and has a policy which controls fallback (try en-us -> en -> default)
/// </summary>

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

@ -38,9 +38,9 @@ namespace Microsoft.Bot.Builder.TemplateManager
{
if (!this.Renderers.Contains(renderer))
{
this.Renderers.Add(renderer);
}
return this;
}

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

@ -12,6 +12,7 @@ namespace Microsoft.Bot.Builder.TemplateManager
{
[JsonProperty(PropertyName = "template")]
public string TemplateId { get; set; }
[JsonProperty(PropertyName = "data")]
public object Data { get; set; }
}

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

@ -20,33 +20,10 @@ namespace Microsoft.Bot.Builder
/// </remarks>
public class FileTranscriptLogger : ITranscriptStore
{
private static JsonSerializerSettings jsonSettings = new JsonSerializerSettings()
{
Formatting = Formatting.Indented,
NullValueHandling = NullValueHandling.Ignore,
};
private string folder;
private bool unitTestMode;
private HashSet<string> started = new HashSet<string>();
private static async Task<Activity[]> LoadTranscript(string transcriptFile)
{
if (File.Exists(transcriptFile))
{
using (var stream = File.OpenRead(transcriptFile))
{
using (var reader = new StreamReader(stream) as TextReader)
{
var json = await reader.ReadToEndAsync().ConfigureAwait(false);
return JsonConvert.DeserializeObject<Activity[]>(json);
}
}
}
return Array.Empty<Activity>();
}
/// <summary>
/// Initializes a new instance of the <see cref="FileTranscriptLogger"/> class.
/// </summary>
@ -70,6 +47,29 @@ namespace Microsoft.Bot.Builder
this.unitTestMode = unitTestMode;
}
private static JsonSerializerSettings jsonSettings = new JsonSerializerSettings()
{
Formatting = Formatting.Indented,
NullValueHandling = NullValueHandling.Ignore,
};
private static async Task<Activity[]> LoadTranscript(string transcriptFile)
{
if (File.Exists(transcriptFile))
{
using (var stream = File.OpenRead(transcriptFile))
{
using (var reader = new StreamReader(stream) as TextReader)
{
var json = await reader.ReadToEndAsync().ConfigureAwait(false);
return JsonConvert.DeserializeObject<Activity[]>(json);
}
}
}
return Array.Empty<Activity>();
}
/// <summary>
/// Log an activity to the transcript.
/// </summary>
@ -117,7 +117,7 @@ namespace Microsoft.Bot.Builder
switch (activity.Type)
{
case ActivityTypes.MessageDelete:
await messageDelete(activity, transcriptFile).ConfigureAwait(false);
await MessageDelete(activity, transcriptFile).ConfigureAwait(false);
return;
case ActivityTypes.MessageUpdate:
@ -257,7 +257,7 @@ namespace Microsoft.Bot.Builder
}
}
private async Task messageDelete(IActivity activity, string transcriptFile)
private async Task MessageDelete(IActivity activity, string transcriptFile)
{
// load all activities
var transcript = await LoadTranscript(transcriptFile).ConfigureAwait(false);

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

@ -61,7 +61,6 @@ namespace Microsoft.Bot.Builder.AI.QnA.Tests
});
}
[TestMethod]
public async Task QnAMakerDialog_Answers()
{

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