TorchAutoModerator/Utils.General/StupidDb.cs
/// <summary>
/// Read the database file and cache it in the RAM.
/// If the file is not found, create an empty JSON file.
/// </summary>
Read the database file and cache it in the RAM.
If the file is not found, create an empty JSON file.
Read the database file and cache it in the RAM . If the file is not found create an empty JSON file .
[MethodImpl(MethodImplOptions.Synchronized)]
        public void Read()
        {
            _ramCopy.Clear();
            if (!File.Exists(_filePath))
            {
                var emptyText = JsonConvert.SerializeObject(_ramCopy);
                File.WriteAllText(_filePath, emptyText);
            }
            else
            {
                var fileText = File.ReadAllText(_filePath);
                var copy = JsonConvert.DeserializeObject<Dictionary<string, JToken>>(fileText);
                _ramCopy.AddRange(copy);
            }
        }
[ MethodImpl ( MethodImplOptions . Synchronized ) ] public void Read ( ) { _ramCopy . Clear ( ) ; if ( ! File . Exists ( _filePath ) ) { var emptyText = JsonConvert . SerializeObject ( _ramCopy ) ; File . WriteAllText ( _filePath , emptyText ) ; } else { var fileText = File . ReadAllText ( _filePath ) ; var copy = JsonConvert . DeserializeObject < Dictionary < string , JToken > > ( fileText ) ; _ramCopy . AddRange ( copy ) ; } }
Read the database file and cache it in the RAM.
Read the database file and cache it in the RAM .