Пример #1
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="applicationUri">Application URI</param>
        /// <param name="masterKey">Master Key</param>
        /// <param name="applicationKey">Application Key</param>
        /// <param name="authenticationToken">Authentication Token</param>
        public MobileServiceClient(Uri applicationUri, string masterKey = null,
                                                        string applicationKey = null,                                             
                                                        string authenticationToken = null)
        {
            if (applicationUri == null)
                throw new ArgumentNullException("applicationUri parameter cannot be null");

            this.applicationUri = applicationUri;

            this.masterKey = masterKey;
            this.applicationKey = applicationKey;
            this.authenticationToken = authenticationToken;

            // create HTTP client and assign send/receive body callbacks
            this.httpClient = new HttpClient();
            this.httpClient.SendBody += httpClient_SendBody;
            this.httpClient.RecvBody += httpClient_RecvBody;

            // create HTTP request
            this.httpRequest = new HttpRequest();
            this.PrepareZumoHeaders();

            this.body = new StringBuilder();
            this.buffer = new byte[BUFFER_SIZE];

            this.uri = new StringBuilder();
        }
Пример #2
0
 void httpClient_SendBody(HttpRequest httpReq)
 {
     // send request body (if exists)
     if (this.body.Length > 0)
     {
         byte[] buffer = Encoding.UTF8.GetBytes(this.body.ToString());
         httpReq.Body.Write(buffer, 0, buffer.Length);
     }
 }