using System.Collections.Generic;

public class StockSequenceMgr
{
	public class StringSequenceData
	{
		public string SequenceNum { get; private set; }

		public string SequenceUri { get; private set; }

		public StringSequenceData(string num, string uri)
		{
			SequenceNum = num;
			SequenceUri = uri;
		}
	}

	protected List<Dictionary<string, object>> sequenceDataList = new List<Dictionary<string, object>>();

	protected string sequenceName = "";

	public StockSequenceMgr(string name)
	{
		sequenceName = name;
	}

	public List<Dictionary<string, object>> GetStockDataList()
	{
		return sequenceDataList;
	}

	public void RemoveSelectData(Dictionary<string, object> data)
	{
		if (data != null)
		{
			lock (sequenceDataList)
			{
				sequenceDataList.Remove(data);
			}
		}
	}

	public bool IsEmpty()
	{
		return sequenceDataList.Count == 0;
	}

	public virtual void StockData(Dictionary<string, object> data)
	{
		lock (sequenceDataList)
		{
			sequenceDataList.Add(data);
		}
	}

	public int GetSequenceNumber(Dictionary<string, object> data)
	{
		if (data.ContainsKey(sequenceName))
		{
			return int.Parse(data[sequenceName].ToString());
		}
		return 0;
	}

	public void ClearSequenceDataList()
	{
		sequenceDataList.Clear();
	}

	public int GetSequenceDataCount()
	{
		if (sequenceDataList == null)
		{
			return 0;
		}
		return sequenceDataList.Count;
	}

	public List<StringSequenceData> GetAllSequenceNum()
	{
		List<StringSequenceData> list = new List<StringSequenceData>();
		for (int i = 0; i < sequenceDataList.Count; i++)
		{
			if (sequenceDataList[i].ContainsKey(sequenceName))
			{
				list.Add(new StringSequenceData(sequenceDataList[i][sequenceName].ToString(), sequenceDataList[i]["uri"].ToString()));
			}
		}
		return list;
	}

	public bool IsIncludedSequenceName(Dictionary<string, object> receivedMessage)
	{
		return receivedMessage.ContainsKey(sequenceName);
	}

	public bool IsIncludedUri(string uri)
	{
		return sequenceDataList.Exists((Dictionary<string, object> x) => x["uri"].ToString() == uri);
	}
}
