Ejemplo n.º 1
0
        async Task <XmlDocument> GetExplainDomAsync(string name,
                                                    string type,
                                                    string expainUrl)
        {
            // 先看看缓存文件是否存在
            string cacheFileName = MakeCacheFileName(name, type);

            if (File.Exists(cacheFileName))
            {
                XmlDocument result = new XmlDocument();
                result.Load(cacheFileName);
                return(result);
            }
            else
            {
                var download_result = await WebClientEx.DownloadStringAsync(expainUrl).ConfigureAwait(false);

                File.WriteAllText(cacheFileName, download_result.String, download_result.Encoding);
                XmlDocument result = new XmlDocument();
                result.LoadXml(download_result.String);
                return(result);
            }
        }