Example #1
0
        public async Task Dump <T>(T context)
        {
            try
            {
                var requestList = "";
                if (context is RequestContext)
                {
                    foreach (var request in (context as RequestContext).RequestData.RequestEnvelope.Requests)
                    {
                        requestList += (requestList == "" ? "" : ", ") + request.RequestType.ToString();
                    }
                    if (requestList != "")
                    {
                        requestList = " " + requestList;
                    }
                }

                var logFilePath = GenerateLogFileName(typeof(T).Name, requestList);
                var sb          = new StringBuilder();
                sb.AppendLine();

                var settings = new JsonSerializerSettings
                {
                    Formatting = Formatting.Indented,
                };
                settings.Converters.Add(new MyConverter());

                sb.AppendLine(JsonConvert.SerializeObject(context, Formatting.Indented, settings));
                //sb.AppendLine("/*** === ***/");
                await FileAsync.WriteTextAsync(logFilePath, sb.ToString(), Encoding.ASCII);
            }
            catch (Exception)
            {
            }
        }
Example #2
0
        public async Task Dump <T>(T context)
        {
            try
            {
                var logFilePath = GenerateLogFileName(typeof(T).Name);
                var sb          = new StringBuilder();
                sb.AppendLine();

                sb.AppendLine(JsonConvert.SerializeObject(context, Formatting.Indented));
                sb.AppendLine("/*** === ***/");
                await FileAsync.WriteTextAsync(logFilePath, sb.ToString(), Encoding.ASCII);
            }
            catch (Exception)
            {
            }
        }