예제 #1
0
        internal bool LoadConfig(IniConfig config)
        {
            bool success = true;

            // panels
            {
                bool valid = true;
                for (int i = 0; i < _panels.Count; i++)
                {
                    EditorPanel panel = _panels[i];

                    string stringValue = config.Read(EditorConfigSections.PanelsOpen, panel.GetType().Name);

                    if (String.IsNullOrEmpty(stringValue))
                    {
                        continue;
                    }

                    if (bool.TryParse(stringValue, out bool val))
                    {
                        panel.Open = val;
                    }
                    else if (stringValue == "null")
                    {
                        panel.Open = null;
                    }
                    else
                    {
                        valid = false;
                        continue;
                    }
                }

                if (!valid)
                {
                    EditorApplication.Log.Trace($"invalid config section '{EditorConfigSections.PanelsOpen}'");
                }

                success = success && valid;
            }

            return(success);
        }
예제 #2
0
파일: App.xaml.cs 프로젝트: Mniwyl/FreeMet
        private bool CheckUserData()
        {
            bool valid = false;

            string dir      = Path.Combine(Environment.CurrentDirectory, ApplicationData.ConfigPath);
            string filePath = Path.Combine(dir, "FreeMet.ini");

            if (!File.Exists(filePath))
            {
                IniConfig.CreateIni(dir, "FreeMet.ini");
                return(false);
            }

            ApplicationData.Instance.Token = IniConfig.Read("Token", "Token", "", filePath);
            int.TryParse(IniConfig.Read("ExpireTime", "ExpireTime", "", filePath), out int expire);
            ApplicationData.Instance.ExpireTime = expire;

            return(valid);
        }