コード例 #1
0
        //init
        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)
            {
            }

            return(result);
        }
コード例 #2
0
        //methods
        public bool ParseRequest(string json, out AmazonSesNotification notification)
        {
            notification = null;

            // parse SES message
            AmazonSesNotification amazonSesNotification;
            bool created = AmazonSesNotification.TryCreate(json, out amazonSesNotification);

            if (!created)
            {
                _logger.LogError($"SES json message was not successfuly parsed: {json}");
                return(false);
            }

            notification = amazonSesNotification;
            return(true);
        }