-1

ここでの考え方は、呼び出し元が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?
        }
    }
}
4

1 に答える 1

0

デリゲートの使用に関する参考資料は、Delegates についてです。例の主要部分にあるデリゲート インスタンスと、それがデリゲートが指しているメソッドにどのように関連付けられているかに注意してください。これが役立つことを願っています。

于 2013-03-24T00:12:44.277 に答える