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


C# System.IO.StringReader.ReadToEnd方法代码示例

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


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

示例1: DownloadStringCompleted

		private static void DownloadStringCompleted( object sender, System.Net.DownloadStringCompletedEventArgs e ) {

			if ( e.Error != null ) {

				Utility.ErrorReporter.SendErrorReport( e.Error, Resources.UpdateCheckFailed );
				return;

			}

			if ( e.Result.StartsWith( "<!DOCTYPE html>" ) ) {

				Utility.Logger.Add( 3, Resources.BadUpdateURI );
				return;

			}


			try {

				using ( var sr = new System.IO.StringReader( e.Result ) ) {

					DateTime date = DateTimeHelper.CSVStringToTime( sr.ReadLine() );
					string version = sr.ReadLine();
					string description = sr.ReadToEnd();

					if ( UpdateTime < date ) {

						Utility.Logger.Add( 3, Resources.NewVersionFound + version );

						var result = System.Windows.Forms.MessageBox.Show(
							string.Format( Resources.AskForUpdate,
							version, description ),
							Resources.Update, System.Windows.Forms.MessageBoxButtons.YesNoCancel, System.Windows.Forms.MessageBoxIcon.Information,
							System.Windows.Forms.MessageBoxDefaultButton.Button1 );


						if ( result == System.Windows.Forms.DialogResult.Yes ) {

							System.Diagnostics.Process.Start( "http://github.com/silfumus/ElectronicObserver/releases" );

						} else if ( result == System.Windows.Forms.DialogResult.Cancel ) {

							Utility.Configuration.Config.Life.CheckUpdateInformation = false;

						}

					} else {

						Utility.Logger.Add( 1, Resources.VersionCurrent );

					}

				}

			} catch ( Exception ex ) {

				Utility.ErrorReporter.SendErrorReport( ex, Resources.UpdateConnectionFailed );
			}

		}
开发者ID:silfumus,项目名称:ElectronicObserver,代码行数:60,代码来源:SoftwareInformation.cs

示例2: DownloadStringCompleted

        private static void DownloadStringCompleted( object sender, System.Net.DownloadStringCompletedEventArgs e )
        {
            if ( e.Error != null ) {

                Utility.ErrorReporter.SendErrorReport( e.Error, "アップデート情報の取得に失敗しました。" );
                return;

            }

            if ( e.Result.StartsWith( "<!DOCTYPE html>" ) ) {

                Utility.Logger.Add( 3, "アップデート情報の URI が無効です。" );
                return;

            }

            try {

                using ( var sr = new System.IO.StringReader( e.Result ) ) {

                    DateTime date = DateTimeHelper.CSVStringToTime( sr.ReadLine() );
                    string version = sr.ReadLine();
                    string description = sr.ReadToEnd();

                    if ( UpdateTime < date ) {

                        Utility.Logger.Add( 3, "新しいバージョンがリリースされています! : " + version );

                        var result = System.Windows.Forms.MessageBox.Show(
                            string.Format( "新しいバージョンがリリースされています! : {0}\r\n更新内容 : \r\n{1}\r\nダウンロードページを開きますか?\r\n(キャンセルすると以降表示しません)",
                            version, description ),
                            "アップデート情報", System.Windows.Forms.MessageBoxButtons.YesNoCancel, System.Windows.Forms.MessageBoxIcon.Information,
                            System.Windows.Forms.MessageBoxDefaultButton.Button1 );

                        if ( result == System.Windows.Forms.DialogResult.Yes ) {

                            System.Diagnostics.Process.Start( "http://electronicobserver.blog.fc2.com/" );

                        } else if ( result == System.Windows.Forms.DialogResult.Cancel ) {

                            Utility.Configuration.Config.Life.CheckUpdateInformation = false;

                        }

                    } else {

                        Utility.Logger.Add( 1, "お使いのバージョンは最新です。" );

                    }

                }

            } catch ( Exception ex ) {

                Utility.ErrorReporter.SendErrorReport( ex, "アップデート情報の処理に失敗しました。" );
            }
        }
