daily pastebin goal
4%
SHARE
TWEET

StringRequestParameter

a guest Mar 29th, 2014 175 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. namespace Zelka.Apis
  2. {
  3.     using System.IO;
  4.     using System.Text;
  5.  
  6.     public class StringRequestParameter : IRequestParameter
  7.     {
  8.         public StringRequestParameter(string key, string value)
  9.         {
  10.             this.Key = key;
  11.             this.Value = value;
  12.         }
  13.  
  14.         public string Value { get; set; }
  15.  
  16.         public string Key { get; set; }
  17.  
  18.         public void WriteToStream(Stream stream, string boundary, Encoding encoding)
  19.         {
  20.             const string template = "--{0}\r\nContent-Disposition: form-data; name=\"{1}\"\r\n\r\n{2}";
  21.             string postData = string.Format(template, boundary, this.Key, this.Value);
  22.  
  23.             stream.Write(encoding.GetBytes(postData), 0, encoding.GetByteCount(postData));
  24.         }
  25.     }
  26. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top