예제 #1
0
        public void LoadConfiguration()
        {
            Log.Message("Loading configuration...");

            foreach (var svc in serviceList)
            {
                string name    = GetConfigPath(string.Format("Config.{0}.xml", svc.GetType().Name));
                var    cfgProp = GameService.GetConfigProperty(svc.GetType());

                if (cfgProp == null)
                {
                    continue;
                }

                Log.Message("Loading : {0}", name);

                Directory.CreateDirectory(Path.GetDirectoryName(name));

                try {
                    var cfg = LoadFromXml(cfgProp.PropertyType, name);
                    cfgProp.SetValue(svc, cfg);
                } catch (Exception ex) {
                    Log.Warning("Failed to load configuration:");
                    Log.Warning(ex.Message);
                }
            }
        }
예제 #2
0
        public void SaveConfiguration()
        {
            Log.Message("Saving configuration...");

            foreach (var svc in serviceList)
            {
                string name    = GetConfigPath(string.Format("Config.{0}.xml", svc.GetType().Name));
                var    cfgProp = GameService.GetConfigProperty(svc.GetType());

                if (cfgProp == null)
                {
                    continue;
                }

                Log.Message("Saving : {0}", name);

                Directory.CreateDirectory(Path.GetDirectoryName(name));

                try {
                    SaveToXml(cfgProp.GetValue(svc), cfgProp.PropertyType, name);
                } catch (Exception ex) {
                    Log.Error("Failed to save configuration:");
                    Log.Error(ex.Message);
                }
            }
        }