示例#1
0
文件: Settings.cs 项目: bakern/FTPbox
        public static void Load()
        {
            Log.Write(l.Debug, "Settings file path: {0}", ConfGeneral);
            Log.Write(l.Debug, "Profiles file path: {0}", ConfProfiles);
            Log.Write(l.Debug, "Certificates file path: {0}", ConfCertificates);

            if (!Directory.Exists(Common.AppdataFolder)) Directory.CreateDirectory(Common.AppdataFolder);

            Profiles = new List<AccountController>();
            General = new SettingsGeneral();
            TrustedCertificates = new List<string>();

            Profiles.Add(new AccountController());

            if (!File.Exists(ConfGeneral)) return;
            // Load General Settings
            var config = File.ReadAllText(ConfGeneral);
            if (!string.IsNullOrWhiteSpace(config))
                General = (SettingsGeneral)JsonConvert.DeserializeObject(config, typeof(SettingsGeneral));
            
            if (!File.Exists(ConfProfiles)) return;
            // Load Profiles
            config = File.ReadAllText(ConfProfiles);
            if (!string.IsNullOrWhiteSpace(config))
                Profiles = (List<AccountController>)JsonConvert.DeserializeObject(config, typeof(List<AccountController>));

            //TODO: Profile.Load();

            if (!File.Exists(ConfCertificates)) return;
            // Load trusted certificates
            config = File.ReadAllText(ConfCertificates);
            if (!string.IsNullOrWhiteSpace(config))
                TrustedCertificates = (List<string>)JsonConvert.DeserializeObject(config, typeof(List<string>));

            Log.Write(l.Info, "Settings Loaded.");
        }
示例#2
0
        public static void Load()
        {
            Log.Write(l.Debug, "Settings file path: {0}", confGeneral);
            Log.Write(l.Debug, "Profiles file path: {0}", confProfiles);
            Log.Write(l.Debug, "Certificates file path: {0}", confCertificates);

            if (!Directory.Exists(Profile.AppdataFolder)) Directory.CreateDirectory(Profile.AppdataFolder);

            Profiles = new List<SettingsProfile>();
            settingsGeneral = new SettingsGeneral();
            TrustedCertificates = new List<string>();

            Profiles.Add(new SettingsProfile());

            #if !__MonoCs__
            if (File.Exists(xmlDocumentPath) && !File.Exists(confProfiles) && !File.Exists(confGeneral))
            {
                LoadXmlSettings();
                Log.Write(l.Debug, "Loaded xml settings, should delete the xml file now...");
                return;
            }
            #endif

            if (!File.Exists(confGeneral)) return;
            // Load General Settings
            string config = File.ReadAllText(confGeneral);
            if (!string.IsNullOrWhiteSpace(config))
                settingsGeneral = (SettingsGeneral)JsonConvert.DeserializeObject(config, typeof(SettingsGeneral));

            if (!File.Exists(confProfiles)) return;
            // Load Profiles
            config = File.ReadAllText(confProfiles);
            if (!string.IsNullOrWhiteSpace(config))
                Profiles =
                    new List<SettingsProfile>(
                        (List<SettingsProfile>) JsonConvert.DeserializeObject(config, typeof (List<SettingsProfile>)));

            Profile.Load();

            if (!File.Exists(confCertificates)) return;
            // Load trusted certificates
            config = File.ReadAllText(confCertificates);
            TrustedCertificates = (List<string>)JsonConvert.DeserializeObject(config, typeof(List<string>));

            Log.Write(l.Info, "Settings Loaded.");
        }
示例#3
0
        public static void Load()
        {
            Log.Write(l.Debug, "Settings file path: {0}", ConfGeneral);
            Log.Write(l.Debug, "Profiles file path: {0}", ConfProfiles);
            Log.Write(l.Debug, "Certificates file path: {0}", ConfCertificates);

            if (!Directory.Exists(Common.AppdataFolder))
            {
                Directory.CreateDirectory(Common.AppdataFolder);
            }

            Profiles            = new List <AccountController>();
            General             = new SettingsGeneral();
            TrustedCertificates = new List <string>();

            Profiles.Add(new AccountController());

            if (File.Exists(ConfGeneral))
            {
                // Load General Settings
                var config = File.ReadAllText(ConfGeneral);
                if (!string.IsNullOrWhiteSpace(config))
                {
                    General = (SettingsGeneral)JsonConvert.DeserializeObject(config, typeof(SettingsGeneral));
                }
            }
            else
            {
                File.Create(ConfGeneral);
            }


            if (File.Exists(ConfProfiles))
            {
                // Load Profiles
                var config = File.ReadAllText(ConfProfiles);
                if (!string.IsNullOrWhiteSpace(config))
                {
                    Profiles = (List <AccountController>)JsonConvert.DeserializeObject(config, typeof(List <AccountController>));
                }
            }
            else
            {
                File.Create(ConfProfiles);
            }

            DefaultProfile.InitClient();

            if (File.Exists(ConfCertificates))
            {
                // Load trusted certificates
                var config = File.ReadAllText(ConfCertificates);
                if (!string.IsNullOrWhiteSpace(config))
                {
                    TrustedCertificates = (List <string>)JsonConvert.DeserializeObject(config, typeof(List <string>));
                }
            }
            else
            {
                File.Create(ConfCertificates);
            }

            Log.Write(l.Info, "Settings Loaded.");
        }