Example #1
0
        private static byte[] GetContentByteArray(IEnumerable <KeyValuePair <string, string> > nameValueCollection, Encoding encoding = null)
        {
            if (nameValueCollection == null)
            {
                throw new ArgumentNullException("nameValueCollection");
            }
            StringBuilder stringBuilder = new StringBuilder();

            foreach (KeyValuePair <string, string> current in nameValueCollection)
            {
                if (stringBuilder.Length > 0)
                {
                    stringBuilder.Append('&');
                }

                stringBuilder.Append(OEliteFormUrlEncodedContent.Encode(current.Key));
                stringBuilder.Append('=');
                stringBuilder.Append(OEliteFormUrlEncodedContent.Encode(current.Value));
            }
            encoding = encoding ?? Encoding.UTF8;
            return(encoding.GetBytes(stringBuilder.ToString()));
        }
Example #2
0
 public OEliteFormUrlEncodedContent(IEnumerable <KeyValuePair <string, string> > nameValueCollection)
     : base(OEliteFormUrlEncodedContent.GetContentByteArray(nameValueCollection))
 {
     base.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/x-www-form-urlencoded");
 }