Example #1
0
        Model.Data.UserSettings LoadUserSettingsFromPorperties()
        {
            DebugSendLog("Try read setting from properties");

            try
            {
                var p = Properties.Settings.Default;

                var result = new Model.Data.UserSettings
                {
                    // int
                    MaxLogLine          = p.MaxLogLine,
                    ServerPanelPageSize = p.ServerPanelPageSize,

                    // bool
                    CfgShowToolPanel = p.CfgShowToolPanel,
                    isPortable       = p.Portable,

                    // string
                    ImportUrls        = p.ImportUrls,
                    DecodeCache       = p.DecodeCache,
                    SubscribeUrls     = p.SubscribeUrls,
                    Culture           = p.Culture,
                    ServerList        = p.ServerList,
                    PacServerSettings = p.PacServerSettings,
                    SysProxySetting   = p.SysProxySetting,
                    ServerTracker     = p.ServerTracker,
                    WinFormPosList    = p.WinFormPosList
                };
                return(result);
            }
            catch { }
            return(new Model.Data.UserSettings());
        }
Example #2
0
 public void Run(
     VgcApis.Models.IUtils vgcUtils,
     VgcApis.Models.ISettingService setting)
 {
     this.vgcUtils = vgcUtils;
     this.setting  = setting;
     userSettings  = LoadUserSettings();
 }
Example #3
0
        Model.Data.UserSettings LoadUserSettings()
        {
            var empty             = new Model.Data.UserSettings();
            var userSettingString = setting.GetPluginsSetting(pluginName);

            if (string.IsNullOrEmpty(userSettingString))
            {
                return(empty);
            }

            try
            {
                var result = VgcApis.Libs.Utils
                             .DeserializeObject <Model.Data.UserSettings>(
                    userSettingString);
                return(result ?? empty);
            }
            catch { }

            return(empty);
        }
Example #4
0
        public void SerializeTest()
        {
            var       us             = new Model.Data.UserSettings();
            var       content        = JsonConvert.SerializeObject(us);
            string    mainUsFilename = "mainUserSettingsTest.json";
            string    bakUsFilename  = "bakUserSettingsTest.bak";
            Stopwatch sw             = new Stopwatch();
            string    readBak        = null;

            sw.Restart();
            File.WriteAllText(mainUsFilename, content);
            var readMain = File.ReadAllText(mainUsFilename);

            if (readMain == content)
            {
                File.WriteAllText(bakUsFilename, content);
                readBak = File.ReadAllText(bakUsFilename);
            }
            sw.Stop();
            Console.WriteLine("Time span: " + sw.ElapsedMilliseconds);
            Assert.AreEqual(readBak, content);
        }
Example #5
0
 // Singleton need this private ctor.
 Setting()
 {
     userSettings = LoadUserSettings();
     isShutdown   = false;
 }
Example #6
0
 public void Run(
     VgcApis.Models.IServices.ISettingService setting)
 {
     this.setting = setting;
     userSettings = LoadUserSettings();
 }
Example #7
0
 // Singleton need this private ctor.
 Setting()
 {
     userSettings = LoadUserSettings();
 }
Example #8
0
 public void Run(
     VgcApis.Interfaces.Services.ISettingsService setting)
 {
     this.setting = setting;
     userSettings = LoadUserSettings();
 }
Example #9
0
 // Singleton need this private ctor.
 Setting()
 {
     userSettings         = LoadUserSettings();
     runningServerSummary = string.Empty;
     isShutdown           = false;
 }
Example #10
0
 // Singleton need this private ctor.
 Setting()
 {
     userSettings = LoadUserSettings();
     userSettings.Normalized();  // replace null with empty object.
 }