C2dmSharp.Server.C2dmMessage.GetPostData C# (CSharp) Метод

GetPostData() приватный Метод

private GetPostData ( ) : string
Результат string
        internal string GetPostData()
        {
            var sb = new StringBuilder();

            sb.AppendFormat("registration_id={0}&collapse_key={1}&", //&auth={2}&",
                HttpUtility.UrlEncode(this.RegistrationId),
                HttpUtility.UrlEncode(this.CollapseKey)
                //HttpUtility.UrlEncode(this.GoogleLoginAuthorizationToken)
                );

            if (this.DelayWhileIdle.HasValue)
                sb.AppendFormat("delay_while_idle={0}&", this.DelayWhileIdle.Value ? "true" : "false");

            foreach (var key in this.Data.AllKeys)
            {
                sb.AppendFormat("data.{0}={1}&",
                    HttpUtility.UrlEncode(key),
                    HttpUtility.UrlEncode(this.Data[key]));
            }

            //Remove trailing & if necessary
            if (sb.Length > 0 && sb[sb.Length - 1] == '&')
                sb.Remove(sb.Length - 1, 1);

            return sb.ToString();
        }

Usage Example

        static void send(C2dmMessage msg, string googleLoginAuthorizationToken, string senderID, string applicationID)
        {
            C2dmMessageTransportResponse result = new C2dmMessageTransportResponse();

            result.Message = msg;

            var postData = msg.GetPostData();

            var webReq = (HttpWebRequest)WebRequest.Create(C2DM_SEND_URL);

            //webReq.ContentLength = postData.Length;
            webReq.Method      = "POST";
            webReq.ContentType = "application/x-www-form-urlencoded";
            webReq.UserAgent   = "C2DM-Sharp (version: 1.0)";
            webReq.Headers.Add("Authorization: GoogleLogin auth=" + googleLoginAuthorizationToken);

            webReq.BeginGetRequestStream(new AsyncCallback(requestStreamCallback), new C2dmAsyncParameters()
            {
                WebRequest      = webReq,
                WebResponse     = null,
                Message         = msg,
                GoogleAuthToken = googleLoginAuthorizationToken,
                SenderId        = senderID,
                ApplicationId   = applicationID
            });
        }
All Usage Examples Of C2dmSharp.Server.C2dmMessage::GetPostData