public void DownloadAsync() { DownloadConfig config = new DownloadConfig() { URL = Url, GUID = "TestFile", CacheFilePath = Application.dataPath + "/TestFile" }; loader = new FileDownLoader(config) { Async = true }; loader.OnComplete.AddEventListener((l) => { Debug.Log("Complete filepath:" + loader.config.CacheFilePath); }); loader.OnError.AddEventListener((l) => { Debug.Log(loader.ErrorStr); }); loader.OnCancel.AddEventListener((l) => { Debug.Log("OnCancel"); }); loader.Execute(); Debug.Log("Call End"); }
public DownloadCore(string url, string pathToCopy, int depthCosntraint, DomainWidth domainConsraint, IEnumerable <string> extentions) { _startUrl = url; _depthConstraint = new DepthConstraint(depthCosntraint); _consoleLogger = ConsoleLogger.CreateInstance(); _urlParser = new UrlParser(pathToCopy); _fileDownLoader = new FileDownLoader(_urlParser, new ExtentionsConstraint(extentions), _consoleLogger); _fileSaver = new FileSaver(_urlParser, _consoleLogger); _linkWorker = new LinkWorker(_urlParser, new DomainConsraint(domainConsraint, url)); }
public void Download() { DownloadConfig config = new DownloadConfig() { URL = Url, GUID = "TestFile", CacheFilePath = Application.dataPath + "/TestFile" }; downLoader = new FileDownLoader(config); downLoader.OnError.AddEventListener((l) => { Debug.Log(l.ErrorStr); }); downLoader.OnComplete.AddEventListener((l) => { Debug.Log("Complete filepath:" + (l as FileDownLoader).config.CacheFilePath); }); downLoader.Execute(); Debug.Log("Call End"); }
static void Main(string[] args) { var downLoader = new FileDownLoader { HostAddress = "http://laod.cn/hosts/2015-google-hosts.html" }; Console.WriteLine("开始检索hosts文件,请稍等..."); var watcher = new System.Diagnostics.Stopwatch(); watcher.Start(); downLoader.FileDownLoad(); watcher.Stop(); Console.WriteLine("下载用时:" + watcher.Elapsed); var parser = new CommonLabelPraser(); watcher.Reset(); watcher.Start(); var col = downLoader.LabelPrase<ATag>(parser); watcher.Stop(); Console.WriteLine("解析用时:" + watcher.Elapsed); Address addr = col.GetMostPossibleAddress(); downLoader.HostAddress = addr.Href; Console.WriteLine(downLoader.HostAddress); Console.WriteLine("即将下载hosts文件"); watcher.Reset(); watcher.Start(); downLoader.FileDownLoad(); var updater = new FileUpdater(); updater.UpdateFile(downLoader.HtmlContent); watcher.Stop(); Console.WriteLine("下载并替换用时:" + watcher.Elapsed ); Console.WriteLine("更新本地hosts文件完成"); Console.ReadKey(); }