Пример #1
0
        public static void Initialize(bool newSettings)
        {
            var fields = TypeLoader.GetFields(typeof(Settings), false);

            foreach (var field in fields)
            {
                if (field.IsLiteral || field.IsInitOnly)
                {
                    continue;
                }

                var attributes = field.GetCustomAttributes(typeof(DefaultValueAttribute), false);
                if (attributes.Length != 0)
                {
                    var attribute = (DefaultValueAttribute)attributes[0];
                    field.SetValue(null, attribute.Default);
                }
            }

            if (!newSettings && FileExplorer.Exists(FileExplorer.MainDirectory, "Settings.yaml"))
            {
                load();
            }

            if (KeyDictionary.Count == 0)
            {
                defaultKeys();
            }

            if (FirstStarted)
            {
                Save();
            }
        }