1

我目前正在使用 XDocument 读取 xml 文件。XML 是在一个带参数的方法中读取的,目前看起来像这样:

private MyXmlFiles_Row GetXmlData(int Year, TAN ANAG, TVerdTyp VerdTyp) {

    XDocument loadedCustomData = XDocument.Load("XML\\MyXmlFiles.xml");
    XName SucheName = "MyXmlFiles";
        IEnumerable<MyXmlFiles_Row> filteredData = from query in loadedCustomData.Descendants(SucheName)
        where query.Element("Year").Value == Year.ToString().Trim() && query.Element("TAN").Value == ANAG.ToString().Trim() && query.Element("TVerdTyp").Value == VerdTyp.ToString().Trim()
        select new BeitrProzent_Row(    
                    Convert.ToDouble(query.Element("One").Value, CultureInfo.InvariantCulture),
                    Convert.ToDouble(query.Element("Two").Value, CultureInfo.InvariantCulture),
                    Convert.ToDouble(query.Element("Three").Value, CultureInfo.InvariantCulture),
                    Convert.ToDouble(query.Element("Four").Value, CultureInfo.InvariantCulture),
                    Convert.ToDouble(query.Element("Five").Value, CultureInfo.InvariantCulture));

    return filteredData.ElementAt(0);
}

如何异步加载 xml 文件(或使用 BackgroundWorker)?

4

0 回答 0