namespace FruitConsignmentManager.Power
{
    using FruitConsignmentManager.Module;
    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Reflection;
    using System.Xml;
    
        public class PowerManager
    {
        private static Dictionary<string, List<PowersData>> _cache = new Dictionary<string, List<PowersData>>();        public static List<PowersData> ReadPowerConfig(string formName)
        {
            List<PowersData> list;
            _cache.TryGetValue(formName, out list);
            if (list == null)
            {
                list = new List<PowersData>();
                List<PowersData> list2 = readPowerXML();
                foreach (PowersData data in list2)
                {
                    if (data.cFormName.Trim().ToLower() == formName.Trim().ToLower())
                    {
                        list.Add(data);
                    }
                }
                _cache.Add(formName, list);
            }
            return list;
        }        public static List<PowerGroupData> ReadPowerGroupConfigByXML()
        {
            List<PowerGroupData> list = new List<PowerGroupData>();
            Stream manifestResourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("FruitConsignmentManager.Power.PowerGroupConfig.xml");
            XmlDocument document = new XmlDocument();
            document.Load(manifestResourceStream);
            XmlNode firstChild = document.FirstChild;
            for (int i = 0; i < firstChild.ChildNodes.Count; i++)
            {
                XmlNode node2 = firstChild.ChildNodes[i];
                foreach (object obj2 in node2.ChildNodes)
                {
                    XmlNode node3 = obj2 as XmlNode;
                    PowerGroupData item = new PowerGroupData {
                        cGroupName = node2.Attributes["Name"].Value,
                        cFormName = node3.Attributes["Name"].Value
                    };
                    list.Add(item);
                }
            }
            return list;
        }        private static List<PowersData> readPowerXML()
        {
            List<PowersData> list = new List<PowersData>();
            Stream manifestResourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("FruitConsignmentManager.Power.PowerConfig.xml");
            XmlDocument document = new XmlDocument();
            document.Load(manifestResourceStream);
            XmlNode firstChild = document.FirstChild;
            for (int i = 0; i < firstChild.ChildNodes.Count; i++)
            {
                XmlNode node2 = firstChild.ChildNodes[i];
                foreach (object obj2 in node2.ChildNodes)
                {
                    XmlNode node3 = obj2 as XmlNode;
                    PowersData item = new PowersData {
                        cFormName = node2.Attributes["Name"].Value,
                        cFormText = node2.Attributes["HeadText"].Value,
                        cControlName = node3.Attributes["Name"].Value,
                        cControlText = node3.Attributes["HeadText"].Value,
                        cPower = node3.Attributes["Power"].Value
                    };
                    list.Add(item);
                }
            }
            return list;
        }
    }
}出错提示如下图