Beispiel #1
0
        /// <summary>
        ///     Load a json list file
        /// </summary>
        private void LoadList()
        {
            List = new Dictionary <string, ServerListItem>();
            if (!File.Exists(_path))
            {
                return;
            }

            try
            {
                string jsonText = FsUtil.ReadFileInUse(_path);
                if (string.IsNullOrEmpty(jsonText))
                {
                    return;
                }

                JsonArray array = JsonConvert.Import <JsonArray>(jsonText);
                foreach (JsonObject obj in array)
                {
                    ServerListItem item = new ServerListItem(obj);
                    if (string.IsNullOrEmpty(item.Name))
                    {
                        continue;
                    }
                    if (!List.ContainsKey(item.Name))
                    {
                        List.Add(item.Name, item);
                    }
                }
                OnListUpdated();
            }
            catch (Exception ex)
            {
                Logger.Log(LogLevel.Warning, "Failed to load list: " + _type, ex.Message);
            }
        }
Beispiel #2
0
		/// <summary>
		///     Load a json list file
		/// </summary>
		private void LoadList()
		{
			List = new Dictionary<string, ServerListItem>();
			if (!File.Exists(_path)) return;

			try
			{
				string jsonText = FsUtil.ReadFileInUse(_path);
				if (string.IsNullOrEmpty(jsonText)) return;

				JsonArray array = JsonConvert.Import<JsonArray>(jsonText);
				foreach (JsonObject obj in array)
				{
					ServerListItem item = new ServerListItem(obj);
					if (string.IsNullOrEmpty(item.Name)) continue;
					if (!List.ContainsKey(item.Name)) List.Add(item.Name, item);
				}
				OnListUpdated();
			}
			catch (Exception ex)
			{
				Logger.Log(LogLevel.Warning, "Failed to load list: " + _type, ex.Message);
			}
		}