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


C# StreamReader.Split方法代码示例

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


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

示例1: GetData

    public void GetData()
    {
        WebRequest request = WebRequest.Create("http://168.63.82.20/api/login?login=sbst&password=ebc1628c26f8515f81a5178a5abfcbd9");
        DoWithResponse(request, (response) => {
            var body = new StreamReader(response.GetResponseStream()).ReadToEnd();
            string[] resp = body.Split('\"');

            GetNext(resp[7], resp[3]);
        });
        //textField.text = temperature;
    }
开发者ID:sbst,项目名称:code,代码行数:11,代码来源:ChangeText.cs

示例2: GetNext

    void GetNext(string user_id,string token)
    {
        WebRequest requestSecond = WebRequest.Create ("http://168.63.82.20/api/thing?user_id=" + user_id + "&token=" + token + "&did=yk5ynj69aw7z");
        DoWithResponse (requestSecond, (response) => {
            var body = new StreamReader (response.GetResponseStream ()).ReadToEnd ();
            string[] resp = body.Split('\"');
            temperature = resp[15] + " C";

        });
        //Debug.Log (temperature);
        //textField.text = temperature;
    }
开发者ID:sbst,项目名称:code,代码行数:12,代码来源:ChangeText.cs

示例3: fillDatabase

            internal static void fillDatabase(Stream stream)
            {
                //Backup
                using (FileStream backup = File.Create("backup.sql"))
                {
                    CopyDatabase(new StreamWriter(backup));
                }
                //Delete old
                List<string> tables = getTables();
                foreach (string name in tables)
                {
                    executeQuery(String.Format("DROP TABLE `{0}`", name));
                }
                //Make new
                string script = new StreamReader(stream).ReadToEnd();
                string[] cmds = script.Split(';');
                 //   StringBuilder sb = new StringBuilder();

                using (DatabaseTransactionHelper helper = DatabaseTransactionHelper.Create())
                {

                    foreach (string cmd in cmds)
                    {
                        String newCmd = cmd.Trim(" \r\n\t".ToCharArray());
                        int index = newCmd.ToUpper().IndexOf("CREATE TABLE");
                        if (index > -1)
                        {
                            newCmd = newCmd.Remove(0, index);
                            //Do we have a primary key?
                            try
                            {
                                if (Server.useMySQL)
                                {
                                    int priIndex = newCmd.ToUpper().IndexOf(" PRIMARY KEY AUTOINCREMENT");
                                    int priCount = " PRIMARY KEY AUTOINCREMENT".Length;
                                    int attIdx = newCmd.Substring(0, newCmd.Substring(0, priIndex - 1).LastIndexOfAny("` \n".ToCharArray())).LastIndexOfAny("` \n".ToCharArray()) + 1;
                                    int attIdxEnd = newCmd.IndexOfAny("` \n".ToCharArray(), attIdx) - 1;
                                    string attName = newCmd.Substring(attIdx, attIdxEnd - attIdx + 1).Trim(' ', '\n', '`', '\r');
                                    //For speed, we just delete this, and add it to the attribute name, then delete the auto_increment clause.
                                    newCmd = newCmd.Remove(priIndex, priCount);
                                    newCmd = newCmd.Insert(newCmd.LastIndexOf(")"), ", PRIMARY KEY (`" + attName + "`)");
                                    newCmd = newCmd.Insert(newCmd.IndexOf(',', priIndex), " AUTO_INCREMENT");

                                }
                                else
                                {
                                    int priIndex = newCmd.ToUpper().IndexOf(",\r\nPRIMARY KEY");
                                    int priIndexEnd = newCmd.ToUpper().IndexOf(')', priIndex);
                                    int attIdx = newCmd.IndexOf("(", priIndex) + 1;
                                    int attIdxEnd = priIndexEnd - 1;
                                    string attName = newCmd.Substring(attIdx, attIdxEnd - attIdx + 1);
                                    newCmd = newCmd.Remove(priIndex, priIndexEnd - priIndex + 1);
                                    int start = newCmd.IndexOf(attName) + attName.Length;
                                    int end = newCmd.IndexOf(',');
                                    newCmd = newCmd.Remove(start, end - start);
                                    newCmd = newCmd.Insert(newCmd.IndexOf(attName) + attName.Length, " INTEGER PRIMARY KEY AUTOINCREMENT");
                                    newCmd = newCmd.Replace(" auto_increment", "").Replace(" AUTO_INCREMENT", "").Replace("True", "1").Replace("False", "0");
                                }
                            }
                            catch (ArgumentOutOfRangeException) { } // If we don't, just ignore it.
                        }
                        //Run the command in the transaction.
                        helper.Execute(newCmd.Replace(" unsigned", "").Replace(" UNSIGNED", "") + ";");
                        //                        sb.Append(newCmd).Append(";\n");
                    }
                    helper.Commit();

                }
                //Not sure if order matters.
                //AUTO_INCREMENT is changed to AUTOINCREMENT for MySQL -> SQLite
                //AUTOINCREMENT is changed to AUTO_INCREMENT for SQLite -> MySQL
                // All we should have in the script file is CREATE TABLE and INSERT INTO commands.
                //executeQuery(sb.ToString().Replace(" unsigned", "").Replace(" UNSIGNED", ""));
            }
