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


C# HttpClient.Split方法代码示例

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


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

示例1: TestSendingEmailAndPhoneCall

        internal void TestSendingEmailAndPhoneCall()
        {
            Console.WriteLine("TestSendingEmail started.");
            Utils.Logger.Info("TestSendingEmail() START");
            DailyMorningTimer_Elapsed(null);

            //string biduDelayedPriceCSV = new WebClient().DownloadString("http://download.finance.yahoo.com/d/quotes.csv?s=BIDU&f=sl1d1t1c1ohgv&e=.csv");
            //string biduDelayedPriceCSV = new WebClient().DownloadString("http://finance.yahoo.com/d/quotes.csv?s=BIDU&f=sl1d1t1c1ohgv&e=.csv");
            var biduDelayedPriceCSV = new HttpClient().GetStringAsync("http://finance.yahoo.com/d/quotes.csv?s=BIDU&f=sl1d1t1c1ohgv&e=.csv").Result;
            string[] biduDelayedPriceSplit = biduDelayedPriceCSV.Split(new char[] { ',', ' ' });
            double realTimePrice = Double.Parse(biduDelayedPriceSplit[1]);

            double dailyChange = Double.Parse(biduDelayedPriceSplit[4]);
            double yesterdayClose = realTimePrice - dailyChange;
            double todayPercentChange = realTimePrice / yesterdayClose - 1;
            Console.WriteLine("BIDU %change: " + (todayPercentChange * 100).ToString("0.00") + @"%");
            Utils.Logger.Info("BIDU %change: " + (todayPercentChange * 100).ToString("0.00") + @"%");
            //if (Math.Abs(todayPercentChange) >= 0.04)
            if (Math.Abs(todayPercentChange) >= 0.00)
            {
                new Email { ToAddresses = Utils.Configuration["EmailGyantal"], Subject = "OvermindServer: BIDU price % move", Body = "BIDU price % move. In percentage: " + (todayPercentChange * 100).ToString("0.00") + @"%", IsBodyHtml = false }.Send();

                Console.WriteLine("Email was sent.");
                Utils.Logger.Info("Email was sent.");

                var call = new PhoneCall
                {
                    FromNumber = Caller.Gyantal,
                    ToNumber = PhoneCall.PhoneNumbers[Caller.Gyantal],
                    Message = "This is a warning notification from SnifferQuant. There's a large up or down movement in the ticker B I D U. ... I repeat the ticker: B I D U.",
                    NRepeatAll = 2
                };
                // skipped temporarily
                bool phoneCallSuccess = call.MakeTheCall();
                Console.WriteLine("Phonecall success: " + phoneCallSuccess);
                Utils.Logger.Info("Phonecall success: " + phoneCallSuccess);
            }

            Console.WriteLine("TestSendingEmail Finished.");
            Utils.Logger.Info("TestSendingEmail() END");
        }
开发者ID:gyantal,项目名称:SQLab,代码行数:41,代码来源:Controller.cs

示例2: GetTodayPctChange

 private static double GetTodayPctChange(string p_ticker)
 {
     Utils.Logger.Trace("GetTodayPctChange(): " + p_ticker);
     var biduDelayedPriceCSV = new HttpClient().GetStringAsync("http://download.finance.yahoo.com/d/quotes.csv?s=" + p_ticker + "&f=sl1d1t1c1ohgv&e=.csv").Result;
     Utils.Logger.Trace("HttpClient().GetStringAsync returned: " + biduDelayedPriceCSV);
     string[] biduDelayedPriceSplit = biduDelayedPriceCSV.Split(new char[] { ',', ' ' });
     double realTimePrice = Double.Parse(biduDelayedPriceSplit[1]);
     double dailyChange = Double.Parse(biduDelayedPriceSplit[4]);
     double yesterdayClose = realTimePrice - dailyChange;
     double todayPercentChange = realTimePrice / yesterdayClose - 1;
     return todayPercentChange;
 }
开发者ID:gyantal,项目名称:SQLab,代码行数:12,代码来源:Controller.cs


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