/// <summary> /// Converts JSON property to adaptive card TextBlock element. /// </summary> /// <param name="cardElementTemplate">TextBlock item element json property.</param> /// <returns>Returns adaptive card TextBlock item element.</returns> public static AdaptiveTextBlock ConvertToAdaptiveTextBlock(string cardElementTemplate) { var result = JsonConvert.DeserializeObject <Dictionary <string, string> >(cardElementTemplate); bool isVisible = true; if (!string.IsNullOrEmpty(CardHelper.TryParseTicketDetailsKeyValuePair(result, "isVisible"))) { bool status = bool.TryParse(CardHelper.TryParseTicketDetailsKeyValuePair(result, "isVisible"), out isVisible); } string color = CardHelper.TryParseTicketDetailsKeyValuePair(result, "color"); AdaptiveTextColor textColor; if (CardHelper.TryParseTicketDetailsKeyValuePair(result, "id") == CardConstants.DateValidationMessageId) { textColor = AdaptiveTextColor.Attention; } else { textColor = string.IsNullOrEmpty(color) ? AdaptiveTextColor.Default : (AdaptiveTextColor)Enum.Parse(typeof(AdaptiveTextColor), color); } return(new AdaptiveTextBlock() { Id = CardHelper.TryParseTicketDetailsKeyValuePair(result, "id"), Text = CardHelper.TryParseTicketDetailsKeyValuePair(result, "text"), IsVisible = isVisible, Color = textColor, }); }
/// <summary> /// Converts JSON property to adaptive card DateInput element. /// </summary> /// <param name="cardElementTemplate">DateInput item element json property.</param> /// <returns>Returns adaptive card DateInput item element.</returns> public static AdaptiveDateInput ConvertToAdaptiveDateInput(string cardElementTemplate) { var result = JsonConvert.DeserializeObject <Dictionary <string, string> >(cardElementTemplate); return(new AdaptiveDateInput() { Id = CardHelper.TryParseTicketDetailsKeyValuePair(result, "id"), Placeholder = CardHelper.TryParseTicketDetailsKeyValuePair(result, "placeholder"), Value = CardHelper.TryParseTicketDetailsKeyValuePair(result, "value"), Max = CardHelper.TryParseTicketDetailsKeyValuePair(result, "max"), Min = CardHelper.TryParseTicketDetailsKeyValuePair(result, "min"), }); }
/// <summary> /// Converts JSON property to adaptive card DateInput element. /// </summary> /// <param name="cardElementTemplate">DateInput item element json property.</param> /// <returns>Returns adaptive card DateInput item element.</returns> public static AdaptiveDateInput ConvertToAdaptiveDateInput(string cardElementTemplate) { var result = JsonConvert.DeserializeObject <Dictionary <string, string> >(cardElementTemplate); return(new AdaptiveDateInput() { Id = CardHelper.TryParseTicketDetailsKeyValuePair(result, "id"), Placeholder = CardHelper.TryParseTicketDetailsKeyValuePair(result, "placeholder"), Value = string.IsNullOrEmpty(CardHelper.TryParseTicketDetailsKeyValuePair(result, "value")) ? DateTime.Now.ToString(CultureInfo.InvariantCulture) : CardHelper.TryParseTicketDetailsKeyValuePair(result, "value"), Max = CardHelper.TryParseTicketDetailsKeyValuePair(result, "max"), Min = CardHelper.TryParseTicketDetailsKeyValuePair(result, "min"), }); }