开发者ID:Goodlyay,项目名称:MCForge-Vanilla-Redux,代码行数:74,代码来源:Database.cs

示例4: Init

    private void Init(string _url)
    {
        try
        {
            m_uri = new Uri(_url);
            m_links = new List<Link>();
            m_html = "";
            m_outstr = "";
            m_title = "";
            m_good = true;
            if (_url.EndsWith(".rar") || _url.EndsWith(".dat") || _url.EndsWith(".msi"))
            {
                m_good = false;
                return;
            }
            HttpWebRequest rqst = (HttpWebRequest)WebRequest.Create(m_uri);
            rqst.AllowAutoRedirect = true;
            rqst.MaximumAutomaticRedirections = 3;
            rqst.UserAgent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)";
            rqst.KeepAlive = true;
            rqst.Timeout = 10000;
            lock (WebPage.webcookies)
            {
                if (WebPage.webcookies.ContainsKey(m_uri.Host))
                    rqst.CookieContainer = WebPage.webcookies[m_uri.Host];
                else
                {
                    CookieContainer cc = new CookieContainer();
                    WebPage.webcookies[m_uri.Host] = cc;
                    rqst.CookieContainer = cc;
                }
            }
            HttpWebResponse rsps = (HttpWebResponse)rqst.GetResponse();
            Stream sm = rsps.GetResponseStream();
            if (!rsps.ContentType.ToLower().StartsWith("text/") || rsps.ContentLength > 1 << 22)
            {
                rsps.Close();
                m_good = false;
                return;
            }
            Encoding cding = System.Text.Encoding.Default;
            string contenttype = rsps.ContentType.ToLower();
            int ix = contenttype.IndexOf("charset=");
            if (ix != -1)
            {
                try
                {
                    cding = System.Text.Encoding.GetEncoding(rsps.ContentType.Substring(ix + "charset".Length + 1));
                }
                catch
                {
                    cding = Encoding.Default;
                }

                //该处视情况而定 有的需要解码
                //m_html = HttpUtility.HtmlDecode(new StreamReader(sm, cding).ReadToEnd());
                m_html = new StreamReader(sm, cding).ReadToEnd();

            }
            else
            {
                //该处视情况而定 有的需要解码
                //m_html = HttpUtility.HtmlDecode(new StreamReader(sm, cding).ReadToEnd());

                m_html = new StreamReader(sm, cding).ReadToEnd();
                Regex regex = new Regex("charset=(?<cding>[^=]+)?\"", RegexOptions.IgnoreCase);
                string strcding = regex.Match(m_html).Groups["cding"].Value;
                try
                {
                    cding = Encoding.GetEncoding(strcding);
                }
                catch
                {
                    cding = Encoding.Default;
                }
                byte[] bytes = Encoding.Default.GetBytes(m_html.ToCharArray());
                m_html = cding.GetString(bytes);
                if (m_html.Split('?').Length > 100)
                {
                    m_html = Encoding.Default.GetString(bytes);
                }
            }
            m_pagesize = m_html.Length;
            m_uri = rsps.ResponseUri;
            rsps.Close();
        }
        catch (Exception ex)
        {

        }
    }
开发者ID:priceLiu,项目名称:GetWebPage,代码行数:91,代码来源:WegPage.cs


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