Esempio n. 1
0
        public static ResponseExplanation From(Explanation explanation, bool isDebugEnabled)
        {
            if (explanation == null)
            {
                return(null);
            }

            var response = new ResponseExplanation
            {
                Message   = explanation.Message,
                Type      = GetRealTypeName(explanation.GetType()),
                DebugData = isDebugEnabled ? explanation.InternalMessage : null,
                Data      = explanation.Data
            };

            if (explanation.Details.Any())
            {
                var details = new List <ResponseExplanation>();
                foreach (var detail in explanation.Details)
                {
                    details.Add(ResponseExplanation.From(detail, isDebugEnabled));
                }

                response.Details = details;
            }

            return(response);
        }