读取XML

    public sealed class ConfigManger
    {
        public XDocument XmlDocs { set; get; }

        string path = @"{0}\Configuration\Server\{1}";
        public ConfigManger()
        {
            LoadFiles();
        }

        public static ConfigManger Instance
        {
            get
            {
                return ConfigCreateXML.Singleton;
            }
        }

        public class ConfigCreateXML
        {

            static ConfigCreateXML() { }

            internal static readonly ConfigManger Singleton = new ConfigManger();
        }

        void LoadFiles()
        {
            string filePath = string.Format(path, AppDomain.CurrentDomain.BaseDirectory, "ServerPath.config");
            if (XmlDocs == null)
            {
                XmlDocs = XDocument.Load(filePath);
            }
        }
    }

 

posted on 2013-11-02 15:57  无觉-李敏  阅读(217)  评论(1编辑  收藏  举报