开发者ID:yukkurikurasu,项目名称:ElectronicObserver,代码行数:57,代码来源:SoftwareInformation.cs

示例3: SetVariableName

 //---------------------------------------------------------------------
 private void SetVariableName()
 {
     System.IO.StringReader strReader = new System.IO.StringReader(line);
     TextReader.SkipWhitespace(strReader);
     varName = TextReader.ReadWord(strReader);
     TextReader.SkipWhitespace(strReader);
     textAfterName = strReader.ReadToEnd();
 }
开发者ID:LANDIS-II-Foundation,项目名称:Core-Utilities-Library,代码行数:9,代码来源:InputLine.cs

示例4: Register

 public void Register(string client)
 {
     if (!serversList.Contains(client) && serversList.Count < serversMaxCount)
     {
         serversList.Add(client);
         const string logFilename = "servers.log";
         System.IO.StringReader sr = new System.IO.StringReader(logFilename);
         bool unique = !(sr.ReadToEnd().Contains(client));
         sr.Close();
         if (unique)
         {
             System.IO.StreamWriter sw = new System.IO.StreamWriter(logFilename, true);
             sw.WriteLine(client);
             sw.Close();
         }
     }
     serversTimestamps[client] = DateTime.Now;
 }
开发者ID:matmas,项目名称:rfgt,代码行数:18,代码来源:List.cs

