public static HttpTxtInfo Allocate(string m_srcUrl, WebRequestTextEvent webRequestTextEvent, bool returnPathOrCon = false, string m_savePath = "", WebRequestProcessEvent processEvent = null) { HttpTxtInfo httpTxtInfo = new HttpTxtInfo(); httpTxtInfo.m_srcUrl = m_srcUrl; httpTxtInfo.m_savePath = m_savePath; httpTxtInfo.returnPathOrCon = returnPathOrCon; httpTxtInfo.webRequestTextEvent = webRequestTextEvent; httpTxtInfo.processEvent = processEvent; return(httpTxtInfo); }
/// <summary> /// 默认返回获取到的内容 /// </summary> /// <param name="m_srcUrl"></param> /// <param name="webRequestTextEvent"></param> /// <param name="returnPathOrCon"></param> /// <param name="m_savePath"></param> /// <param name="processEvent"></param> public void StartDownReturnPathOrContent(string m_srcUrl, WebRequestTextEvent webRequestTextEvent, bool returnPathOrCon = false, string m_savePath = "", WebRequestProcessEvent processEvent = null) { if (JudgeNetworkState()) { if (!URLToHttpBase.ContainsKey(m_srcUrl)) { HttpTxt httpTxt = new HttpTxt(HttpTxtInfo.Allocate(m_srcUrl, webRequestTextEvent, returnPathOrCon, m_savePath, processEvent)); AddRequest(m_srcUrl, httpTxt); } } else { webRequestTextEvent("", DownStatus.NoNetwork, ""); } }
public override void DownloadFinish() { base.DownloadFinish(); HttpTxtInfo httpTxtInfo = (HttpTxtInfo)httpInfo; if (httpTxtInfo.webRequestTextEvent != null) { if (httpTxtInfo.returnPathOrCon) { httpTxtInfo.webRequestTextEvent.Invoke(m_saveFilePath, downResult, downError); } else { if (downResult == DownStatus.Fail) { httpTxtInfo.webRequestTextEvent.Invoke("", downResult, downError); } else { httpTxtInfo.webRequestTextEvent.Invoke(FileHelper.ReadTxtToStr(m_saveFilePath), downResult, downError); } } } }
public HttpTxt(HttpTxtInfo httpTxtInfo) : base(httpTxtInfo) { }