//инициализация public static bool TryCreate(string jsonMessage, out AmazonSesNotification amazonSesNotification) { amazonSesNotification = null; bool result = false; if (string.IsNullOrEmpty(jsonMessage)) return false; try { using (TextReader reader = new StringReader(jsonMessage)) using (var jsonRreader = new Newtonsoft.Json.JsonTextReader(reader)) { var serializer = new Newtonsoft.Json.JsonSerializer(); amazonSesNotification = serializer.Deserialize<AmazonSesNotification>(jsonRreader); } result = true; } catch (Exception ex) { } return result; }
//методы public bool ParseRequest(string json, out AmazonSesNotification notification) { notification = null; //разбор сообщения ses AmazonSesNotification amazonSesNotification; bool created = AmazonSesNotification.TryCreate(json, out amazonSesNotification); if (!created) { if (_logger != null) _logger.Error("Ошибка при разборе json Amazon Ses: {0}", json); return false; } notification = amazonSesNotification; return true; }