示例5: CompareViewCode

        private void CompareViewCode(ConnectionType otherConn, List<TableType> thisObjs, List<TableType> otherObjs, StringBuilder builder)
        {
            try
            {
                var helper = new DbHelper(this.dataInfo);
                var otherHelper = new DbHelper(otherConn);
                var views = new List<string>();
                foreach (var thisView in thisObjs)
                {
                    if (otherObjs.FindTable(thisView.Name) != null)
                    {
                        views.Add(thisView.Name);
                        continue;
                    }
                }

                var v_str = "";
                for (var index = 0; index < views.Count; index++)
                {
                    if (index > 0)
                        v_str += ",";

                    v_str += string.Format("'{0}'", views[index]);
                }

                var sql = string.Format(@"SELECT obj.name,m.definition
            FROM sys.sql_modules m JOIN sys.objects obj
            ON m.object_id= obj.object_id
              and obj.type='v'
            and obj.name in ({0}) order by obj.name", v_str);

                var thisDs = helper.ExecuteDataSet(sql);

                var otherDs = otherHelper.ExecuteDataSet(sql);

                for (var index = 0; index < thisDs.Tables[0].Rows.Count; index++)
                {
                    var thisRow = thisDs.Tables[0].Rows[index];
                    var otherRow = otherDs.Tables[0].Rows[index];

                    var thisSql = thisRow["definition"].ToString().Trim();
                    var otherSql = otherRow["definition"].ToString().Trim();

                    var thisReader = new System.IO.StringReader(thisSql);
                    var otherReader = new System.IO.StringReader(otherSql);

                    var thisFirstLine = thisReader.ReadLine().Replace("[", "").Replace("]","");
                    var otherFirstLine = otherReader.ReadLine().Replace("[", "").Replace("]", "");

                    if (thisFirstLine != otherFirstLine)
                    {
                        builder.AppendFormat("View Difference {0}", thisRow["name"].ToString());
                        builder.AppendLine();
                        continue;
                    }

                    var this_ = thisReader.ReadToEnd();
                    var other_ = otherReader.ReadToEnd();

                    if (this_ != other_)
                    {
                        builder.AppendFormat("View Difference {0}", thisRow["name"].ToString());
                        builder.AppendLine();
                        continue;
                    }

                    //if (thisRow["definition"].ToString().Trim() != otherRow["definition"].ToString().Trim())
                    //{
                    //    builder.AppendFormat("View Difference {0}", thisRow["name"].ToString());
                    //    builder.AppendLine();
                    //}
                }

                helper.Close();
                otherHelper.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
开发者ID:koksaver,项目名称:CodeHelper,代码行数:81,代码来源:ConnectionNode.cs

示例6: GetTOXNETInformation

        void GetTOXNETInformation(string compoundName, string casNo)
        {
            // http://toxnet.nlm.nih.gov/cgi-bin/sis/search2/f?./temp/~oiB60G:1
            string uriString = "https://toxgate.nlm.nih.gov/cgi-bin/sis/search2";
            System.Net.HttpWebRequest request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(uriString);
            string postData = "queryxxx=" + casNo;
            postData += "&chemsyn=1";
            postData += "&database=hsdb";
            postData += "&Stemming=1";
            postData += "&and=1";
            postData += "&second_search=1";
            postData += "&gateway=1";
            var data = Encoding.ASCII.GetBytes(postData);
            request.Method = "POST";
            request.ContentType = "application/x-www-form-urlencoded";
            request.ContentLength = data.Length;
            using (var stream = request.GetRequestStream())
            {
                stream.Write(data, 0, data.Length);
            }
            System.Net.HttpWebResponse response = (System.Net.HttpWebResponse)request.GetResponse();
            string responseString = new System.IO.StreamReader(response.GetResponseStream()).ReadToEnd();
            string s1 = responseString.Replace("<br>", "");
            System.Xml.XmlDocument document = new System.Xml.XmlDocument();
            document.Load(new System.IO.StringReader(s1));
            string tempFileName = document.FirstChild["TemporaryFile"].InnerText;
            uriString = "http://toxnet.nlm.nih.gov/cgi-bin/sis/search2/f?" + tempFileName;

            //// Whole Document
            m_hsdbDocumentURL = "http://toxgate.nlm.nih.gov/cgi-bin/sis/search2/r?dbs+hsdb:@[email protected]+" + document.FirstChild["Id"].InnerText.Split(' ')[0];

            // Molecular Formula 
            request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(uriString + ":1:mf");
            response = (System.Net.HttpWebResponse)request.GetResponse();
            string mfResposne = new System.IO.StreamReader(response.GetResponseStream()).ReadToEnd();
            string pattern = "Molecular Formula:</h3>\n<br>\n\\s*(?<1>\\S+)\\s*<br><code><NOINDEX>(?<2>[^\\n]*)</NOINDEX>";
            System.Text.RegularExpressions.Match m = System.Text.RegularExpressions.Regex.Match(mfResposne, pattern,
                       System.Text.RegularExpressions.RegexOptions.IgnoreCase | System.Text.RegularExpressions.RegexOptions.Compiled,
                      TimeSpan.FromSeconds(1));
            this.m_molecularFormula = m.Groups[1].Value;
            this.m_molecularFormulareference = m.Groups[2].Value;


            // AutoIgnition temperature 
            request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(uriString + ":1:auto");
            response = (System.Net.HttpWebResponse)request.GetResponse();
            string autoResposne = new System.IO.StreamReader(response.GetResponseStream()).ReadToEnd();
            pattern = "Autoignition Temperature:</h3>\n<br>\n\\s*(?<1>\\S+)\\s*Deg\\s*(?<2>\\S+)\\s*\\((?<4>\\S+)\\s*deg\\s*(?<5>\\S+)\\s*\\)<br><code><NOINDEX>(?<3>[^\\n]*)</NOINDEX>";
            m = System.Text.RegularExpressions.Regex.Match(autoResposne, pattern,
                       System.Text.RegularExpressions.RegexOptions.IgnoreCase | System.Text.RegularExpressions.RegexOptions.Compiled,
                      TimeSpan.FromSeconds(1));
            if (m.Groups.Count == 1)
            {
                pattern = "Autoignition Temperature:</h3>\n<br>\n\\s*(?<1>\\S+)\\s*Deg\\s*(?<2>\\S+)\\s*<br><code><NOINDEX>(?<3>[^\\n]*)</NOINDEX>";
                m = System.Text.RegularExpressions.Regex.Match(autoResposne, pattern,
                           System.Text.RegularExpressions.RegexOptions.IgnoreCase | System.Text.RegularExpressions.RegexOptions.Compiled,
                          TimeSpan.FromSeconds(1));
            }

            // Chemical Properties 
            request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(uriString + ":1:cpp");
            response = (System.Net.HttpWebResponse)request.GetResponse();
            string propertiesResposne = new System.IO.StreamReader(response.GetResponseStream()).ReadToEnd();

            // Chemical Properties 
            request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(uriString + ":1:ph");
            response = (System.Net.HttpWebResponse)request.GetResponse();
            propertiesResposne = new System.IO.StreamReader(response.GetResponseStream()).ReadToEnd();
            pattern = "pH:\\s*(?<1>\\S+)\\s*(?<2>[^\\n]*)\\s*<NOINDEX>(?<3>[^\\n]*)</NOINDEX>";
            m = System.Text.RegularExpressions.Regex.Match(propertiesResposne, pattern,
                       System.Text.RegularExpressions.RegexOptions.IgnoreCase | System.Text.RegularExpressions.RegexOptions.Compiled,
                      TimeSpan.FromSeconds(1));
            string m_pH = m.Groups[1].Value;
            string m_pHAdditional = m.Groups[2].Value;
            string m_pHReference = m.Groups[3].Value;

            // heat of vaporization: 
            pattern = "Heat of Vaporization:</h3>\\s*<br>\\s*Latent:\\s*(?<1>\\S+)\\s*(?<2>\\S+)\\s*(?<4>[^\\n]*)<br><code><NOINDEX>(?<3>[^\\n]*)</NOINDEX>";
            m = System.Text.RegularExpressions.Regex.Match(propertiesResposne, pattern,
                       System.Text.RegularExpressions.RegexOptions.IgnoreCase | System.Text.RegularExpressions.RegexOptions.Compiled,
                      TimeSpan.FromSeconds(1));
            if (m.Groups.Count == 1)
            {
                pattern = "Heat of Vaporization:</h3>\\s*<br>\\s*Enthalpy of vaporization:\\s*(?<1>\\S+)\\s*(?<2>\\S+)\\s*(?<4>[^\\n]*)<br><code><NOINDEX>(?<3>[^\\n]*)</NOINDEX>";
                m = System.Text.RegularExpressions.Regex.Match(propertiesResposne, pattern,
                           System.Text.RegularExpressions.RegexOptions.IgnoreCase | System.Text.RegularExpressions.RegexOptions.Compiled,
                          TimeSpan.FromSeconds(1));
            }
            if (m.Groups.Count == 1)
            {
                pattern = "Heat of Vaporization:</h3>\\s*<br>\\s*(?<1>\\S+)\\s*(?<2>\\S+)\\s*(?<4>[^\\n]*)<br><code><NOINDEX>(?<3>[^\\n]*)</NOINDEX>";
                m = System.Text.RegularExpressions.Regex.Match(propertiesResposne, pattern,
                           System.Text.RegularExpressions.RegexOptions.IgnoreCase | System.Text.RegularExpressions.RegexOptions.Compiled,
                          TimeSpan.FromSeconds(1));
            }
            m_HeatOfVaporization = m.Groups[1].Value;
            m_HeatOfVaporizationUnit = m.Groups[2].Value;
            if (m_HeatOfVaporizationUnit.ToLower() == "kj/g")
            {
                m_HeatOfVaporization = (Convert.ToDouble(m_HeatOfVaporization) * 1000).ToString();
//.........这里部分代码省略.........
开发者ID:wbarret1,项目名称:ChemicalDataSourcesTestApp,代码行数:101,代码来源:Form1.cs


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