当前位置: 首页>>代码示例>>C#>>正文


C# NameValueCollection.ConstructQueryString方法代码示例

本文整理汇总了C#中System.Collections.Specialized.NameValueCollection.ConstructQueryString方法的典型用法代码示例。如果您正苦于以下问题:C# NameValueCollection.ConstructQueryString方法的具体用法?C# NameValueCollection.ConstructQueryString怎么用?C# NameValueCollection.ConstructQueryString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Collections.Specialized.NameValueCollection的用法示例。


在下文中一共展示了NameValueCollection.ConstructQueryString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SendPassword

        private static string SendPassword(string username, string encryptedBase64, Dictionary<string, object> loginParams)
        {
            // Send the RSA-encrypted password via POST.
            var webRequest = WebRequest.Create(API_DO_LOGIN) as HttpWebRequest;
            webRequest.Method = "POST";

            var timestamp = loginParams["timestamp"] as string;

            var fields = new NameValueCollection();
            fields.Add("username", username);
            fields.Add("password", encryptedBase64);
            fields.Add("emailauth", String.Empty);
            fields.Add("captchagid", String.Empty);
            fields.Add("captcha_text", String.Empty);
            fields.Add("emailsteamid", String.Empty);
            fields.Add("rsatimestamp", timestamp);

            var query = fields.ConstructQueryString();
            var queryData = Encoding.ASCII.GetBytes(query);

            webRequest.ContentType = "application/x-www-form-urlencoded";
            webRequest.ContentLength = queryData.Length;
            webRequest.CookieContainer = new CookieContainer();

            // Write the request
            using (Stream stream = webRequest.GetRequestStream())
            {
                stream.Write(queryData, 0, queryData.Length);
            }

            // Perform the request
            var response = webRequest.GetResponse() as HttpWebResponse;

            String res;
            using (Stream stream = response.GetResponseStream())
            {
                res = stream.ReadAll();
            }

            response.Close();

            var reader = new JsonReader();
            var results = reader.Read<Dictionary<string, object>>(res);

            return response.Cookies["steamLogin"].Value;
        }
开发者ID:ampped101,项目名称:SteamBot,代码行数:46,代码来源:WebLogin.cs

示例2: SetRequestCommonFields

        void SetRequestCommonFields(
            HttpWebRequest request, Action<NameValueCollection> headersCallback)
        {
            var fields = new NameValueCollection();
            fields.Add("sessionid", LoginData.SessionId);
            fields.Add("logpos", NextLogPos.ToString());
            fields.Add("version", Version.ToString());

            if (headersCallback != null)
                headersCallback(fields);

            var query = fields.ConstructQueryString();
            var queryData = Encoding.ASCII.GetBytes(query);

            request.ContentType = "application/x-www-form-urlencoded";
            request.ContentLength = queryData.Length;

            try
            {
                // Write the request
                using (Stream stream = request.GetRequestStream())
                    stream.Write(queryData, 0, queryData.Length);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Could not write query data to request: {0}",
                    ex.ToString());
            }
        }
开发者ID:KimimaroTsukimiya,项目名称:SteamBot-1,代码行数:29,代码来源:Trade.cs

示例3: GetKeyRSA

        private static Dictionary<string, object> GetKeyRSA(string username)
        {
            // First ask the public RSA key for encryption.
            var webRequest = WebRequest.Create(API_RSA_KEY) as HttpWebRequest;
            webRequest.Method = "POST";

            var fields = new NameValueCollection();
            fields.Add("username", username);

            var query = fields.ConstructQueryString();
            byte[] data = Encoding.ASCII.GetBytes(query);

            webRequest.ContentType = "application/x-www-form-urlencoded";
            webRequest.ContentLength = data.Length;

            // Write the request
            using (Stream stream = webRequest.GetRequestStream())
            {
                stream.Write(data, 0, data.Length);
            }

            // Perform the request
            var response = webRequest.GetResponse();

            String res;
            using (Stream stream = response.GetResponseStream())
            {
                res = stream.ReadAll();
            }

            response.Close();

            var reader = new JsonReader();
            var json = reader.Read<Dictionary<string, object>>(res);

            return json;
        }
开发者ID:ampped101,项目名称:SteamBot,代码行数:37,代码来源:WebLogin.cs

示例4: LoadForeignInventory

        /// <summary>
        /// Sends a load theirs inventory request.
        /// </summary>
        public void LoadForeignInventory(SteamID backpackId, int appid, int contextid)
        {
            var service = string.Format(TradeURLAction, "foreigninventory");
            var webRequest = CreateSteamRequest(service, LoginData);

            var fields = new NameValueCollection();
            fields.Add("sessionid", LoginData.SessionId);
            fields.Add("steamid", backpackId.ConvertToUInt64().ToString());
            fields.Add("appid", appid.ToString());
            fields.Add("contextid", contextid.ToString());

            var query = fields.ConstructQueryString();
            var queryData = Encoding.ASCII.GetBytes(query);

            webRequest.ContentType = "application/x-www-form-urlencoded";
            webRequest.ContentLength = queryData.Length;

            // Write the request
            using (Stream stream = webRequest.GetRequestStream())
            {
                stream.Write(queryData, 0, queryData.Length);
            }

            // Perform the request
            var res = webRequest.BeginGetResponse(
                new AsyncCallback(ProcessForeignInventory), webRequest);
        }
开发者ID:KimimaroTsukimiya,项目名称:SteamBot-1,代码行数:30,代码来源:Trade.cs


注:本文中的System.Collections.Specialized.NameValueCollection.ConstructQueryString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。