/// <inheritdoc/> public async Task <T> RecognizeAsync <T>(ITurnContext turnContext, CancellationToken cancellationToken) where T : IRecognizerConvert, new() { var result = await RecognizeAsync(turnContext, cancellationToken).ConfigureAwait(false); return(ObjectPath.MapValueTo <T>(result)); }
protected override async Task <MessagingExtensionActionResponse> OnTeamsMessagingExtensionSubmitActionAsync(ITurnContext <IInvokeActivity> turnContext, MessagingExtensionAction action, CancellationToken cancellationToken) { switch (action.CommandId) { // These commandIds are defined in the Teams App Manifest. case TeamsCommands.TakeQuickNote: var quickNote = ObjectPath.MapValueTo <Note>(action.Data); quickNote.Id = Guid.NewGuid().ToString(); quickNote.MessageActionsPayload = new MessageActionsPayload(from: new MessageActionsPayloadFrom(new MessageActionsPayloadUser(displayName: turnContext.Activity.From.Name)), createdDateTime: DateTime.Now.ToString(CultureInfo.InvariantCulture)); // Save the note. await _notesService.AddNoteAsync(quickNote); return(new MessagingExtensionActionResponse()); case TeamsCommands.NoteFromMessage: var newNote = ObjectPath.MapValueTo <Note>(action.Data); newNote.Id = Guid.NewGuid().ToString(); newNote.MessageActionsPayload = action.MessagePayload; // BUG: action.MessagePayload doesn't to have the linkToMessage, so we manually pull it from the value property of the activity. newNote.MessageLinkUrl = JObject.FromObject(turnContext.Activity.Value)["messagePayload"]?["linkToMessage"]?.ToString(); // Save the note. await _notesService.AddNoteAsync(newNote); return(new MessagingExtensionActionResponse()); default: throw new NotImplementedException($"Invalid CommandId: {action.CommandId}"); } }
/// <summary> /// Create the expression for this condition. /// </summary> /// <remarks> /// Override this in base classes to create the expression for this trigger. /// </remarks> /// <returns>Expression used to evaluate this rule. </returns> protected virtual Expression CreateExpression() { var allExpressions = new List <Expression>(); if (this.Condition != null) { allExpressions.Add(this.Condition.ToExpression()); } if (this.extraConstraints.Any()) { allExpressions.AddRange(this.extraConstraints); } if (RunOnce) { allExpressions.Add(new Expression( Expression.Lookup(ExpressionType.Ignore), new Expression(new ExpressionEvaluator( $"runOnce{Id}", (expression, os, _) => { var basePath = $"{AdaptiveDialog.ConditionTracker}.{Id}."; var changed = false; if (os.TryGetValue(basePath + "lastRun", out object val)) { uint lastRun = ObjectPath.MapValueTo <uint>(val); if (os.TryGetValue(basePath + "paths", out val)) { string[] paths = ObjectPath.MapValueTo <string[]>(val); if (paths != null) { foreach (var path in paths) { if (os.TryGetValue($"dialog._tracker.paths.{path}", out val)) { uint current = ObjectPath.MapValueTo <uint>(val); if (current > lastRun) { changed = true; break; } } } } } } return(changed, null); }, ReturnType.Boolean, FunctionUtils.ValidateUnary)))); } if (allExpressions.Any()) { return(Expression.AndExpression(allExpressions.ToArray())); } else { return(Expression.ConstantExpression(true)); } }