예제 #1
0
 private Cards.AdaptiveCard Parse(string json)
 {
     try
     {
         Cards.AdaptiveCardParseResult result = Cards.AdaptiveCard.FromJson(json);
         return(result.Card);
     }
     catch (Exception)
     {
         return(null);
     }
 }
예제 #2
0
        /// <summary>
        /// Parse an AdaptiveCard from a JSON string
        /// </summary>
        /// <param name="json">A JSON-serialized Adaptive Card</param>
        /// <returns></returns>
        public static AdaptiveCardParseResult FromJson(string json)
        {
            var parseResult = new AdaptiveCardParseResult();

            try
            {
                parseResult.Card = JsonConvert.DeserializeObject <AdaptiveCard>(json, new JsonSerializerSettings
                {
                    ContractResolver = new WarningLoggingContractResolver(parseResult, new ParseContext()),
                    Converters       = { new StrictIntConverter() }
                });
            }
            catch (JsonException ex)
            {
                throw new AdaptiveSerializationException(ex.Message, ex);
            }
            return(parseResult);
        }
예제 #3
0
 public WarningLoggingContractResolver(AdaptiveCardParseResult parseResult)
 {
     _parseResult = parseResult;
 }
 public AdaptiveCardConverter(AdaptiveCardParseResult parseResult)
 {
     _parseResult = parseResult;
 }
 public AdaptiveTypedElementConverter(AdaptiveCardParseResult parseResult)
 {
     _parseResult = parseResult;
 }