示例#1
0
        public DefaultConfig()
        {
            C.User User = new C.User
            {
                Account = new C.Account
                {
                    Cookie        = string.Empty,
                    GetCookieFrom = C.Account.GetCookieFromEnum.Chrome,
                    GetMessages   = false,
                    SetStatus     = false,
                    Username      = string.Empty
                },
                Id         = Guid.NewGuid().ToString(),
                Platform   = Payloads.Platform.Pc,
                Region     = Payloads.Region.En,
                UserStates = new List <Payloads.Status>
                {
                    Payloads.Status.Ingame,
                    Payloads.Status.Online
                }
            };

            Config = new C.Configuration
            {
                User        = User,
                Items       = new List <C.Item>(),
                Application = new C.Application
                {
                    StartWithWindows = true,
                    Watcher          = true
                }
            };
        }
示例#2
0
            public static C.Configuration Load()
            {
                FileInfo configFile = new FileInfo(PathToConfig());

                if (!configFile.Exists || configFile.Length == 0)
                {
                    var defaultConfig = new DefaultConfig().Config;
                    var settings      = new JsonSerializerSettings
                    {
                        NullValueHandling = NullValueHandling.Ignore,
                        Formatting        = Formatting.Indented
                    };
                    string defaultConfigText = JsonConvert.SerializeObject(defaultConfig, settings);
                    File.WriteAllText(PathToConfig(), defaultConfigText);
                }
                string configBody = File.ReadAllText(PathToConfig());

                C.Configuration config = JsonConvert.DeserializeObject <C.Configuration>(configBody);
                return(config);
            }