public T GetValue <T>(string path)
        {
            Log.Data($"Reading JSON data at '{path}'.");
            var val = JSONSerialization.DeserializeFile <T>(GetPath() + path);

            return(val);
        }
Example #2
0
        public static bool IsDefault(Type pluginType) // This might fit better in the Plugin class.
        {
            var list = JSONSerialization.DeserializeFile <List <string> >(DefaultPluginsPath);

            if (list == null)
            {
                list = new List <string>(_standardPlugins.Select(x => Plugin.GetFullName(x)));
                JSONSerialization.SerializeObject(list, DefaultPluginsPath);
            }
            return(list.Contains(Plugin.GetFullName(pluginType)));
        }
Example #3
0
 private void Load()
 {
     _users = JSONSerialization.DeserializeFile <List <ulong> > (_filePath);
     if (_users == null)
     {
         _users = new List <ulong> {
             0
         };
         Save();
     }
 }
        public T[] GetAllValues <T>(string path)
        {
            string directoryPath = GetPath() + path.Substring(0, path.LastIndexOf('/'));
            string prefix        = path.Substring(path.LastIndexOf("/") + 1);

            string[] matches = Directory.GetFiles(directoryPath, $"{prefix}*");
            T[]      results = new T[matches.Length];
            for (int i = 0; i < results.Length; i++)
            {
                results[i] = JSONSerialization.DeserializeFile <T>(matches[i]);
            }
            return(results);
        }
Example #5
0
        private static void CacheFullTanslationTable()
        {
            string[] files = Directory.GetFiles(LocalizationsDirectory);
            foreach (string file in files)
            {
                var(culture, identifier) = DeformatName(Path.GetFileNameWithoutExtension(file));
                Dictionary <string, string> dict = JSONSerialization.DeserializeFile <Dictionary <string, string> >(file);

                if (!_translationTable.ContainsKey(culture))
                {
                    _translationTable.Add(culture, new Dictionary <string, Dictionary <string, string> >());
                }

                if (!_translationTable[culture].ContainsKey(identifier))
                {
                    _translationTable[culture].Add(identifier, null);
                }

                _translationTable[culture][identifier] = dict;
            }
        }
Example #6
0
 public static ClientConfiguration Load(string path)
 {
     return(JSONSerialization.DeserializeFile <ClientConfiguration>(path));
 }