using System;

namespace wf
{
	public abstract class CsvCommonDatabaseUniqueType<Data> : CsvCommonDatabaseIDType<Data>
	{
		public bool Contains(string name)
		{
			return this.commonIdManager.nameMap.ContainsKey(name);
		}

		public int uniqueNameToId(string name)
		{
			this.Initialize();
			NDebug.Assert(this.commonIdManager.nameMap.ContainsKey(name), this.typeNameForErrorLog + "\nユニーク名[" + name + "]をIDに変換できませんでした");
			return this.commonIdManager.nameMap[name];
		}

		public string IdToUniqueName(int id)
		{
			this.Initialize();
			NDebug.Assert(this.commonIdManager.idMap.ContainsKey(id), string.Concat(new object[]
			{
				this.typeNameForErrorLog,
				"\nID[",
				id,
				"]をユニーク名に変換できませんでした"
			}));
			return this.commonIdManager.idMap[id].Key;
		}

		public Data GetData(string uniqueName)
		{
			return base.GetData(this.uniqueNameToId(uniqueName));
		}

		public bool IsEnabled(string uniqueName)
		{
			this.Initialize();
			return this.commonIdManager.enabledIdList.Contains(this.uniqueNameToId(uniqueName));
		}

		public override bool Initialize()
		{
			if (this.commonIdManager != null)
			{
				return false;
			}
			this.commonIdManager = new CsvCommonIdManager(this.csvTopCommonName, this.typeNameForErrorLog, CsvCommonIdManager.Type.IdAndUniqueName, null);
			this.basicDatas = this.CreateData(this.commonIdManager);
			return true;
		}
	}
}
