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


C# WebClient.Trim方法代码示例

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


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

示例1: getExternalIPAddressFromWebsite

 public static IPAddress getExternalIPAddressFromWebsite()
 {
     String external_ip_str;
     IPAddress external_ip;
     try
     {
         external_ip_str = new System.Net.WebClient().DownloadString(xbs_upnp.EXTERNAL_IP_WEB_SERVICE);
     }
     catch (WebException)
     {
         xbs_messages.addInfoMessage("!! Could not resolve external IP Address.", xbs_message_sender.UPNP, xbs_message_type.ERROR);
         return null;
     }
     bool ret = IPAddress.TryParse(external_ip_str.Trim(), out external_ip);
     if ( ret )
         xbs_messages.addInfoMessage(" @ discovered external public IP " + external_ip, xbs_message_sender.UPNP);
     return ( ret ? external_ip : null);
 }
开发者ID:Ch0wW,项目名称:XBSlink,代码行数:18,代码来源:xbs_natstun.cs

示例2: ProcessMessage

 public void ProcessMessage(IrcMessageEventArgs args, string @from, string message)
 {
     var ret = new WebClient().DownloadString("http://www.octgn.net/api/stats/usersonlinenow.php");
     Channel.Message("There are " + ret.Trim() + " users online right now.",true);
 }
开发者ID:jonbonne,项目名称:OCTGN,代码行数:5,代码来源:Uo.cs

示例3: stockLookup

        static void stockLookup(string msg)
        {
            // setup vars
            //	string stock = new string(msg.Substring(5).Where(c => Char.IsLetter(c)).ToArray());
            string stock = msg.Substring(5);

            if (stock == "help") {
                botSay("[stock/exchange]name Last Trade (change/change%) Average Daily Volume " +
                    "Market Cap [(high/low)52 week h/l range in %, Short Ratio, 50 day moving average " +
                    "200 day moving average] -");
                botSay("Ratios: Price/Earnings, Earnings/Share, Price/Sales, Price/Earnings Growth, " +
                    "- Other fundamentals: Book Value, EBITDA");
            }

            string url = "http://finance.yahoo.com/d/quotes.csv?s=" + stock +
                "&f=a2b4cej1j4j6k5l1m3m4np5p6rr5ss7xlc6t7";

            // csvSplit() the csv
            string scRes = "";

            try {
                scRes = new WebClient().DownloadString(url);
            } catch (WebException ex) {
                Console.WriteLine("Error ({0}):\n {1}", ex.Source, ex.Message);
                botSay("I threw an ex... I don't feel so well");
                return;
            }

            string[] result;

            if (scRes.Trim('\n','\r') == "Missing Symbols List.") {
                botSay("MSL... whatever");
                return;
            }

            result = csvSplit(",", "\"", scRes);

            // filter out bad results
            if (result[18] == "\"N/A\"") {
                botSay("Lookup of " + stock.ToUpper() + " failed");
            //	botSay(result[result.Length-1]);
                return;
            }

            string sColor = "{dred}";
            if (result[20].Contains("+")) sColor = "{green}";

            // 0	a2
            string sADV = String.Format("{0:n0}", Convert.ToInt32(result[0].Trim(' ', '"')));

            // 1	b4
            string sBV = result[1].Trim('"', ' ');

            // 2	c
            string[] cMod = result[2].Trim('"', ' ').Split(' ');
            string cChangeP = cMod[2];

            // 3	e
            string sES = result[3].Trim('"', ' ');

            // 4	j1
            string sMC = result[4].Trim('"', ' ');

            // 5	j4
            string sEBITDA = result[4].Trim('"', ' ');

            // 6    j6
            string s52WL = result[6].Trim('"', ' ');

            // 7	k5
            string s52WH = result[7].Trim('"', ' ');

            // 8	l1
            // 9	m3
            string s50MA = result[9].Trim('"', ' ');

            // 10	m4
            string s200MA = result[10].Trim('"', ' ');

            // 11	n
            string sName = result[11];

            // 12	p5
            string sPS = result[12].Trim('"', ' ');

            // 13	p6
            // 14	r
            string sPE = result[14].Trim('"', ' ');

            // 15	r5
            string sPEG = result[15].Trim('"', ' ');

            // 16   s
            string sSymbol = result[16].Trim('"', ' ');
            // 17   s7
            string sSR = result[17].Trim('"', ' ');
            // 18	x
            string sExchange = result[18].Trim('"');

            // 19   k1 -> l
//.........这里部分代码省略.........
开发者ID:quiznilo,项目名称:Zerobot,代码行数:101,代码来源:BotLib.cs

示例4: AddEventWithPhoto

 public void AddEventWithPhoto()
 {
     bool s = false;
     dynamic ev;
     var Wc = new WebClient();
     Wc.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
     var firstdata = "grant_type=password&username=" + "TestUserName" + "&password=" + "TestPassword361";
     var result1 = Wc.UploadString(SiteUrl + TokenUrl, firstdata);
     JObject o1 = JObject.Parse(result1);
     var token = o1["access_token"].Value<string>();
     Wc = new WebClient();
     Wc.Encoding = Encoding.UTF8;
     Wc.Headers.Add("Content-Type", "application/json");
     Wc.Headers.Add("Authorization", "Bearer " + token);
     string sdata;
     var photoIds = new string[0];
     var url = new WebClient().DownloadString(new Uri(SiteUrl + "api/Endpoints/GetUploadUrl/AddEvent"));
     url = url.Trim(new char[] { '\"' });
     url = url.TrimStart(new char[] { '/' });
     using (var client = new HttpClient())
     {
         MultipartFormDataContent form = new MultipartFormDataContent();
         client.DefaultRequestHeaders.TryAddWithoutValidation("Authorization", "Bearer " + token);
         var fs = new FileStream("C:\\Users\\Александр\\Desktop\\kompot.jpg", FileMode.Open);
         form.Add(new StreamContent(fs), "file", "file.jpg");
         fs = new FileStream("C:\\Users\\Александр\\Desktop\\qRISsLk7j3E.jpg", FileMode.Open);
         form.Add(new StreamContent(fs), "file", "file.jpg");
         var response = client.PostAsync(SiteUrl + url, form).Result;
         sdata = response.Content.ReadAsStringAsync().Result;
     }
     using (var client = new HttpClient())
     {
         client.DefaultRequestHeaders.TryAddWithoutValidation("Authorization", "Bearer " + token);
         var content = new StringContent(sdata, Encoding.UTF8, "application/json");
         var response = client.PostAsync(SiteUrl
                                 + "api/Endpoints/SaveUploadedFile/AddEvent", content).Result;
         sdata = response.Content.ReadAsStringAsync().Result;
         photoIds = JArray.Parse(sdata).Select(tok => (tok as JObject)["Id"].Value<string>()).ToArray();
     }
     try
     {
         var time = System.DateTime.Now.ToString("u");
         var data = JsonConvert.SerializeObject(new
         {
             Latitude = 76,
             Longitude = 92,
             Description = "TestEvent",
             EventDate = time,
             PhotoIds = photoIds
         });
         var result = Wc.UploadString(SiteUrl + AddEventUrl, data);
     }
     catch(WebException we)
     {
         Assert.Fail(we.Message);
     }
 }
开发者ID:nbIxMaN,项目名称:HomeWork,代码行数:57,代码来源:UnitTest1.cs


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