本文整理汇总了C#中System.IO.StreamReader.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# StreamReader.Equals方法的具体用法?C# StreamReader.Equals怎么用?C# StreamReader.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.StreamReader
的用法示例。
在下文中一共展示了StreamReader.Equals方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Fetch
internal static IEnumerable<string[]> Fetch(string uri)
{
string[] res;
using(var x = new StreamReader(WebRequest.Create(uri).GetResponse().GetResponseStream()))
res = x.EnumerateLines().ToArray();
var s = new List<string>();
foreach(var x in res)
{
if(x.Equals("----") || x.Equals(res.Last()))
{
yield return s.ToArray();
s.Clear();
}
else
s.Add(x);
}
}
示例2: AssembleMCPCharacterCharacters
/// <summary>
/// NOTE: Relies on the results from CombineMCPComicsData
/// </summary>
/// <param name="pathDataDir"></param>
private static void AssembleMCPCharacterCharacters(string pathDataDir)
{
Console.WriteLine("Starting character-characters data assembling . . .");
int countProcessedCharacter = 0;
int totalNumCharacters = FileManager.GetNumLinesInCSV(FileManager.GetPathResultCharComics(pathDataDir));
using (StreamWriter writer = new StreamWriter(FileManager.GetPathResultCharChars(pathDataDir), false))
{
string pathCharComics = FileManager.GetPathResultCharComics(pathDataDir);
FileStream outerFileStream = new FileStream(pathCharComics, FileMode.OpenOrCreate, FileAccess.Read, FileShare.Read);
using (StreamReader outerReader = new StreamReader(outerFileStream))
{
while (!outerReader.EndOfStream)
{
string outerInput = outerReader.ReadLine();
if (!outerReader.Equals(String.Empty))
{
Console.WriteLine(String.Format("Processing character #{0} of {1}", countProcessedCharacter, totalNumCharacters));
++countProcessedCharacter;
string[] testCharData = outerInput.Split(',');
string testCharId = testCharData[0];
HashSet<string> testCharComics = new HashSet<string>();
for (int i = 1; i < testCharData.Length; ++i)
{
testCharComics.Add(testCharData[i]);
}
writer.Write(testCharId);
// Check overlapping with all characters
FileStream innerFileStream = new FileStream(pathCharComics, FileMode.OpenOrCreate, FileAccess.Read, FileShare.Read);
using (StreamReader innerReader = new StreamReader(innerFileStream))
{
while (!innerReader.EndOfStream)
{
string innerInput = innerReader.ReadLine();
if (!innerInput.Equals(String.Empty))
{
string[] nextCharData = innerInput.Split(',');
string nextCharId = nextCharData[0];
if (!nextCharId.Equals(testCharId))
{
HashSet<string> nextCharComics = new HashSet<string>();
for (int i = 1; i < nextCharData.Length; ++i)
{
nextCharComics.Add(nextCharData[i]);
}
if (testCharComics.Overlaps(nextCharComics))
{
writer.Write(String.Format(",{0}", nextCharId));
}
}
}
}
}
writer.WriteLine();
}
}
}
}
Console.WriteLine("Finished character-characters data assembling.");
}
示例3: report_Click
private void report_Click(object sender, EventArgs e)
{
if (agree.Checked && reason.Text != "")
{
WebRequest.DefaultWebProxy = gui.proxy;
HtmlWeb htmlWeb = new HtmlWeb();
htmlWeb.UserAgent = "DaRT 0.6";
HtmlAgilityPack.HtmlDocument doc = htmlWeb.Load("http://www.gametracker.com/server_info/" + reporter + ":" + port + "/server_variables/");
HtmlNode rootNode = doc.DocumentNode;
HtmlNodeCollection table = rootNode.SelectNodes("//table[@class='table_lst table_lst_gse']//tr//td[@class='c02']");
String servername = null;
String signature = null;
if (table != null)
{
foreach (HtmlNode node in table)
{
if (node.InnerHtml.Contains("hostname"))
{
servername = node.InnerText.Trim();
}
else if (node.InnerHtml.Contains("signatures"))
{
signature = node.InnerText.Trim();
}
}
}
if (servername == null)
{
servername = "N/A";
}
if (signature == null)
{
signature = "N/A";
}
String data = String.Format("key={0}&reporter={1}&port={2}&ip={3}&guid={4}&name={5}&reason={6}&url={7}&servername={8}&signature={9}", "d2kso2laoxp2ld8fmy4qk2js8rl5kf7r", reporter, port, ip, guid, name, reason.Text, "", servername, signature);
ServicePointManager.ServerCertificateValidationCallback += new System.Net.Security.RemoteCertificateValidationCallback(certCheck);
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("https://forum.swisscraft.eu/DaRT report.php");
request.Proxy = gui.proxy;
request.KeepAlive = false;
request.ProtocolVersion = HttpVersion.Version10;
request.Method = "POST";
request.UserAgent = "DaRT " + gui.version;
byte[] postBytes = Encoding.ASCII.GetBytes(data);
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = postBytes.Length;
Stream requestStream = request.GetRequestStream();
requestStream.Write(postBytes, 0, postBytes.Length);
requestStream.Close();
HttpWebResponse responseStream = (HttpWebResponse)request.GetResponse();
String response = new StreamReader(responseStream.GetResponseStream()).ReadToEnd();
responseStream.Close();
if (response.Equals("OK"))
{
gui.Invoke((MethodInvoker)delegate
{
gui.Log("Player has been reported.", LogType.Console, false);
});
}
else if (response.Equals("Already reported"))
{
gui.Invoke((MethodInvoker)delegate
{
gui.Log("You can not report a player two times.", LogType.Console, false);
});
}
else if (response.Equals("Blacklisted"))
{
gui.Invoke((MethodInvoker)delegate
{
gui.Log("It appears you are blacklisted, you can not report players.", LogType.Console, false);
});
}
else if (response.Equals("No valid server"))
{
gui.Invoke((MethodInvoker)delegate
{
gui.Log("It appears that your server is not a valid, whitelisted DayZ server or is not listed on GameTracker.", LogType.Console, false);
gui.Log("Please register your server at GameTracker in order to use this feature. http://www.gametracker.com/server_info/" + reporter + ":" + port + "/", LogType.Console, false);
});
}
else
{
gui.Invoke((MethodInvoker)delegate
{
gui.Log("An error occurred. Please report this to me:", LogType.Console, false);
gui.Log(response, LogType.Console, false);
});
}
this.Close();
//.........这里部分代码省略.........