コード例 #1
0
        public bool Enable()
        {
            try
            {
                IConfiguration Configuration     = SingletonFactory.GetSingleton <T>();
                string         ConfigurationPath = GetConfigurationPath();

                if (!File.Exists(ConfigurationPath))
                {
                    Configuration.LoadDefaults();
                    Disable();
                    return(false);
                }
                else
                {
                    using (FileStream Stream = File.Open(ConfigurationPath, FileMode.Open))
                    {
                        XElement Element = XElement.Load(Stream);
                        foreach (XElement PropertyElement in Element.Elements())
                        {
                            string Section = PropertyElement.Attribute(XName.Get("Section")).Value;
                            string Value   = PropertyElement.Attribute(XName.Get("Value")).Value;

                            Configuration[Section] = Value;
                        }
                    }
                    return(true);
                }
            }
            catch (Exception e)
            {
                LogFactory.GetLog(this).LogFatal(e);
                return(false);
            }
        }