Warnings fix gropup 8
This commit is contained in:
Родитель
40d552b7d4
Коммит
e5f530d992
|
@ -464,7 +464,8 @@ namespace Microsoft.Bot.Builder.AI.QnA
|
|||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task<T> RecognizeAsync<T>(ITurnContext turnContext, CancellationToken cancellationToken) where T : IRecognizerConvert, new()
|
||||
public Task<T> RecognizeAsync<T>(ITurnContext turnContext, CancellationToken cancellationToken)
|
||||
where T : IRecognizerConvert, new()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
|
|
@ -24,15 +24,6 @@ namespace Microsoft.Bot.Builder.AI.TriggerTrees
|
|||
private List<Trigger> _triggers = new List<Trigger>();
|
||||
private List<Node> _specializations = new List<Node>();
|
||||
|
||||
private enum Operation
|
||||
{
|
||||
None,
|
||||
Found,
|
||||
Added,
|
||||
Removed,
|
||||
Inserted
|
||||
}
|
||||
|
||||
internal Node(Clause clause, TriggerTree tree, Trigger trigger = null)
|
||||
{
|
||||
// In order to debug:
|
||||
|
@ -75,6 +66,15 @@ namespace Microsoft.Bot.Builder.AI.TriggerTrees
|
|||
}
|
||||
}
|
||||
|
||||
private enum Operation
|
||||
{
|
||||
None,
|
||||
Found,
|
||||
Added,
|
||||
Removed,
|
||||
Inserted
|
||||
}
|
||||
|
||||
#if Count
|
||||
private static int _count = 0;
|
||||
#endif
|
||||
|
|
|
@ -68,11 +68,6 @@ namespace Microsoft.Bot.Builder.AI.TriggerTrees
|
|||
/// </remarks>
|
||||
public const string Optional = "optional";
|
||||
|
||||
public List<IOptimizer> Optimizers = new List<IOptimizer>();
|
||||
public Dictionary<string, IPredicateComparer> Comparers = new Dictionary<string, IPredicateComparer>();
|
||||
public Node Root;
|
||||
public int TotalTriggers = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Any predicate expression wrapped in this will be ignored for specialization.
|
||||
/// </summary>
|
||||
|
@ -83,8 +78,21 @@ namespace Microsoft.Bot.Builder.AI.TriggerTrees
|
|||
/// </remarks>
|
||||
public const string Ignore = "ignore";
|
||||
|
||||
public List<IOptimizer> Optimizers = new List<IOptimizer>();
|
||||
public Dictionary<string, IPredicateComparer> Comparers = new Dictionary<string, IPredicateComparer>();
|
||||
public Node Root;
|
||||
public int TotalTriggers = 0;
|
||||
|
||||
private static readonly IExpressionParser _parser = new ExpressionEngine(LookupFunction);
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="TriggerTree"/> class.
|
||||
/// </summary>
|
||||
public TriggerTree()
|
||||
{
|
||||
Root = new Node(new Clause(), this);
|
||||
}
|
||||
|
||||
public static ExpressionEvaluator LookupFunction(string type)
|
||||
{
|
||||
ExpressionEvaluator eval;
|
||||
|
@ -101,14 +109,6 @@ namespace Microsoft.Bot.Builder.AI.TriggerTrees
|
|||
return eval;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="TriggerTree"/> class.
|
||||
/// </summary>
|
||||
public TriggerTree()
|
||||
{
|
||||
Root = new Node(new Clause(), this);
|
||||
}
|
||||
|
||||
public static Expression Parse(string expr) => _parser.Parse(expr);
|
||||
|
||||
public override string ToString() => $"TriggerTree with {TotalTriggers} triggers";
|
||||
|
|
|
@ -73,6 +73,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
|
|||
/// </summary>
|
||||
///
|
||||
GET,
|
||||
|
||||
/// <summary>
|
||||
/// Http POST.
|
||||
/// </summary>
|
||||
|
|
|
@ -60,7 +60,10 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
|
|||
|
||||
private static string Ellipsis(string text, int length)
|
||||
{
|
||||
if (text.Length <= length) { return text; }
|
||||
if (text.Length <= length)
|
||||
{
|
||||
return text;
|
||||
}
|
||||
int pos = text.IndexOf(" ", length);
|
||||
|
||||
if (pos >= 0)
|
||||
|
|
|
@ -20,15 +20,15 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
|
|||
/// </summary>
|
||||
public class SwitchCondition : DialogAction, IDialogDependencies
|
||||
{
|
||||
private Dictionary<string, Expression> caseExpressions = null;
|
||||
|
||||
private Expression condition;
|
||||
|
||||
/// <summary>
|
||||
/// Cases.
|
||||
/// </summary>
|
||||
public List<Case> Cases = new List<Case>();
|
||||
|
||||
private Dictionary<string, Expression> caseExpressions = null;
|
||||
|
||||
private Expression condition;
|
||||
|
||||
[JsonConstructor]
|
||||
public SwitchCondition([CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLine = 0)
|
||||
: base()
|
||||
|
|
|
@ -100,7 +100,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Events
|
|||
/// Method called to execute the rule's actions.
|
||||
/// </summary>
|
||||
/// <param name="planningContext">Context.</param>
|
||||
/// <returns></returns>
|
||||
/// <returns>A <see cref="Task"/> with plan change list.</returns>
|
||||
public async Task<List<ActionChangeList>> ExecuteAsync(SequenceContext planningContext)
|
||||
{
|
||||
return await OnExecuteAsync(planningContext).ConfigureAwait(false);
|
||||
|
@ -110,7 +110,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Events
|
|||
/// Method called to process the request to execute the actions.
|
||||
/// </summary>
|
||||
/// <param name="planning">Context.</param>
|
||||
/// <returns></returns>
|
||||
/// <returns>A <see cref="Task"/> with plan change list.</returns>
|
||||
public async virtual Task<List<ActionChangeList>> OnExecuteAsync(SequenceContext planning)
|
||||
{
|
||||
return new List<ActionChangeList>()
|
||||
|
|
|
@ -15,6 +15,8 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Events
|
|||
{
|
||||
[JsonConstructor]
|
||||
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) { }
|
||||
: base(type: ActivityTypes.Handoff, actions: actions, constraint: constraint, callerPath: callerPath, callerLine: callerLine)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Events
|
|||
var (name, score) = recognizerResult.GetTopScoringIntent();
|
||||
return new ActionChangeList()
|
||||
{
|
||||
//ChangeType = this.ChangeType,
|
||||
// ChangeType = this.ChangeType,
|
||||
|
||||
// proposed turn state changes
|
||||
Turn = new Dictionary<string, object>()
|
||||
|
|
|
@ -16,13 +16,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive
|
|||
/// <returns>The expression for the rule.</returns>
|
||||
Expression GetExpression(IExpressionParser parser);
|
||||
|
||||
/// <summary>
|
||||
/// Execute the action for this rule.
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <returns>Task with plan change list.</returns>
|
||||
Task<List<ActionChangeList>> ExecuteAsync(SequenceContext context);
|
||||
|
||||
/// <summary>
|
||||
/// Gets actions to add to the plan when the rule is activated.
|
||||
/// </summary>
|
||||
|
@ -30,5 +23,12 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive
|
|||
/// Actions to add to the plan when the rule is activated.
|
||||
/// </value>
|
||||
List<IDialog> Actions { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Execute the action for this rule.
|
||||
/// </summary>
|
||||
/// <param name="context">Dialog sequence context.</param>
|
||||
/// <returns>Task with plan change list.</returns>
|
||||
Task<List<ActionChangeList>> ExecuteAsync(SequenceContext context);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,12 +67,12 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input
|
|||
public const string TURN_COUNT_PROPERTY = "dialog.turnCount";
|
||||
public const string INPUT_PROPERTY = "turn.value";
|
||||
|
||||
private Expression value;
|
||||
private Expression defaultValue;
|
||||
|
||||
private const string PersistedOptions = "options";
|
||||
private const string PersistedState = "state";
|
||||
|
||||
private Expression value;
|
||||
private Expression defaultValue;
|
||||
|
||||
public bool AlwaysPrompt { get; set; } = false;
|
||||
|
||||
public AllowInterruptions AllowInterruptions { get; set; } = AllowInterruptions.NotRecognized;
|
||||
|
@ -136,8 +136,10 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input
|
|||
{
|
||||
return defaultValue?.ToString();
|
||||
}
|
||||
|
||||
set
|
||||
{ lock (this)
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
defaultValue = (value != null) ? new ExpressionEngine().Parse(value) : null;
|
||||
}
|
||||
|
@ -267,7 +269,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input
|
|||
// InputState.Valid -> Do not bubble up -> return true
|
||||
// InputState.Missing -> bubble up -> return false
|
||||
// InputState.Unrecognized -> bubble up -> return false
|
||||
|
||||
return state == InputState.Valid || state == InputState.Invalid;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,15 +28,15 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input
|
|||
|
||||
public class NumberInput : InputDialog
|
||||
{
|
||||
public string DefaultLocale { get; set; } = null;
|
||||
|
||||
public NumberOutputFormat OutputFormat { get; set; } = NumberOutputFormat.Float;
|
||||
|
||||
public NumberInput([CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLine = 0)
|
||||
{
|
||||
this.RegisterSourceLocation(callerPath, callerLine);
|
||||
}
|
||||
|
||||
public string DefaultLocale { get; set; } = null;
|
||||
|
||||
public NumberOutputFormat OutputFormat { get; set; } = NumberOutputFormat.Float;
|
||||
|
||||
protected override string OnComputeId()
|
||||
{
|
||||
return $"NumberInput[{BindingPath()}]";
|
||||
|
|
|
@ -13,6 +13,10 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers
|
|||
/// </summary>
|
||||
public class MultiLanguageRecognizer : IRecognizer
|
||||
{
|
||||
public MultiLanguageRecognizer()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets policy for languages fallback.
|
||||
/// </summary>
|
||||
|
@ -31,10 +35,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers
|
|||
[JsonProperty("recognizers")]
|
||||
public IDictionary<string, IRecognizer> Recognizers { get; set; } = new Dictionary<string, IRecognizer>();
|
||||
|
||||
public MultiLanguageRecognizer()
|
||||
{
|
||||
}
|
||||
|
||||
public Task<RecognizerResult> RecognizeAsync(ITurnContext turnContext, CancellationToken cancellationToken)
|
||||
{
|
||||
if (!LanguagePolicy.TryGetValue(turnContext.Activity.Locale ?? string.Empty, out string[] policy))
|
||||
|
@ -54,7 +54,8 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers
|
|||
return Task.FromResult(new RecognizerResult() { });
|
||||
}
|
||||
|
||||
public Task<T> RecognizeAsync<T>(ITurnContext turnContext, CancellationToken cancellationToken) where T : IRecognizerConvert, new()
|
||||
public Task<T> RecognizeAsync<T>(ITurnContext turnContext, CancellationToken cancellationToken)
|
||||
where T : IRecognizerConvert, new()
|
||||
{
|
||||
if (!LanguagePolicy.TryGetValue(turnContext.Activity.Locale ?? string.Empty, out string[] policy))
|
||||
{
|
||||
|
|
|
@ -21,6 +21,10 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers
|
|||
{
|
||||
private Dictionary<string, Regex> patterns = new Dictionary<string, Regex>();
|
||||
|
||||
public RegexRecognizer()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets dictionary of patterns -> Intent names.
|
||||
/// </summary>
|
||||
|
@ -30,10 +34,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers
|
|||
[JsonProperty("intents")]
|
||||
public Dictionary<string, string> Intents { get; set; } = new Dictionary<string, string>();
|
||||
|
||||
public RegexRecognizer()
|
||||
{
|
||||
}
|
||||
|
||||
public async Task<RecognizerResult> RecognizeAsync(ITurnContext turnContext, CancellationToken cancellationToken)
|
||||
{
|
||||
// Process only messages
|
||||
|
@ -105,7 +105,8 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers
|
|||
return result;
|
||||
}
|
||||
|
||||
public Task<T> RecognizeAsync<T>(ITurnContext turnContext, CancellationToken cancellationToken) where T : IRecognizerConvert, new()
|
||||
public Task<T> RecognizeAsync<T>(ITurnContext turnContext, CancellationToken cancellationToken)
|
||||
where T : IRecognizerConvert, new()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
|
|
@ -14,12 +14,29 @@ using Newtonsoft.Json;
|
|||
|
||||
namespace Microsoft.Bot.Builder.Dialogs.Adaptive
|
||||
{
|
||||
public enum ActionChangeType
|
||||
{
|
||||
InsertActions,
|
||||
InsertActionsBeforeTags,
|
||||
AppendActions,
|
||||
EndSequence,
|
||||
ReplaceSequence,
|
||||
}
|
||||
|
||||
public class SequenceContext : DialogContext
|
||||
{
|
||||
private readonly string changeKey;
|
||||
|
||||
private DialogSet actionDialogs;
|
||||
|
||||
public SequenceContext(DialogSet dialogs, DialogContext dc, DialogState state, List<ActionState> actions, string changeKey, DialogSet actionDialogs)
|
||||
: base(dialogs, dc.Context, state, conversationState: dc.State.Conversation, userState: dc.State.User, settings: dc.State.Settings)
|
||||
{
|
||||
this.Actions = actions;
|
||||
this.changeKey = changeKey;
|
||||
this.actionDialogs = actionDialogs;
|
||||
}
|
||||
|
||||
public AdaptiveDialogState Plans { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
|
@ -42,14 +59,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive
|
|||
private set { this.Context.TurnState[changeKey] = value; }
|
||||
}
|
||||
|
||||
public SequenceContext(DialogSet dialogs, DialogContext dc, DialogState state, List<ActionState> actions, string changeKey, DialogSet actionDialogs)
|
||||
: base(dialogs, dc.Context, state, conversationState: dc.State.Conversation, userState: dc.State.User, settings: dc.State.Settings)
|
||||
{
|
||||
this.Actions = actions;
|
||||
this.changeKey = changeKey;
|
||||
this.actionDialogs = actionDialogs;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Queues up a set of changes that will be applied when ApplyChanges is called.
|
||||
/// </summary>
|
||||
|
@ -72,6 +81,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive
|
|||
/// will loop and apply any additional plan changes until there are no more changes left to
|
||||
/// apply.
|
||||
/// </remarks>
|
||||
/// <param name="cancellationToken">Cancellation token.</param>
|
||||
/// <returns>True if there were any changes to apply. </returns>
|
||||
public async Task<bool> ApplyChangesAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
|
@ -185,6 +195,21 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive
|
|||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Specifies whether a given dialog should inherit dialog-level state. For adaptive dialogs,
|
||||
/// we take our base class cases plus we explicitly ask that InputDialogs inherit state as well.
|
||||
/// InputDialogs don't inherit state out of the box because they inherit directly from Dialog and
|
||||
/// are declared in the Adaptive assembly, so the base class, DialogContext does not explicitly
|
||||
/// request that they inherit state. Thus, we add it here. This enables seamless usage of
|
||||
/// dialog level properties such as $name across Input dialogs and / or steps within an adaptive dialog.
|
||||
/// </summary>
|
||||
/// <param name="dialog">The dialog to be tested.</param>
|
||||
/// <returns>Whether the passed dialog should inherit dialog-level state.</returns>
|
||||
protected override bool ShouldInheritState(IDialog dialog)
|
||||
{
|
||||
return base.ShouldInheritState(dialog) || dialog is InputDialog;
|
||||
}
|
||||
|
||||
private async Task UpdateSequenceAsync(ActionChangeList change, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
if (change == null)
|
||||
|
@ -261,21 +286,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Specifies whether a given dialog should inherit dialog-level state. For adaptive dialogs,
|
||||
/// we take our base class cases plus we explicitly ask that InputDialogs inherit state as well.
|
||||
/// InputDialogs don't inherit state out of the box because they inherit directly from Dialog and
|
||||
/// are declared in the Adaptive assembly, so the base class, DialogContext does not explicitly
|
||||
/// request that they inherit state. Thus, we add it here. This enables seamless usage of
|
||||
/// dialog level properties such as $name across Input dialogs and / or steps within an adaptive dialog.
|
||||
/// </summary>
|
||||
/// <param name="dialog">The dialog to be tested.</param>
|
||||
/// <returns>Whether the passed dialog should inherit dialog-level state.</returns>
|
||||
protected override bool ShouldInheritState(IDialog dialog)
|
||||
{
|
||||
return base.ShouldInheritState(dialog) || dialog is InputDialog;
|
||||
}
|
||||
}
|
||||
|
||||
public class AdaptiveEvents : DialogContext.DialogEvents
|
||||
|
@ -322,15 +332,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive
|
|||
public object Options { get; set; }
|
||||
}
|
||||
|
||||
public enum ActionChangeType
|
||||
{
|
||||
InsertActions,
|
||||
InsertActionsBeforeTags,
|
||||
AppendActions,
|
||||
EndSequence,
|
||||
ReplaceSequence,
|
||||
}
|
||||
|
||||
[DebuggerDisplay("{ChangeType}:{Desire}")]
|
||||
public class ActionChangeList
|
||||
{
|
||||
|
|
|
@ -6,7 +6,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Composition.Recognizers
|
|||
{
|
||||
public class AgeEntityRecognizer : BaseEntityRecognizer
|
||||
{
|
||||
public AgeEntityRecognizer() { }
|
||||
public AgeEntityRecognizer()
|
||||
{
|
||||
}
|
||||
|
||||
protected override List<ModelResult> Recognize(string text, string culture)
|
||||
{
|
||||
|
|
|
@ -8,7 +8,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Composition.Recognizers
|
|||
{
|
||||
public class ChoiceEntityRecognizer : BaseEntityRecognizer
|
||||
{
|
||||
public ChoiceEntityRecognizer() { }
|
||||
public ChoiceEntityRecognizer()
|
||||
{
|
||||
}
|
||||
|
||||
protected override List<ModelResult> Recognize(string text, string culture)
|
||||
{
|
||||
|
|
|
@ -6,7 +6,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Composition.Recognizers
|
|||
{
|
||||
public class CurrencyEntityRecognizer : BaseEntityRecognizer
|
||||
{
|
||||
public CurrencyEntityRecognizer() { }
|
||||
public CurrencyEntityRecognizer()
|
||||
{
|
||||
}
|
||||
|
||||
protected override List<ModelResult> Recognize(string text, string culture)
|
||||
{
|
||||
|
|
|
@ -7,7 +7,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Composition.Recognizers
|
|||
{
|
||||
public class DateTimeEntityRecognizer : BaseEntityRecognizer
|
||||
{
|
||||
public DateTimeEntityRecognizer() { }
|
||||
public DateTimeEntityRecognizer()
|
||||
{
|
||||
}
|
||||
|
||||
protected override List<ModelResult> Recognize(string text, string culture)
|
||||
{
|
||||
|
|
|
@ -6,7 +6,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Composition.Recognizers
|
|||
{
|
||||
public class DimensionEntityRecognizer : BaseEntityRecognizer
|
||||
{
|
||||
public DimensionEntityRecognizer() { }
|
||||
public DimensionEntityRecognizer()
|
||||
{
|
||||
}
|
||||
|
||||
protected override List<ModelResult> Recognize(string text, string culture)
|
||||
{
|
||||
|
|
|
@ -9,7 +9,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Composition.Recognizers
|
|||
{
|
||||
public class EmailEntityRecognizer : BaseEntityRecognizer
|
||||
{
|
||||
public EmailEntityRecognizer() { }
|
||||
public EmailEntityRecognizer()
|
||||
{
|
||||
}
|
||||
|
||||
protected override List<ModelResult> Recognize(string text, string culture)
|
||||
{
|
||||
|
|
|
@ -11,7 +11,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Composition.Recognizers
|
|||
/// </summary>
|
||||
public class EntityRecognizerSet : IEntityRecognizer
|
||||
{
|
||||
public EntityRecognizerSet() { }
|
||||
public EntityRecognizerSet()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets recognizer pool.
|
||||
|
|
|
@ -9,7 +9,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Composition.Recognizers
|
|||
{
|
||||
public class GuidEntityRecognizer : BaseEntityRecognizer
|
||||
{
|
||||
public GuidEntityRecognizer() { }
|
||||
public GuidEntityRecognizer()
|
||||
{
|
||||
}
|
||||
|
||||
protected override List<ModelResult> Recognize(string text, string culture)
|
||||
{
|
||||
|
|
|
@ -9,7 +9,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Composition.Recognizers
|
|||
{
|
||||
public class HashtagEntityRecognizer : BaseEntityRecognizer
|
||||
{
|
||||
public HashtagEntityRecognizer() { }
|
||||
public HashtagEntityRecognizer()
|
||||
{
|
||||
}
|
||||
|
||||
protected override List<ModelResult> Recognize(string text, string culture)
|
||||
{
|
||||
|
|
|
@ -9,7 +9,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Composition.Recognizers
|
|||
{
|
||||
public class IpEntityRecognizer : BaseEntityRecognizer
|
||||
{
|
||||
public IpEntityRecognizer() { }
|
||||
public IpEntityRecognizer()
|
||||
{
|
||||
}
|
||||
|
||||
protected override List<ModelResult> Recognize(string text, string culture)
|
||||
{
|
||||
|
|
|
@ -9,7 +9,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Composition.Recognizers
|
|||
{
|
||||
public class MentionEntityRecognizer : BaseEntityRecognizer
|
||||
{
|
||||
public MentionEntityRecognizer() { }
|
||||
public MentionEntityRecognizer()
|
||||
{
|
||||
}
|
||||
|
||||
protected override List<ModelResult> Recognize(string text, string culture)
|
||||
{
|
||||
|
|
|
@ -6,7 +6,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Composition.Recognizers
|
|||
{
|
||||
public class NumberEntityRecognizer : BaseEntityRecognizer
|
||||
{
|
||||
public NumberEntityRecognizer() { }
|
||||
public NumberEntityRecognizer()
|
||||
{
|
||||
}
|
||||
|
||||
protected override List<ModelResult> Recognize(string text, string culture)
|
||||
{
|
||||
|
|
|
@ -6,7 +6,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Composition.Recognizers
|
|||
{
|
||||
public class NumberRangeEntityRecognizer : BaseEntityRecognizer
|
||||
{
|
||||
public NumberRangeEntityRecognizer() { }
|
||||
public NumberRangeEntityRecognizer()
|
||||
{
|
||||
}
|
||||
|
||||
protected override List<ModelResult> Recognize(string text, string culture)
|
||||
{
|
||||
|
|
|
@ -6,7 +6,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Composition.Recognizers
|
|||
{
|
||||
public class PercentageEntityRecognizer : BaseEntityRecognizer
|
||||
{
|
||||
public PercentageEntityRecognizer() { }
|
||||
public PercentageEntityRecognizer()
|
||||
{
|
||||
}
|
||||
|
||||
protected override List<ModelResult> Recognize(string text, string culture)
|
||||
{
|
||||
|
|
|
@ -9,7 +9,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Composition.Recognizers
|
|||
{
|
||||
public class PhoneNumberEntityRecognizer : BaseEntityRecognizer
|
||||
{
|
||||
public PhoneNumberEntityRecognizer() { }
|
||||
public PhoneNumberEntityRecognizer()
|
||||
{
|
||||
}
|
||||
|
||||
protected override List<ModelResult> Recognize(string text, string culture)
|
||||
{
|
||||
|
|
|
@ -6,7 +6,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Composition.Recognizers
|
|||
{
|
||||
public class TemperatureEntityRecognizer : BaseEntityRecognizer
|
||||
{
|
||||
public TemperatureEntityRecognizer() { }
|
||||
public TemperatureEntityRecognizer()
|
||||
{
|
||||
}
|
||||
|
||||
protected override List<ModelResult> Recognize(string text, string culture)
|
||||
{
|
||||
|
|
|
@ -7,7 +7,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Composition.Recognizers
|
|||
public const string TypeName = "Text";
|
||||
|
||||
public TextEntity()
|
||||
: base(TypeName) { }
|
||||
: base(TypeName)
|
||||
{
|
||||
}
|
||||
|
||||
public TextEntity(string text)
|
||||
: base(TypeName)
|
||||
|
|
|
@ -9,7 +9,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Composition.Recognizers
|
|||
{
|
||||
public class UrlEntityRecognizer: BaseEntityRecognizer
|
||||
{
|
||||
public UrlEntityRecognizer() { }
|
||||
public UrlEntityRecognizer()
|
||||
{
|
||||
}
|
||||
|
||||
protected override List<ModelResult> Recognize(string text, string culture)
|
||||
{
|
||||
|
|
|
@ -103,7 +103,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging
|
|||
public sealed class DictionaryDataModel<K, V> : DataModelBase<IDictionary<K, V>, K, V>
|
||||
{
|
||||
public DictionaryDataModel(ICoercion coercion)
|
||||
: base(coercion) { }
|
||||
: base(coercion)
|
||||
{
|
||||
}
|
||||
|
||||
public override int Rank => 6;
|
||||
|
||||
|
@ -119,7 +121,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging
|
|||
public sealed class ReadOnlyDictionaryDataModel<K, V> : DataModelBase<IReadOnlyDictionary<K, V>, K, V>
|
||||
{
|
||||
public ReadOnlyDictionaryDataModel(ICoercion coercion)
|
||||
: base(coercion) { }
|
||||
: base(coercion)
|
||||
{
|
||||
}
|
||||
|
||||
public override int Rank => 5;
|
||||
|
||||
|
@ -135,7 +139,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging
|
|||
public sealed class ListDataModel<T> : DataModelBase<IList<T>, int, T>
|
||||
{
|
||||
public ListDataModel(ICoercion coercion)
|
||||
: base(coercion) { }
|
||||
: base(coercion)
|
||||
{
|
||||
}
|
||||
|
||||
public override int Rank => 4;
|
||||
|
||||
|
@ -151,7 +157,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging
|
|||
public sealed class EnumerableDataModel<T> : DataModelBase<IEnumerable<T>, int, T>
|
||||
{
|
||||
public EnumerableDataModel(ICoercion coercion)
|
||||
: base(coercion) { }
|
||||
: base(coercion)
|
||||
{
|
||||
}
|
||||
|
||||
public override int Rank => 3;
|
||||
|
||||
|
@ -167,7 +175,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging
|
|||
public sealed class ReflectionDataModel<T> : DataModelBase<object, string, object>
|
||||
{
|
||||
public ReflectionDataModel(ICoercion coercion)
|
||||
: base(coercion) { }
|
||||
: base(coercion)
|
||||
{
|
||||
}
|
||||
|
||||
public override int Rank => 2;
|
||||
|
||||
|
|
|
@ -59,7 +59,11 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging
|
|||
public string LastMore { get; set; }
|
||||
}
|
||||
|
||||
public enum Phase { Started, Continue, Next, Step, Breakpoint, Pause, Exited };
|
||||
public enum Phase
|
||||
{
|
||||
Started, Continue, Next, Step, Breakpoint, Pause, Exited
|
||||
}
|
||||
;
|
||||
|
||||
public sealed class RunModel
|
||||
{
|
||||
|
|
|
@ -11,7 +11,8 @@ using Newtonsoft.Json.Linq;
|
|||
|
||||
namespace Microsoft.Bot.Builder.Dialogs.Declarative.Converters
|
||||
{
|
||||
public class InterfaceConverter<T> : JsonConverter where T : class
|
||||
public class InterfaceConverter<T> : JsonConverter
|
||||
where T : class
|
||||
{
|
||||
private readonly IRefResolver refResolver;
|
||||
private readonly Source.IRegistry registry;
|
||||
|
|
|
@ -17,7 +17,8 @@ namespace Microsoft.Bot.Builder.Dialogs.Declarative.Converters
|
|||
{
|
||||
public LanguageGeneratorConverter(IRefResolver refResolver, Source.IRegistry registry, Stack<string> paths)
|
||||
: base(refResolver, registry, paths)
|
||||
{ }
|
||||
{
|
||||
}
|
||||
|
||||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
|
||||
{
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Declarative
|
|||
/// <param name="botAdapter">BotAdapter to add middleware to.</param>
|
||||
/// <param name="resourceExplorer">resourceExplorer to use.</param>
|
||||
/// <param name="registerCustomTypes">function to add custom types.</param>
|
||||
/// <returns></returns>
|
||||
/// <returns>The bot adapter.</returns>
|
||||
public static BotAdapter UseResourceExplorer(this BotAdapter botAdapter, ResourceExplorer resourceExplorer, Action registerCustomTypes = null)
|
||||
{
|
||||
TypeFactory.RegisterAdaptiveTypes();
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Declarative
|
|||
|
||||
var json = await resource.ReadTextAsync();
|
||||
|
||||
return _load<T>(registry, refResolver, paths, json);
|
||||
return Load<T>(registry, refResolver, paths, json);
|
||||
}
|
||||
|
||||
public static T Load<T>(IResource resource, ResourceExplorer resourceExplorer, Source.IRegistry registry)
|
||||
|
@ -41,10 +41,33 @@ namespace Microsoft.Bot.Builder.Dialogs.Declarative
|
|||
|
||||
var json = resource.ReadTextAsync().GetAwaiter().GetResult();
|
||||
|
||||
return _load<T>(registry, refResolver, paths, json);
|
||||
return Load<T>(registry, refResolver, paths, json);
|
||||
}
|
||||
|
||||
private static T _load<T>(Source.IRegistry registry, IRefResolver refResolver, Stack<string> paths, string json)
|
||||
/// <summary>
|
||||
/// Load a settings style path settings.x.y.z -> x:y:z.
|
||||
/// </summary>
|
||||
/// <param name="configuration">Configuration.</param>
|
||||
/// <param name="value">Value to load.</param>
|
||||
/// <returns>The value formatted to the configuration.</returns>
|
||||
public static string LoadSetting(this IConfiguration configuration, string value)
|
||||
{
|
||||
if (value.StartsWith("{") && value.EndsWith("}"))
|
||||
{
|
||||
var path = value.Trim('{', '}').Replace(".", ":");
|
||||
if (path.StartsWith("settings:"))
|
||||
{
|
||||
path = path.Substring(9);
|
||||
}
|
||||
|
||||
// just use configurations ability to query for x:y:z
|
||||
value = ConfigurationBinder.GetValue<string>(configuration, path);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
private static T Load<T>(Source.IRegistry registry, IRefResolver refResolver, Stack<string> paths, string json)
|
||||
{
|
||||
return JsonConvert.DeserializeObject<T>(
|
||||
json, new JsonSerializerSettings()
|
||||
|
@ -72,28 +95,5 @@ namespace Microsoft.Bot.Builder.Dialogs.Declarative
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Load a settings style path settings.x.y.z -> x:y:z.
|
||||
/// </summary>
|
||||
/// <param name="configuration"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
public static string LoadSetting(this IConfiguration configuration, string value)
|
||||
{
|
||||
if (value.StartsWith("{") && value.EndsWith("}"))
|
||||
{
|
||||
var path = value.Trim('{', '}').Replace(".", ":");
|
||||
if (path.StartsWith("settings:"))
|
||||
{
|
||||
path = path.Substring(9);
|
||||
}
|
||||
|
||||
// just use configurations ability to query for x:y:z
|
||||
value = ConfigurationBinder.GetValue<string>(configuration, path);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,10 @@ namespace Microsoft.Bot.Builder.Dialogs.Declarative.Resources
|
|||
|
||||
public string Id { get; }
|
||||
|
||||
public string FullName { get { return this.path; } }
|
||||
public string FullName
|
||||
{
|
||||
get { return this.path; }
|
||||
}
|
||||
|
||||
public async Task<Stream> OpenStreamAsync()
|
||||
{
|
||||
|
@ -57,9 +60,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Declarative.Resources
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get resource as atext.
|
||||
/// Get resource as a text.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <returns>A <see cref="Task"/> with the string.</returns>
|
||||
public Task<string> ReadTextAsync()
|
||||
{
|
||||
if (this.textTask == null)
|
||||
|
|
|
@ -16,9 +16,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Declarative.Resources
|
|||
/// </summary>
|
||||
public class FolderResourceProvider : IResourceProvider, IDisposable
|
||||
{
|
||||
private CancellationTokenSource CancelReloadToken = new CancellationTokenSource();
|
||||
private CancellationTokenSource cancelReloadToken = new CancellationTokenSource();
|
||||
private ConcurrentBag<string> changedPaths = new ConcurrentBag<string>();
|
||||
private FileSystemWatcher Watcher;
|
||||
private FileSystemWatcher watcher;
|
||||
private Dictionary<string, FileResource> resources = new Dictionary<string, FileResource>();
|
||||
private HashSet<string> extensions = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
|
@ -32,7 +32,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Declarative.Resources
|
|||
this.IncludeSubFolders = includeSubFolders;
|
||||
folder = PathUtils.NormalizePath(folder);
|
||||
this.Directory = new DirectoryInfo(folder);
|
||||
SearchOption option = (this.IncludeSubFolders) ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly;
|
||||
SearchOption option = this.IncludeSubFolders ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly;
|
||||
|
||||
foreach (var fileInfo in this.Directory.EnumerateFiles($"*.*", option).Where(fi => this.extensions.Contains(fi.Extension)))
|
||||
{
|
||||
|
@ -42,16 +42,82 @@ namespace Microsoft.Bot.Builder.Dialogs.Declarative.Resources
|
|||
|
||||
if (monitorChanges)
|
||||
{
|
||||
this.Watcher = new FileSystemWatcher(folder);
|
||||
this.Watcher.IncludeSubdirectories = this.IncludeSubFolders;
|
||||
this.Watcher.EnableRaisingEvents = true;
|
||||
this.Watcher.Created += Watcher_Changed;
|
||||
this.Watcher.Changed += Watcher_Changed;
|
||||
this.Watcher.Deleted += Watcher_Deleted;
|
||||
this.Watcher.Renamed += Watcher_Renamed;
|
||||
this.watcher = new FileSystemWatcher(folder);
|
||||
this.watcher.IncludeSubdirectories = this.IncludeSubFolders;
|
||||
this.watcher.EnableRaisingEvents = true;
|
||||
this.watcher.Created += Watcher_Changed;
|
||||
this.watcher.Changed += Watcher_Changed;
|
||||
this.watcher.Deleted += Watcher_Deleted;
|
||||
this.watcher.Renamed += Watcher_Renamed;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets folder to enumerate.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// folder to enumerate.
|
||||
/// </value>
|
||||
public DirectoryInfo Directory { get; set; }
|
||||
|
||||
public bool IncludeSubFolders { get; set; }
|
||||
|
||||
public string Id
|
||||
{
|
||||
get { return this.Directory.FullName; }
|
||||
}
|
||||
|
||||
public event ResourceChangedEventHandler Changed;
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
lock (Directory)
|
||||
{
|
||||
if (this.watcher != null)
|
||||
{
|
||||
this.watcher.EnableRaisingEvents = false;
|
||||
this.watcher.Dispose();
|
||||
this.watcher = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// GetResource by id.
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public IResource GetResource(string id)
|
||||
{
|
||||
lock (this.resources)
|
||||
{
|
||||
if (this.resources.TryGetValue(id, out FileResource fileResource))
|
||||
{
|
||||
return fileResource;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get Resources by extension.
|
||||
/// </summary>
|
||||
public IEnumerable<IResource> GetResources(string extension)
|
||||
{
|
||||
extension = $".{extension.TrimStart('.').ToLower()}";
|
||||
|
||||
lock (this.resources)
|
||||
{
|
||||
return this.resources.Where(pair => Path.GetExtension(pair.Key).ToLower() == extension).Select(pair => pair.Value).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return this.Id;
|
||||
}
|
||||
|
||||
private void Watcher_Deleted(object sender, FileSystemEventArgs e)
|
||||
{
|
||||
var ext = Path.GetExtension(e.FullPath);
|
||||
|
@ -103,69 +169,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Declarative.Resources
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets folder to enumerate.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// folder to enumerate.
|
||||
/// </value>
|
||||
public DirectoryInfo Directory { get; set; }
|
||||
|
||||
public bool IncludeSubFolders { get; set; }
|
||||
|
||||
public string Id { get { return this.Directory.FullName; } }
|
||||
|
||||
public event ResourceChangedEventHandler Changed;
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
lock (Directory)
|
||||
{
|
||||
if (this.Watcher != null)
|
||||
{
|
||||
this.Watcher.EnableRaisingEvents = false;
|
||||
this.Watcher.Dispose();
|
||||
this.Watcher = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// GetResource by id.
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public IResource GetResource(string id)
|
||||
{
|
||||
lock (this.resources)
|
||||
{
|
||||
if (this.resources.TryGetValue(id, out FileResource fileResource))
|
||||
{
|
||||
return fileResource;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get Resources by extension.
|
||||
/// </summary>
|
||||
public IEnumerable<IResource> GetResources(string extension)
|
||||
{
|
||||
extension = $".{extension.TrimStart('.').ToLower()}";
|
||||
|
||||
lock (this.resources)
|
||||
{
|
||||
return this.resources.Where(pair => Path.GetExtension(pair.Key).ToLower() == extension).Select(pair => pair.Value).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return this.Id;
|
||||
}
|
||||
}
|
||||
|
||||
public static class FolderResourceProviderExtensions
|
||||
|
|
|
@ -25,14 +25,17 @@ namespace Microsoft.Bot.Builder.Dialogs.Declarative.Resources
|
|||
{
|
||||
private List<IResourceProvider> resourceProviders = new List<IResourceProvider>();
|
||||
|
||||
private CancellationTokenSource CancelReloadToken = new CancellationTokenSource();
|
||||
private CancellationTokenSource cancelReloadToken = new CancellationTokenSource();
|
||||
private ConcurrentBag<IResource> changedResources = new ConcurrentBag<IResource>();
|
||||
|
||||
public ResourceExplorer()
|
||||
{
|
||||
}
|
||||
|
||||
public IEnumerable<IResourceProvider> ResourceProviders { get { return this.resourceProviders; } }
|
||||
public IEnumerable<IResourceProvider> ResourceProviders
|
||||
{
|
||||
get { return this.resourceProviders; }
|
||||
}
|
||||
|
||||
public event ResourceChangedEventHandler Changed;
|
||||
|
||||
|
@ -58,11 +61,11 @@ namespace Microsoft.Bot.Builder.Dialogs.Declarative.Resources
|
|||
changedResources.Add(resource);
|
||||
}
|
||||
|
||||
lock (CancelReloadToken)
|
||||
lock (cancelReloadToken)
|
||||
{
|
||||
CancelReloadToken.Cancel();
|
||||
CancelReloadToken = new CancellationTokenSource();
|
||||
Task.Delay(1000, CancelReloadToken.Token)
|
||||
cancelReloadToken.Cancel();
|
||||
cancelReloadToken = new CancellationTokenSource();
|
||||
Task.Delay(1000, cancelReloadToken.Token)
|
||||
.ContinueWith(t =>
|
||||
{
|
||||
if (t.IsCanceled)
|
||||
|
|
|
@ -67,7 +67,8 @@ namespace Microsoft.Bot.Builder.Dialogs.Declarative.Types
|
|||
Register(plugin.SchemaUri, plugin.Type, plugin.Loader);
|
||||
}
|
||||
|
||||
public static T Build<T>(string name, JToken obj, JsonSerializer serializer) where T : class
|
||||
public static T Build<T>(string name, JToken obj, JsonSerializer serializer)
|
||||
where T : class
|
||||
{
|
||||
EnsureConfig();
|
||||
ICustomDeserializer builder;
|
||||
|
|
|
@ -132,7 +132,7 @@ namespace Microsoft.Bot.Builder.Dialogs
|
|||
/// to the current dialog's parent.
|
||||
/// </summary>
|
||||
/// <param name="dc">The dialog context for the current turn of the conversation.</param>
|
||||
/// <param name="reason">Reason why the dialog resumed.</param>
|
||||
/// <param name="reason">An enum indicating why the dialog resumed.</param>
|
||||
/// <param name="result">(Optional) value returned from the dialog that was called. The type of the value returned is dependent on the dialog that was called.</param>
|
||||
/// <param name="cancellationToken">A cancellation token that can be used by other objects
|
||||
/// or threads to receive notice of cancellation.</param>
|
||||
|
|
|
@ -78,10 +78,10 @@ namespace Microsoft.Bot.Builder.Dialogs
|
|||
/// dialog that was started by the current instance using `DialogSet.begin()`.
|
||||
/// If this method is NOT implemented then the dialog will be automatically ended with a call
|
||||
/// to `DialogSet.endDialogWithResult()`. Any result passed from the called dialog will be passed
|
||||
/// to the current dialogs parent.
|
||||
/// to the current dialog's parent.
|
||||
/// </summary>
|
||||
/// <param name="dc">The dialog context for the current turn of conversation.</param>
|
||||
/// <param name="reason">Reason why the dialog resumed.</param>
|
||||
/// <param name="reason">An enum indicating why the dialog resumed.</param>
|
||||
/// <param name="result">(Optional) value returned from the dialog that was called. The type of the value returned is dependant on the dialog that was called.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
|
||||
|
@ -93,7 +93,7 @@ namespace Microsoft.Bot.Builder.Dialogs
|
|||
/// <param name="turnContext">Dialog turn context.</param>
|
||||
/// <param name="instance">Dialog instance.</param>
|
||||
/// <param name="cancellationToken">Cancellation token.</param>
|
||||
/// <returns></returns>
|
||||
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
|
||||
Task RepromptDialogAsync(ITurnContext turnContext, DialogInstance instance, CancellationToken cancellationToken = default(CancellationToken));
|
||||
|
||||
/// <summary>
|
||||
|
@ -101,9 +101,9 @@ namespace Microsoft.Bot.Builder.Dialogs
|
|||
/// </summary>
|
||||
/// <param name="turnContext">Dialog turn context.</param>
|
||||
/// <param name="instance">Dialog instance.</param>
|
||||
/// <param name="reason"></param>
|
||||
/// <param name="reason">An enum indicating why the dialog ended.</param>
|
||||
/// <param name="cancellationToken">Cancellation token.</param>
|
||||
/// <returns></returns>
|
||||
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
|
||||
Task EndDialogAsync(ITurnContext turnContext, DialogInstance instance, DialogReason reason, CancellationToken cancellationToken = default(CancellationToken));
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -236,9 +236,9 @@ namespace Microsoft.Bot.Builder.Dialogs
|
|||
/// <summary>
|
||||
/// Equivalent to javascripts ObjectPath.Assign, creates a new object from startObject overlaying any non-null values from the overlay object.
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="startObject">intial object.</param>
|
||||
/// <param name="overlayObject">overlay object.</param>
|
||||
/// <typeparam name="T">The object type.</typeparam>
|
||||
/// <param name="startObject">Intial object.</param>
|
||||
/// <param name="overlayObject">Overlay object.</param>
|
||||
/// <returns>merged object.</returns>
|
||||
public static T Merge<T>(T startObject, T overlayObject)
|
||||
where T : class
|
||||
|
@ -249,7 +249,7 @@ namespace Microsoft.Bot.Builder.Dialogs
|
|||
/// <summary>
|
||||
/// Equivalent to javascripts ObjectPath.Assign, creates a new object from startObject overlaying any non-null values from the overlay object.
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <typeparam name="T">The target type.</typeparam>
|
||||
/// <param name="startObject">intial object of any type.</param>
|
||||
/// <param name="overlayObject">overlay object of any type.</param>
|
||||
/// <returns>merged object.</returns>
|
||||
|
|
|
@ -154,7 +154,7 @@ namespace Microsoft.Bot.Builder.Dialogs
|
|||
/// when the previous active dialog on the stack completes.
|
||||
/// </summary>
|
||||
/// <param name="dc">The dialog context for the current turn of the conversation.</param>
|
||||
/// <param name="reason">An enumeration values that indicates why the dialog resumed.</param>
|
||||
/// <param name="reason">An enum indicating why the dialog resumed.</param>
|
||||
/// <param name="result">Optional, value returned from the previous dialog on the stack.
|
||||
/// The type of the value returned is dependent on the previous dialog.</param>
|
||||
/// <param name="cancellationToken">A cancellation token that can be used by other objects
|
||||
|
|
|
@ -171,7 +171,7 @@ namespace Microsoft.Bot.Builder.Dialogs
|
|||
/// when the previous active dialog on the stack completes.
|
||||
/// </summary>
|
||||
/// <param name="dc">The dialog context for the current turn of the conversation.</param>
|
||||
/// <param name="reason">An enumeration values that indicates why the dialog resumed.</param>
|
||||
/// <param name="reason">An enum indicating why the dialog resumed.</param>
|
||||
/// <param name="result">Optional, value returned from the previous dialog on the stack.
|
||||
/// The type of the value returned is dependent on the previous dialog.</param>
|
||||
/// <param name="cancellationToken">A cancellation token that can be used by other objects
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace Microsoft.Bot.Builder.Dialogs
|
|||
/// <param name="turnContext">turn context.</param>
|
||||
/// <param name="template">template or [templateId].</param>
|
||||
/// <param name="data">data to bind to.</param>
|
||||
/// <returns></returns>
|
||||
/// <returns>A <see cref="Task{TResult}"/> representing the asynchronous operation.</returns>
|
||||
Task<T> Generate(ITurnContext turnContext, string template, object data);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ namespace Microsoft.Bot.Builder.Dialogs
|
|||
/// <summary>
|
||||
/// Defines Template interface for binding data to T.
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <typeparam name="T">Type to bind data to.</typeparam>
|
||||
public interface ITemplate<T>
|
||||
{
|
||||
/// <summary>
|
||||
|
|
|
@ -22,161 +22,6 @@ namespace Microsoft.Bot.Builder.Dialogs
|
|||
{
|
||||
}
|
||||
|
||||
private static int AddJsonAttachment(IMessageActivity activity, string[] lines, int iLine)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (; iLine < lines.Length; iLine++)
|
||||
{
|
||||
if (lines[iLine].TrimEnd() == "]")
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
sb.AppendLine(lines[iLine]);
|
||||
}
|
||||
|
||||
dynamic obj = JsonConvert.DeserializeObject(sb.ToString());
|
||||
string contentType = "application/json";
|
||||
|
||||
if (obj.type == "AdaptiveCard")
|
||||
{
|
||||
contentType = "application/vnd.microsoft.card.adaptive";
|
||||
}
|
||||
|
||||
var attachment = new Attachment(contentType, content: obj);
|
||||
activity.Attachments.Add(attachment);
|
||||
return iLine;
|
||||
}
|
||||
|
||||
private static void AddSuggestions(IMessageActivity activity, string line)
|
||||
{
|
||||
var value = line.Split('=');
|
||||
if (value.Length > 1)
|
||||
{
|
||||
var suggestions = value[1].Split('|');
|
||||
activity.SuggestedActions = new SuggestedActions();
|
||||
activity.SuggestedActions.Actions = suggestions.Select(s =>
|
||||
{
|
||||
var text = s.TrimEnd(']').Trim();
|
||||
return new CardAction(type: ActionTypes.MessageBack, title: text, displayText: text, text: text);
|
||||
}).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
private static void AddAttachmentLayout(IMessageActivity activity, string line)
|
||||
{
|
||||
var value = line.Split('=');
|
||||
if (value.Length > 1)
|
||||
{
|
||||
activity.AttachmentLayout = value[1].TrimEnd(']').Trim();
|
||||
}
|
||||
}
|
||||
|
||||
private static int AddGenericCardAtttachment(IMessageActivity activity, string type, string[] lines, int iLine)
|
||||
{
|
||||
var attachment = new Attachment(type, content: new JObject());
|
||||
iLine = BuildGenericCard(attachment.Content, type, lines, iLine);
|
||||
activity.Attachments.Add(attachment);
|
||||
return iLine;
|
||||
}
|
||||
|
||||
private static int BuildGenericCard(dynamic card, string type, string[] lines, int iLine)
|
||||
{
|
||||
bool lastLine = false;
|
||||
|
||||
for (; !lastLine && iLine < lines.Length; iLine++)
|
||||
{
|
||||
var line = lines[iLine];
|
||||
var start = line.IndexOf('=');
|
||||
if (start > 0)
|
||||
{
|
||||
var property = line.Substring(0, start).Trim().ToLower();
|
||||
var value = line.Substring(start + 1).Trim();
|
||||
if (value.EndsWith("]"))
|
||||
{
|
||||
value = value.TrimEnd(']');
|
||||
lastLine = true;
|
||||
}
|
||||
|
||||
switch (property.ToLower())
|
||||
{
|
||||
case "title":
|
||||
case "subtitle":
|
||||
case "text":
|
||||
case "aspect":
|
||||
case "value":
|
||||
case "connectionName":
|
||||
card[property] = value;
|
||||
break;
|
||||
|
||||
case "image":
|
||||
case "images":
|
||||
if (type == HeroCard.ContentType || type == ThumbnailCard.ContentType)
|
||||
{
|
||||
// then it's images
|
||||
if (card["images"] == null)
|
||||
{
|
||||
card["images"] = new JArray();
|
||||
}
|
||||
|
||||
var urlObj = new JObject() { { "url", value } };
|
||||
((JArray)card["images"]).Add(urlObj);
|
||||
}
|
||||
else
|
||||
{
|
||||
// then it's image
|
||||
var urlObj = new JObject() { { "url", value } };
|
||||
card["image"] = urlObj;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case "media":
|
||||
if (card[property] == null)
|
||||
{
|
||||
card[property] = new JArray();
|
||||
}
|
||||
|
||||
var mediaObj = new JObject() { { "url", value } };
|
||||
((JArray)card[property]).Add(mediaObj);
|
||||
break;
|
||||
|
||||
case "buttons":
|
||||
if (card[property] == null)
|
||||
{
|
||||
card[property] = new JArray();
|
||||
}
|
||||
|
||||
foreach (var button in value.Split('|'))
|
||||
{
|
||||
var buttonObj = new JObject() { { "title", button.Trim() }, { "type", "imBack" }, { "value", button.Trim() } };
|
||||
((JArray)card[property]).Add(buttonObj);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case "autostart":
|
||||
case "sharable":
|
||||
case "autoloop":
|
||||
card[property] = value.ToLower() == "true";
|
||||
break;
|
||||
case "":
|
||||
break;
|
||||
default:
|
||||
System.Diagnostics.Debug.WriteLine(string.Format("Skipping unknown card property {0}", property));
|
||||
break;
|
||||
}
|
||||
|
||||
if (lastLine)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return iLine;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generate the activity.
|
||||
/// </summary>
|
||||
|
@ -355,6 +200,161 @@ namespace Microsoft.Bot.Builder.Dialogs
|
|||
}
|
||||
}
|
||||
|
||||
private static int AddJsonAttachment(IMessageActivity activity, string[] lines, int iLine)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (; iLine < lines.Length; iLine++)
|
||||
{
|
||||
if (lines[iLine].TrimEnd() == "]")
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
sb.AppendLine(lines[iLine]);
|
||||
}
|
||||
|
||||
dynamic obj = JsonConvert.DeserializeObject(sb.ToString());
|
||||
string contentType = "application/json";
|
||||
|
||||
if (obj.type == "AdaptiveCard")
|
||||
{
|
||||
contentType = "application/vnd.microsoft.card.adaptive";
|
||||
}
|
||||
|
||||
var attachment = new Attachment(contentType, content: obj);
|
||||
activity.Attachments.Add(attachment);
|
||||
return iLine;
|
||||
}
|
||||
|
||||
private static void AddSuggestions(IMessageActivity activity, string line)
|
||||
{
|
||||
var value = line.Split('=');
|
||||
if (value.Length > 1)
|
||||
{
|
||||
var suggestions = value[1].Split('|');
|
||||
activity.SuggestedActions = new SuggestedActions();
|
||||
activity.SuggestedActions.Actions = suggestions.Select(s =>
|
||||
{
|
||||
var text = s.TrimEnd(']').Trim();
|
||||
return new CardAction(type: ActionTypes.MessageBack, title: text, displayText: text, text: text);
|
||||
}).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
private static void AddAttachmentLayout(IMessageActivity activity, string line)
|
||||
{
|
||||
var value = line.Split('=');
|
||||
if (value.Length > 1)
|
||||
{
|
||||
activity.AttachmentLayout = value[1].TrimEnd(']').Trim();
|
||||
}
|
||||
}
|
||||
|
||||
private static int AddGenericCardAtttachment(IMessageActivity activity, string type, string[] lines, int iLine)
|
||||
{
|
||||
var attachment = new Attachment(type, content: new JObject());
|
||||
iLine = BuildGenericCard(attachment.Content, type, lines, iLine);
|
||||
activity.Attachments.Add(attachment);
|
||||
return iLine;
|
||||
}
|
||||
|
||||
private static int BuildGenericCard(dynamic card, string type, string[] lines, int iLine)
|
||||
{
|
||||
bool lastLine = false;
|
||||
|
||||
for (; !lastLine && iLine < lines.Length; iLine++)
|
||||
{
|
||||
var line = lines[iLine];
|
||||
var start = line.IndexOf('=');
|
||||
if (start > 0)
|
||||
{
|
||||
var property = line.Substring(0, start).Trim().ToLower();
|
||||
var value = line.Substring(start + 1).Trim();
|
||||
if (value.EndsWith("]"))
|
||||
{
|
||||
value = value.TrimEnd(']');
|
||||
lastLine = true;
|
||||
}
|
||||
|
||||
switch (property.ToLower())
|
||||
{
|
||||
case "title":
|
||||
case "subtitle":
|
||||
case "text":
|
||||
case "aspect":
|
||||
case "value":
|
||||
case "connectionName":
|
||||
card[property] = value;
|
||||
break;
|
||||
|
||||
case "image":
|
||||
case "images":
|
||||
if (type == HeroCard.ContentType || type == ThumbnailCard.ContentType)
|
||||
{
|
||||
// then it's images
|
||||
if (card["images"] == null)
|
||||
{
|
||||
card["images"] = new JArray();
|
||||
}
|
||||
|
||||
var urlObj = new JObject() { { "url", value } };
|
||||
((JArray)card["images"]).Add(urlObj);
|
||||
}
|
||||
else
|
||||
{
|
||||
// then it's image
|
||||
var urlObj = new JObject() { { "url", value } };
|
||||
card["image"] = urlObj;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case "media":
|
||||
if (card[property] == null)
|
||||
{
|
||||
card[property] = new JArray();
|
||||
}
|
||||
|
||||
var mediaObj = new JObject() { { "url", value } };
|
||||
((JArray)card[property]).Add(mediaObj);
|
||||
break;
|
||||
|
||||
case "buttons":
|
||||
if (card[property] == null)
|
||||
{
|
||||
card[property] = new JArray();
|
||||
}
|
||||
|
||||
foreach (var button in value.Split('|'))
|
||||
{
|
||||
var buttonObj = new JObject() { { "title", button.Trim() }, { "type", "imBack" }, { "value", button.Trim() } };
|
||||
((JArray)card[property]).Add(buttonObj);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case "autostart":
|
||||
case "sharable":
|
||||
case "autoloop":
|
||||
card[property] = value.ToLower() == "true";
|
||||
break;
|
||||
case "":
|
||||
break;
|
||||
default:
|
||||
System.Diagnostics.Debug.WriteLine(string.Format("Skipping unknown card property {0}", property));
|
||||
break;
|
||||
}
|
||||
|
||||
if (lastLine)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return iLine;
|
||||
}
|
||||
|
||||
private async Task AddAttachment(ITurnContext turnContext, ILanguageGenerator languageGenerator, IMessageActivity activity, string line, object data)
|
||||
{
|
||||
var parts = line.Split('=');
|
||||
|
|
|
@ -672,19 +672,20 @@ namespace Microsoft.Bot.Builder.Expressions
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// walk dialog callstack looking for property.
|
||||
/// Walk dialog callstack looking for property.
|
||||
/// </summary>
|
||||
/// <param name="expression"></param>
|
||||
/// <param name="state"></param>
|
||||
/// <returns></returns>
|
||||
/// <param name="expression">Filter expression.</param>
|
||||
/// <param name="state">Object containing the dialog callstack to search.</param>
|
||||
/// <returns>The property</returns>
|
||||
private static (object value, string error) CallstackScope(Expression expression, object state)
|
||||
{
|
||||
// get collection
|
||||
// get callstack collection?
|
||||
var (result, error) = AccessProperty(state, "callstack");
|
||||
if (result != null)
|
||||
{
|
||||
var items = (IEnumerable<object>)result;
|
||||
object property = null;
|
||||
// Check for a match??
|
||||
(property, error) = expression.Children[0].TryEvaluate(state);
|
||||
if (property != null && error == null)
|
||||
{
|
||||
|
@ -1096,9 +1097,9 @@ namespace Microsoft.Bot.Builder.Expressions
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// return new object list replace jarray.ToArray<object>().
|
||||
/// Return new object list replace jarray.ToArray<object>().
|
||||
/// </summary>
|
||||
/// <param name="instance"></param>
|
||||
/// <param name="instance">List to resolve.</param>
|
||||
/// <returns></returns>
|
||||
private static IList ResolveListValue(object instance)
|
||||
{
|
||||
|
|
|
@ -259,8 +259,8 @@ namespace Microsoft.Bot.Builder.Expressions
|
|||
/// Evaluate the expression.
|
||||
/// </summary>
|
||||
/// <param name="state">
|
||||
/// Global state to evaluate accessor expressions against. Can be <see cref="IDictionary{String, Object}"/>,
|
||||
/// <see cref="IDictionary"/> otherwise reflection is used to access property and then indexer.
|
||||
/// Global state to evaluate accessor expressions against. Can be <see cref="System.Collections.Generic.IDictionary{String, Object}"/>,
|
||||
/// <see cref="System.Collections.IDictionary"/> otherwise reflection is used to access property and then indexer.
|
||||
/// </param>
|
||||
/// <returns>Computed value and an error string. If the string is non-null, then there was an evaluation error.</returns>
|
||||
public (object value, string error) TryEvaluate(object state)
|
||||
|
|
|
@ -21,9 +21,9 @@ namespace Microsoft.Bot.Builder.LanguageGeneration
|
|||
/// <summary>
|
||||
/// Implementation of lookup by locale. This uses internal dictionary to lookup.
|
||||
/// </summary>
|
||||
/// <param name="context">context.</param>
|
||||
/// <param name="context">Context for the current turn of conversation with the user.</param>\
|
||||
/// <param name="locale">locale.</param>
|
||||
/// <param name="generator">generator to return.</param>
|
||||
/// <param name="languageGenerator">generator to return.</param>
|
||||
/// <returns>true if found.</returns>
|
||||
public override bool TryGetGenerator(ITurnContext context, string locale, out ILanguageGenerator languageGenerator)
|
||||
{
|
||||
|
|
|
@ -34,7 +34,10 @@ namespace Microsoft.Bot.Builder.TemplateManager
|
|||
/// <value>
|
||||
/// Template Renderers.
|
||||
/// </value>
|
||||
public List<ITemplateRenderer> Renderers { get { return this.TemplateManager.Renderers; } set { this.TemplateManager.Renderers = value; } }
|
||||
public List<ITemplateRenderer> Renderers
|
||||
{
|
||||
get { return this.TemplateManager.Renderers; } set { this.TemplateManager.Renderers = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets language fallback policy.
|
||||
|
@ -42,7 +45,10 @@ namespace Microsoft.Bot.Builder.TemplateManager
|
|||
/// <value>
|
||||
/// Language fallback policy.
|
||||
/// </value>
|
||||
public List<string> LanguageFallback { get { return this.TemplateManager.LanguageFallback; } set { this.TemplateManager.LanguageFallback = value; } }
|
||||
public List<string> LanguageFallback
|
||||
{
|
||||
get { return this.TemplateManager.LanguageFallback; } set { this.TemplateManager.LanguageFallback = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Records incoming and outgoing activities to the conversation store.
|
||||
|
|
|
@ -66,7 +66,8 @@ namespace Microsoft.Bot.Builder.AI.TriggerTrees.Tests
|
|||
public object Object = null;
|
||||
|
||||
public SimpleValues()
|
||||
{ }
|
||||
{
|
||||
}
|
||||
|
||||
public SimpleValues(int integer)
|
||||
{
|
||||
|
|
|
@ -50,11 +50,17 @@ namespace Microsoft.Bot.Builder.Azure.Tests
|
|||
"21", "22", "23", "24", "25", "26", "27", "28", "29", "30",
|
||||
};
|
||||
|
||||
public string ContainerName { get { return TestContext.TestName.ToLower(); } }
|
||||
public string ContainerName
|
||||
{
|
||||
get { return TestContext.TestName.ToLower(); }
|
||||
}
|
||||
|
||||
public TestContext TestContext { get; set; }
|
||||
|
||||
public AzureBlobTranscriptStore TranscriptStore { get { return new AzureBlobTranscriptStore(ConnectionString, ContainerName); } }
|
||||
public AzureBlobTranscriptStore TranscriptStore
|
||||
{
|
||||
get { return new AzureBlobTranscriptStore(ConnectionString, ContainerName); }
|
||||
}
|
||||
|
||||
// These tests require Azure Storage Emulator v5.7
|
||||
[TestInitialize]
|
||||
|
|
|
@ -39,7 +39,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Composition
|
|||
};
|
||||
var overlay = new Options() { };
|
||||
|
||||
var result = ObjectPath.Merge(defaultOptions,overlay);
|
||||
var result = ObjectPath.Merge(defaultOptions, overlay);
|
||||
Assert.AreEqual(result.LastName, defaultOptions.LastName);
|
||||
Assert.AreEqual(result.FirstName, defaultOptions.FirstName);
|
||||
Assert.AreEqual(result.Age, defaultOptions.Age);
|
||||
|
@ -62,7 +62,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Composition
|
|||
};
|
||||
|
||||
var result = ObjectPath.Merge(defaultOptions, overlay);
|
||||
|
||||
Assert.AreEqual(result.LastName, overlay.LastName);
|
||||
Assert.AreEqual(result.FirstName, overlay.FirstName);
|
||||
Assert.AreEqual(result.Age, overlay.Age);
|
||||
|
|
|
@ -24,7 +24,8 @@ namespace Microsoft.Bot.Builder.Dialogs.Composition.Tests
|
|||
return new RecognizerResult() { Text = this.Id };
|
||||
}
|
||||
|
||||
public async Task<T> RecognizeAsync<T>(ITurnContext turnContext, CancellationToken cancellationToken) where T : IRecognizerConvert, new()
|
||||
public async Task<T> RecognizeAsync<T>(ITurnContext turnContext, CancellationToken cancellationToken)
|
||||
where T : IRecognizerConvert, new()
|
||||
{
|
||||
return new T();
|
||||
}
|
||||
|
|
|
@ -32,7 +32,8 @@ namespace Microsoft.Bot.Builder.Dialogs.Declarative.Tests.Recognizers
|
|||
});
|
||||
}
|
||||
|
||||
public Task<T> RecognizeAsync<T>(ITurnContext turnContext, CancellationToken cancellationToken) where T : IRecognizerConvert, new()
|
||||
public Task<T> RecognizeAsync<T>(ITurnContext turnContext, CancellationToken cancellationToken)
|
||||
where T : IRecognizerConvert, new()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
|
|
@ -19,13 +19,13 @@ namespace Microsoft.Bot.Builder.TestBot.Json.Controllers
|
|||
[ApiController]
|
||||
public class BotController : ControllerBase
|
||||
{
|
||||
private readonly IBotFrameworkHttpAdapter Adapter;
|
||||
private readonly IBot Bot;
|
||||
private readonly IBotFrameworkHttpAdapter adapter;
|
||||
private readonly IBot bot;
|
||||
|
||||
public BotController(IBotFrameworkHttpAdapter adapter, IBot bot)
|
||||
{
|
||||
Adapter = adapter;
|
||||
Bot = bot;
|
||||
this.adapter = adapter;
|
||||
this.bot = bot;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
|
@ -33,7 +33,7 @@ namespace Microsoft.Bot.Builder.TestBot.Json.Controllers
|
|||
{
|
||||
// Delegate the processing of the HTTP POST to the adapter.
|
||||
// The adapter will invoke the bot.
|
||||
await Adapter.ProcessAsync(Request, Response, Bot);
|
||||
await adapter.ProcessAsync(Request, Response, bot);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,7 +35,10 @@ namespace Microsoft.Bot.Builder.TestBot.Json
|
|||
/// <value>
|
||||
/// Javascript bound to memory run function(user, conversation, dialog, turn).
|
||||
/// </value>
|
||||
public string Script { get { return script; } set { LoadScript(value); } }
|
||||
public string Script
|
||||
{
|
||||
get { return script; } set { LoadScript(value); }
|
||||
}
|
||||
|
||||
[JsonConstructor]
|
||||
public JavascriptAction([CallerFilePath] string sourceFilePath = "", [CallerLineNumber] int sourceLineNumber = 0)
|
||||
|
|
|
@ -32,7 +32,10 @@ namespace Microsoft.Bot.Builder.TestBot.Json
|
|||
/// memory path to bind to arg1 (ex: conversation.width).
|
||||
/// </value>
|
||||
[JsonProperty("arg1")]
|
||||
public string Arg1 { get { return this.InputBindings["arg1"]; } set { this.InputBindings["arg1"] = value; } }
|
||||
public string Arg1
|
||||
{
|
||||
get { return this.InputBindings["arg1"]; } set { this.InputBindings["arg1"] = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets memory path to bind to arg2 (ex: conversation.height).
|
||||
|
@ -41,7 +44,10 @@ namespace Microsoft.Bot.Builder.TestBot.Json
|
|||
/// memory path to bind to arg2 (ex: conversation.height).
|
||||
/// </value>
|
||||
[JsonProperty("arg2")]
|
||||
public string Arg2 { get { return this.InputBindings["arg2"]; } set { this.InputBindings["arg2"] = value; } }
|
||||
public string Arg2
|
||||
{
|
||||
get { return this.InputBindings["arg2"]; } set { this.InputBindings["arg2"] = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets caller's memory path to store the result of this step in (ex: conversation.area).
|
||||
|
@ -50,7 +56,10 @@ namespace Microsoft.Bot.Builder.TestBot.Json
|
|||
/// caller's memory path to store the result of this step in (ex: conversation.area).
|
||||
/// </value>
|
||||
[JsonProperty("result")]
|
||||
public string Result { get { return this.OutputBinding; } set { this.OutputBinding = value; } }
|
||||
public string Result
|
||||
{
|
||||
get { return this.OutputBinding; } set { this.OutputBinding = value; }
|
||||
}
|
||||
|
||||
protected override Task<DialogTurnResult> OnRunCommandAsync(DialogContext dc, object options = null, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
|
|
|
@ -10,7 +10,10 @@ namespace Microsoft.Bot.Builder.Tests
|
|||
[TestClass]
|
||||
public class FileTranscriptTests : TranscriptBaseTests
|
||||
{
|
||||
public static string Folder { get { return Path.Combine(Path.GetTempPath(), nameof(FileTranscriptTests)); } }
|
||||
public static string Folder
|
||||
{
|
||||
get { return Path.Combine(Path.GetTempPath(), nameof(FileTranscriptTests)); }
|
||||
}
|
||||
|
||||
[ClassInitialize]
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace Microsoft.Bot.Configuration.Tests
|
|||
[TestClass]
|
||||
public class ConfigurationLoadAndSaveTests
|
||||
{
|
||||
private string TestBotFileName = NormalizePath(@"..\..\..\test.bot");
|
||||
private string testBotFileName = NormalizePath(@"..\..\..\test.bot");
|
||||
private const string OutputBotFileName = "save.bot";
|
||||
|
||||
private static string NormalizePath(string path) => Path.Combine(path.TrimEnd('\\').Split('\\'));
|
||||
|
@ -18,7 +18,7 @@ namespace Microsoft.Bot.Configuration.Tests
|
|||
[TestMethod]
|
||||
public async Task DeserializeBotFile()
|
||||
{
|
||||
var config = await BotConfiguration.LoadAsync(TestBotFileName);
|
||||
var config = await BotConfiguration.LoadAsync(testBotFileName);
|
||||
Assert.AreEqual("test", config.Name);
|
||||
Assert.AreEqual("test description", config.Description);
|
||||
Assert.AreEqual(string.Empty, config.Padlock);
|
||||
|
@ -73,7 +73,7 @@ namespace Microsoft.Bot.Configuration.Tests
|
|||
[TestMethod]
|
||||
public async Task LoadAndSaveUnencryptedBotFile()
|
||||
{
|
||||
var config = await BotConfiguration.LoadAsync(TestBotFileName);
|
||||
var config = await BotConfiguration.LoadAsync(testBotFileName);
|
||||
await config.SaveAsAsync(OutputBotFileName);
|
||||
|
||||
var config2 = await BotConfiguration.LoadAsync(OutputBotFileName);
|
||||
|
@ -84,7 +84,7 @@ namespace Microsoft.Bot.Configuration.Tests
|
|||
[TestMethod]
|
||||
public void LoadAndSaveUnencryptedBotFileSync()
|
||||
{
|
||||
var config = BotConfiguration.Load(TestBotFileName);
|
||||
var config = BotConfiguration.Load(testBotFileName);
|
||||
config.SaveAs(OutputBotFileName);
|
||||
|
||||
var config2 = BotConfiguration.Load(OutputBotFileName);
|
||||
|
@ -95,7 +95,7 @@ namespace Microsoft.Bot.Configuration.Tests
|
|||
public async Task CantLoadWithoutSecret()
|
||||
{
|
||||
string secret = BotConfiguration.GenerateKey();
|
||||
var config = await BotConfiguration.LoadAsync(TestBotFileName);
|
||||
var config = await BotConfiguration.LoadAsync(testBotFileName);
|
||||
await config.SaveAsAsync(OutputBotFileName, secret);
|
||||
|
||||
try
|
||||
|
@ -112,7 +112,7 @@ namespace Microsoft.Bot.Configuration.Tests
|
|||
public async Task LoadFromFolderWithSecret()
|
||||
{
|
||||
string secret = BotConfiguration.GenerateKey();
|
||||
var config = await BotConfiguration.LoadAsync(TestBotFileName);
|
||||
var config = await BotConfiguration.LoadAsync(testBotFileName);
|
||||
await config.SaveAsAsync(OutputBotFileName, secret);
|
||||
await BotConfiguration.LoadFromFolderAsync(".", secret);
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ namespace Microsoft.Bot.Configuration.Tests
|
|||
public void LoadFromFolderWithSecretSync()
|
||||
{
|
||||
string secret = BotConfiguration.GenerateKey();
|
||||
var config = BotConfiguration.Load(TestBotFileName);
|
||||
var config = BotConfiguration.Load(testBotFileName);
|
||||
config.SaveAs(OutputBotFileName, secret);
|
||||
BotConfiguration.LoadFromFolder(".", secret);
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ namespace Microsoft.Bot.Configuration.Tests
|
|||
public async Task FailLoadFromFolderWithNoSecret()
|
||||
{
|
||||
string secret = BotConfiguration.GenerateKey();
|
||||
var config = await BotConfiguration.LoadAsync(TestBotFileName);
|
||||
var config = await BotConfiguration.LoadAsync(testBotFileName);
|
||||
await config.SaveAsAsync(OutputBotFileName, secret);
|
||||
await BotConfiguration.LoadFromFolderAsync(".");
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ namespace Microsoft.Bot.Configuration.Tests
|
|||
[TestMethod]
|
||||
public async Task LoadFromFolderNoSecret()
|
||||
{
|
||||
var config = await BotConfiguration.LoadAsync(TestBotFileName);
|
||||
var config = await BotConfiguration.LoadAsync(testBotFileName);
|
||||
await config.SaveAsAsync(OutputBotFileName);
|
||||
await BotConfiguration.LoadFromFolderAsync(".");
|
||||
}
|
||||
|
@ -147,7 +147,7 @@ namespace Microsoft.Bot.Configuration.Tests
|
|||
[TestMethod]
|
||||
public void LoadFromFolderNoSecretSync()
|
||||
{
|
||||
var config = BotConfiguration.Load(TestBotFileName);
|
||||
var config = BotConfiguration.Load(testBotFileName);
|
||||
config.SaveAs(OutputBotFileName);
|
||||
BotConfiguration.LoadFromFolder(".");
|
||||
}
|
||||
|
@ -184,7 +184,7 @@ namespace Microsoft.Bot.Configuration.Tests
|
|||
public async Task CantSaveWithoutSecret()
|
||||
{
|
||||
string secret = BotConfiguration.GenerateKey();
|
||||
var config = await BotConfiguration.LoadAsync(TestBotFileName);
|
||||
var config = await BotConfiguration.LoadAsync(testBotFileName);
|
||||
await config.SaveAsAsync(OutputBotFileName, secret);
|
||||
|
||||
var config2 = await BotConfiguration.LoadAsync(OutputBotFileName, secret);
|
||||
|
@ -205,7 +205,7 @@ namespace Microsoft.Bot.Configuration.Tests
|
|||
public async Task LoadAndSaveEncrypted()
|
||||
{
|
||||
string secret = BotConfiguration.GenerateKey();
|
||||
var config = await BotConfiguration.LoadAsync(TestBotFileName);
|
||||
var config = await BotConfiguration.LoadAsync(testBotFileName);
|
||||
Assert.AreEqual(string.Empty, config.Padlock, "There should be no padlock");
|
||||
|
||||
// save with secret
|
||||
|
@ -434,7 +434,7 @@ namespace Microsoft.Bot.Configuration.Tests
|
|||
[TestMethod]
|
||||
public void LoadAndVerifyChannelServiceSync()
|
||||
{
|
||||
var publicConfig = BotConfiguration.Load(TestBotFileName);
|
||||
var publicConfig = BotConfiguration.Load(testBotFileName);
|
||||
var endpointSvc = publicConfig.Services.Single(x => x.Type == ServiceTypes.Endpoint) as EndpointService;
|
||||
Assert.IsNotNull(endpointSvc);
|
||||
Assert.IsNull(endpointSvc.ChannelService);
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace Microsoft.Bot.Configuration.Tests
|
|||
[TestClass]
|
||||
public class ConnectionTests
|
||||
{
|
||||
private string TestBotFileName = NormalizePath(@"..\..\..\test.bot");
|
||||
private string testBotFileName = NormalizePath(@"..\..\..\test.bot");
|
||||
|
||||
public static string NormalizePath(string ambigiousPath)
|
||||
{
|
||||
|
@ -31,7 +31,7 @@ namespace Microsoft.Bot.Configuration.Tests
|
|||
[TestMethod]
|
||||
public async Task ConnectAssignsUniqueIds()
|
||||
{
|
||||
var config = await BotConfiguration.LoadAsync(TestBotFileName);
|
||||
var config = await BotConfiguration.LoadAsync(testBotFileName);
|
||||
var config2 = new BotConfiguration();
|
||||
foreach (var service in config.Services)
|
||||
{
|
||||
|
@ -50,7 +50,7 @@ namespace Microsoft.Bot.Configuration.Tests
|
|||
[TestMethod]
|
||||
public async Task FindServices()
|
||||
{
|
||||
var config = await BotConfiguration.LoadAsync(TestBotFileName);
|
||||
var config = await BotConfiguration.LoadAsync(testBotFileName);
|
||||
Assert.IsNotNull(config.FindServiceByNameOrId("3"), "Should find by id");
|
||||
Assert.IsNotNull(config.FindServiceByNameOrId("testInsights"), "Should find by name");
|
||||
Assert.IsNotNull(config.FindService("3"), "Should find by id");
|
||||
|
@ -68,7 +68,7 @@ namespace Microsoft.Bot.Configuration.Tests
|
|||
[TestMethod]
|
||||
public async Task DisconnectServicesById()
|
||||
{
|
||||
var config = await BotConfiguration.LoadAsync(TestBotFileName);
|
||||
var config = await BotConfiguration.LoadAsync(testBotFileName);
|
||||
var config2 = new BotConfiguration();
|
||||
foreach (var service in config.Services)
|
||||
{
|
||||
|
@ -88,7 +88,7 @@ namespace Microsoft.Bot.Configuration.Tests
|
|||
[TestMethod]
|
||||
public async Task DisconnectServicesByNameOrId_UsingId()
|
||||
{
|
||||
var config = await BotConfiguration.LoadAsync(TestBotFileName);
|
||||
var config = await BotConfiguration.LoadAsync(testBotFileName);
|
||||
var config2 = new BotConfiguration();
|
||||
foreach (var service in config.Services)
|
||||
{
|
||||
|
@ -108,7 +108,7 @@ namespace Microsoft.Bot.Configuration.Tests
|
|||
[TestMethod]
|
||||
public async Task DisconnectByNameOrId_UsingName()
|
||||
{
|
||||
var config = await BotConfiguration.LoadAsync(TestBotFileName);
|
||||
var config = await BotConfiguration.LoadAsync(testBotFileName);
|
||||
var config2 = new BotConfiguration();
|
||||
foreach (var service in config.Services)
|
||||
{
|
||||
|
@ -128,7 +128,7 @@ namespace Microsoft.Bot.Configuration.Tests
|
|||
[TestMethod]
|
||||
public async Task DisconnectService_UsingNameAndType()
|
||||
{
|
||||
var config = await BotConfiguration.LoadAsync(TestBotFileName);
|
||||
var config = await BotConfiguration.LoadAsync(testBotFileName);
|
||||
var config2 = new BotConfiguration();
|
||||
foreach (var service in config.Services)
|
||||
{
|
||||
|
@ -154,7 +154,7 @@ namespace Microsoft.Bot.Configuration.Tests
|
|||
public async Task DisconnectByNameOrId_UsingName_WithDuplicates()
|
||||
{
|
||||
// We have a least one duplicate name in the config.
|
||||
var config = await BotConfiguration.LoadAsync(TestBotFileName);
|
||||
var config = await BotConfiguration.LoadAsync(testBotFileName);
|
||||
var config2 = new BotConfiguration();
|
||||
var uniqueNames = new List<string>();
|
||||
var duplicatedNames = new List<string>();
|
||||
|
|
Загрузка…
Ссылка в новой задаче