Exemplo n.º 1
0
        public static string Serialize(WebRequest request)
        {
            if (request == null)
                throw new ArgumentNullException("request");

            var info = new WebUrlInfo
            {
                Url = request.RequestUri.ToString()
            };

            var credentials = request.Credentials
                as NetworkCredential;

            if (credentials != null)
            {
                info.User = credentials.UserName;
                info.Domain = credentials.Domain;
                info.Password = credentials.Password;
            }

            return JsonConvert.SerializeObject(info);
        }
Exemplo n.º 2
0
        public static string Serialize(WebRequest request)
        {
            if (request == null)
            {
                throw new ArgumentNullException("request");
            }

            var info = new WebUrlInfo
            {
                Url = request.RequestUri.ToString()
            };

            var credentials = request.Credentials
                              as NetworkCredential;

            if (credentials != null)
            {
                info.User     = credentials.UserName;
                info.Domain   = credentials.Domain;
                info.Password = credentials.Password;
            }

            return(JsonConvert.SerializeObject(info));
        }