コード例 #1
0
ファイル: Utils.cs プロジェクト: Sp1rit/Logify.Alert.Clients
 public static void SerializeCookieInfo(IRequestCookieCollection cookies, IgnorePropertiesInfo ignoreInfo, ILogger logger)
 {
     if (cookies != null && cookies.Count != 0)
     {
         try {
             logger.BeginWriteObject("cookie");
             foreach (string key in cookies.Keys)
             {
                 string cookie = cookies[key];
                 logger.BeginWriteObject(key);
                 //logger.WriteValue("domain", cookie.Domain);
                 //logger.WriteValue("expires", cookie.Expires.ToString());
                 logger.WriteValue("name", key);
                 //logger.WriteValue("secure", cookie.Secure);
                 //logger.WriteValue("value", cookie.Value);
                 if (ignoreInfo != null && ignoreInfo.ShouldIgnore(key))
                 {
                     logger.WriteValue("value", RequestBodyFilter.ValueStripped);
                 }
                 else
                 {
                     logger.WriteValue("value", cookie);
                 }
                 logger.EndWriteObject(key);
             }
         }
         finally {
             logger.EndWriteObject("cookie");
         }
     }
 }
コード例 #2
0
        public static Dictionary <string, string> SerializeInfo(NameValueCollection info, string name, IgnorePropertiesInfo ignoreInfo, ILogger logger)
        {
            Dictionary <string, string> result = null;

            if (info != null && info.Count != 0)
            {
                try {
                    logger.BeginWriteObject(name);
                    foreach (string key in info.AllKeys)
                    {
                        if (ignoreInfo != null && ignoreInfo.ShouldIgnore(key))
                        {
                            if (result == null)
                            {
                                result = new Dictionary <string, string>();
                            }
                            result[key] = info.Get(key);

                            logger.WriteValue(key, RequestBodyFilter.ValueStripped);
                        }
                        else
                        {
                            logger.WriteValue(key, info.Get(key));
                        }
                    }
                }
                finally {
                    logger.EndWriteObject(name);
                }
            }
            return(result);
        }
コード例 #3
0
ファイル: Utils.cs プロジェクト: Sp1rit/Logify.Alert.Clients
        static Dictionary <string, string> SerializeInfoCore(IEnumerable <KeyValuePair <string, StringValues> > info, string name, IgnorePropertiesInfo ignoreInfo, ILogger logger)
        {
            if (info == null)
            {
                return(null);
            }

            Dictionary <string, string> result = null;
            int written = 0;

            try {
                foreach (KeyValuePair <string, StringValues> pair in info)
                {
                    if (written == 0)
                    {
                        logger.BeginWriteObject(name);
                    }
                    written++;
                    if (ignoreInfo != null && ignoreInfo.ShouldIgnore(pair.Key))
                    {
                        if (result == null)
                        {
                            result = new Dictionary <string, string>();
                        }
                        result[pair.Key] = pair.Value.ToString();

                        logger.WriteValue(pair.Key, RequestBodyFilter.ValueStripped);
                    }
                    else
                    {
                        logger.WriteValue(pair.Key, pair.Value.ToString());
                    }
                }
            }
            finally {
                if (written > 0)
                {
                    logger.EndWriteObject(name);
                }
            }
            return(result);
        }