|
xml文件读:
- public void ReadXml(string xmlPath, ref Dictionary<string, string> imageProcessParams)
- {
- try
- {
- XElement xRoot = XElement.Load(xmlPath);
- IEnumerable<XElement> xAlgorithms = xRoot.Elements("Algorithm");
- List<Tuple<string,string,string>> AlgorithmsParametersInfo=(from i in xAlgorithms
- select Tuple.Create<string,string,string>(
- i.Attribute("dllName").Value,
- i.Attribute("className").Value,
- i.Attribute("algorithmName").Value)).ToList();
- //var AlgorithmData = (from i in xRoot.Elements("Algorithm")
- // where i.Attribute("className").Value=="ysw_threshold"
- // select i).ToList();
- //List<Tuple<string, string>> paramList = (from i in AlgorithmData.Elements("Params").Elements("Item")
- // select Tuple.Create(i.Attribute("name").Value,
- // i.Attribute("defaultValue").Value
- // )).ToList();
- List<Tuple<string, string>> paramList = (from i in xAlgorithms.Elements("Params").Elements("Item")
- select Tuple.Create(i.Attribute("name").Value,
- i.Attribute("defaultValue").Value
- )).ToList();
- imageProcessParams = null;
- imageProcessParams = new Dictionary<string, string>();
- imageProcessParams.Clear();
- foreach (var item in paramList)
- {
- imageProcessParams.Add(item.Item1, item.Item2);
- }
- }
- catch (Exception ex)
- {
- }
- }
复制代码
|
|