public static AmazonSESNotification ParseAmazonSESNotification(string notification, Type type = null) { AmazonSESNotification amazonSESNotification = null; TryParseAmazonSESNotification(notification, out amazonSESNotification, type); return(amazonSESNotification); }
public void ParseDeliveryNotification() { AmazonSESNotification amazonSESNotification = null; var notification = ResourceManager.RetrieveEmbeddedResource("delivery-notification-content.json"); if (null != notification) { amazonSESNotification = AmazonSESNotification.Parse(notification); } Assert.IsTrue(null != amazonSESNotification); }
public void TryParseDeliveryNotification() { AmazonSESNotification amazonSESNotification = null; var notification = ResourceManager.RetrieveEmbeddedResource("delivery-notification-content.json"); var parsed = false; if (null != notification) { parsed = AmazonSESNotification.TryParse(notification, out amazonSESNotification); } Assert.IsTrue(parsed); }
public void SerializeBounceNotification() { AmazonSESBounceNotification amazonSESBounceNotification = null; var notification = ResourceManager.RetrieveEmbeddedResource("bounce-notification-content.json"); if (null != notification) { AmazonSESBounceNotification.Parse(notification); amazonSESBounceNotification = new AmazonSESBounceNotification(notification); } AmazonSESNotification amazonSESNotification = null; bool parsed = AmazonSESBounceNotification.TryParse(notification, out amazonSESNotification); AmazonSESBounceNotification amazonSESBounceNotification2 = amazonSESNotification as AmazonSESBounceNotification; Assert.IsTrue(null != amazonSESBounceNotification); }
public static bool TryParseAmazonSESNotification(string notification, out AmazonSESNotification amazonSESNotification, Type type = null) { amazonSESNotification = null; var settings = new JsonSerializerSettings { MissingMemberHandling = MissingMemberHandling.Error }; #region Deserializing for a specific type if (null != type) { try { amazonSESNotification = JsonConvert.DeserializeObject(notification, type, settings) as AmazonSESNotification; return(true); } catch (Exception ex) { return(false); } } #endregion bool parsed = false; foreach (var t in amazonSESNotificationSubTypes) { try { amazonSESNotification = JsonConvert.DeserializeObject(notification, t, settings) as AmazonSESNotification; parsed = true; break; } catch (Exception ex) { if (ex is JsonSerializationException) { continue; } } } return(parsed); }