ここでの考え方は、呼び出し元がAfterHTMLPieceHandler
ループのサイクルごとに実装できるようにすることです。それが正しいのか、それともイベントの挿入またはデリゲートであるべきなのかはわかりません。正直なところ、違いはわかりませんが、これは別の質問です。
//? Should it be static?
public static class PageScan
{
public delegate string AfterHTMLPieceHandler();
public static string GetHTML(string url)
{
HttpWebRequest wRequest = (HttpWebRequest)WebRequest.Create(url);
wRequest.Method = "GET";
HttpWebResponse wResponse = (HttpWebResponse)wRequest.GetResponse();
StreamReader sReader = new StreamReader(wResponse.GetResponseStream());
string html = sReader.ReadToEnd();
sReader.Close();
wResponse.Close();
sReader.Dispose();
return html;
}
public static void GetPiecesOfHtml(string html, string constantHtml)
{
while (html.IndexOf("http://portfoliopad.com/images/") > -1)
{
// it will retrieve a piece of html given the constantHtml and remove from html in order to break the loop in the end
//How Do I hit the event for each time one cycle of the loop ends?
}
}
}