예제 #1
0
 public static bool TryParseJson <T>(this TwinCollection twinCollection, string property, ILogger?logger, [NotNullWhen(true)] out T?value)
 {
     value = default;
     if (twinCollection.TryReadJsonBlock(property, out var json))
     {
         try
         {
             value = JsonSerializer.Deserialize <T>(json);
         }
         catch (JsonException ex)
         {
             logger?.LogError(ex, $"Failed to parse '{property}'. We expect type '{typeof(T)}'");
         }
     }
     return(value != null);
 }