Exemple #1
0
        public static void Load()
        {
            try
            {
                using (var file = File.OpenRead(Program.ConfigPath))
                    using (var reader = new StreamReader(file, Encoding.UTF8))
                    {
                        var inst = new Config();
                        Program.JsonSerializer.Populate(reader, inst);
                        Instance = inst;
                    }
            }
            catch (FileNotFoundException)
            {
            }
            catch (DirectoryNotFoundException)
            {
            }
            catch (Exception ex)
            {
                SentrySdk.CaptureException(ex);
            }

            Instance = Instance ?? new Config();

            TwitterClientFactory.SetInstances(Instance.Accounts);

            Loaded = true;
        }
        static Config()
        {
            try
            {
                using (var file = File.OpenRead(Program.ConfigPath))
                using (var reader = new StreamReader(file, Encoding.UTF8))
                {
                    var inst = new Config();
                    Program.JsonSerializer.Populate(reader, inst);
                    Instance = inst;
                }
            }
            catch (Exception ex)
            {
                SentrySdk.CaptureException(ex);

                Instance = new Config();
            }

            TwitterClientFactory.SetInstances(Instance.Accounts);

            Interlocked.Exchange(ref Load, 1);
        }