本文整理汇总了C#中System.IO.StreamReader.Replace方法的典型用法代码示例。如果您正苦于以下问题:C# System.IO.StreamReader.Replace方法的具体用法?C# System.IO.StreamReader.Replace怎么用?C# System.IO.StreamReader.Replace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.StreamReader
的用法示例。
在下文中一共展示了System.IO.StreamReader.Replace方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Get_Login
void Get_Login()
{
if (IsLogin) { return; }
stt1.Visible = true;
stt1.Text = "Đang kiểm tra tài khoản...";
Application.DoEvents();
var request = (HttpWebRequest)WebRequest.Create(host + "/taikhoan/login");
request.CookieContainer = cookieContainer;
var postData = "username=" + txtID.Text + "&password=" + txtPW.Text;
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);
}
var response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode == HttpStatusCode.OK)
{
var responseString = new System.IO.StreamReader(response.GetResponseStream()).ReadToEnd();
string json = responseString.Replace("\n", "").Replace("\t", "").Replace("\"", "'").Replace(" ", " ").Replace(" ", " ").Replace(" ", " ");
if (FuncHelp.CutFromTo(json, "'user_type':'", "'") == "1")
{
stt1.Visible = false;
IsLogin = true;
}
else
{
MessageBox.Show("Tài khoản đăng nhập hoặc Mật khẩu không chính xác!!!");
IsStop = true;
stt1.Text = "";
}
}
}
示例2: GetToxData
void GetToxData(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);
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.WebResponse 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 = "https://toxgate.nlm.nih.gov/cgi-bin/sis/search2/f?" + tempFileName;
// EcoTox
request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(uriString + ":1:etxv");
response = (System.Net.HttpWebResponse)request.GetResponse();
string ecoToxResposne = new System.IO.StreamReader(response.GetResponseStream()).ReadToEnd();
string pattern = "LC50; Species:\\s*(?<1>[^\\n]*)\\s*[,;] Conditions:\\s*(?<2>[^\\n]*)\\s*[,;] Concentration:\\s*(?<3>\\S+)\\s*(?<4>\\S+)\\s*for\\s*(?<5>[^\\n]*)\\s*<br><code><NOINDEX>\\s*(?<6>[^\\n]*)\\s*</NOINDEX>";
System.Text.RegularExpressions.MatchCollection matchColl = System.Text.RegularExpressions.Regex.Matches(ecoToxResposne, pattern,
System.Text.RegularExpressions.RegexOptions.IgnoreCase | System.Text.RegularExpressions.RegexOptions.Compiled,
TimeSpan.FromSeconds(1));
double lc50 = 1000000.0;
System.Text.RegularExpressions.Match lc50Match = null;
foreach (System.Text.RegularExpressions.Match match in matchColl)
{
string lc50STR = match.Groups[3].Value;
lc50STR = lc50STR.Replace(">", "");
lc50STR = lc50STR.Replace("<", "");
double conc = Convert.ToDouble(lc50STR);
string unit = match.Groups[4].Value;
if (string.Compare(unit, "mg/l", true) == 0)
{
if (conc < lc50)
{
lc50 = conc;
lc50Match = match;
}
}
else if (string.Compare(unit, "ug/l", true) == 0)
{
{
if (conc / 1000 < lc50) lc50 = conc / 1000;
lc50Match = match;
}
}
}
string lc50Value = string.Empty;
string lc50Reference = string.Empty;
if (lc50Match != null)
{
lc50Value = lc50Match.Groups[3].Value;
lc50Reference = "Species: " + lc50Match.Groups[1].Value + "; Conditions: " + lc50Match.Groups[2].Value + "; Time: " + lc50Match.Groups[5].Value + "; Reference: " + lc50Match.Groups[6].Value;
}
//pattern = "EC50; Species:\\s*(?<1>[^\\n]*)\\s*[,;] Conditions:\\s*(?<2>[^\\n]*)\\s*[,;] Concentration:\\s*(?<3>[^\\n]*)\\s*for\\s*(?<4>[^\\n]*)\\s*[,;] Effect: \\s*(?<5>[^\\n]*)\\s*<br><code><NOINDEX>\\s*(?<6>[^\\n]*)\\s*</NOINDEX>";
//matchColl = System.Text.RegularExpressions.Regex.Matches(ecoToxResposne, pattern,
// System.Text.RegularExpressions.RegexOptions.IgnoreCase | System.Text.RegularExpressions.RegexOptions.Compiled,
// TimeSpan.FromSeconds(1));
// NonHuman Tox
request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(uriString + ":1:ntxv");
response = (System.Net.HttpWebResponse)request.GetResponse();
string nonHumanToxResposne = new System.IO.StreamReader(response.GetResponseStream()).ReadToEnd();
pattern = "LD50\\s*(?<1>\\S+)\\s*oral\\s*[(>)\\s*]\\s*(?<2>\\S+)\\s*(?<3>\\S+)\\s*<br><code><NOINDEX>\\s*(?<4>[^\\n]*)\\s*</NOINDEX>";
matchColl = System.Text.RegularExpressions.Regex.Matches(nonHumanToxResposne, pattern,
System.Text.RegularExpressions.RegexOptions.IgnoreCase | System.Text.RegularExpressions.RegexOptions.Compiled,
TimeSpan.FromSeconds(1));
double ld50Oral = 1000000.0;
System.Text.RegularExpressions.Match ld50OralMatch = null;
foreach (System.Text.RegularExpressions.Match match in matchColl)
{
string ld50STR = match.Groups[2].Value;
ld50STR = ld50STR.Replace(">", "");
ld50STR = ld50STR.Replace("<", "");
double conc = 0;
if (!double.TryParse(ld50STR, out conc))
{
string[] values = ld50STR.Split('-');
double.TryParse(values[0], out conc);
}
string unit = match.Groups[3].Value;
//.........这里部分代码省略.........
示例3: ToxnetHSDBButton_Click_1
private void ToxnetHSDBButton_Click_1(object sender, EventArgs e)
{
string uriString = "https://toxgate.nlm.nih.gov/cgi-bin/sis/search2";
System.Net.HttpWebRequest request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(uriString);
request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(uriString);
string postData = "queryxxx=" + m_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.WebResponse response = (System.Net.HttpWebResponse)request.GetResponse();
string responseString = new System.IO.StreamReader(response.GetResponseStream()).ReadToEnd();
string s1 = responseString.Replace("<br>", "");
var XMLReader = new System.Xml.XmlTextReader(new System.IO.StringReader(s1));
System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(QueryResult));
if (serializer.CanDeserialize(XMLReader))
{
// Synonyms means more than one name for the same chemical/CAS Number.
QueryResult result = (QueryResult)serializer.Deserialize(XMLReader);
uriString = "https://toxgate.nlm.nih.gov/cgi-bin/sis/search2/f?" + result.TemporaryFile;
string[] ids = result.Id.Split(' ');
System.Diagnostics.Process.Start("http://toxgate.nlm.nih.gov/cgi-bin/sis/search2/r?dbs+hsdb:@[email protected]+" + ids[0]);
}
}
示例4: 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();
//.........这里部分代码省略.........