/// <summary> /// IDオブジェクトを登録する。 /// </summary> /// <param name="id">登録するID</param> internal void RegisterId(IdType id) { if (id == null) { throw new ArgumentNullException(); } int index = id.Index; if ((0 <= index) && (index < IdList.Length)) { if (IdList[index] == null) { IdList[index] = id; } else { throw new ArgumentException(); } } else if (SupportUnindexedId == true) { UnindexedIdList.Add(id); } else { return; } }
/// <summary> /// ID名からIDオブジェクトが登録されているかどうか確認する。 /// </summary> /// <param name="name">ID名</param> /// <returns>存在するならtrue</returns> public bool IsResistered(string name) { bool result = Array.Exists(IdList, item => item.CompareTo(name)); if ((result == false) && (SupportUnindexedId == true)) { result = UnindexedIdList.Exists(item => item.CompareTo(name)); } return(result); }
/// <summary> /// ID名からIDオブジェクトを取得する。 /// </summary> /// <param name="name">ID名</param> /// <returns>登録されているIDあるいはnull</returns> public IdType GetId(string name) { // インデックスのあるIDから検索する IdType id = IdList.FirstOrDefault(item => item.CompareTo(name)); if (id != null) { return(id); } if (SupportUnindexedId == true) { // 見つからなかったのでインデックスのないIDも検索する id = UnindexedIdList.FirstOrDefault(x => x.CompareTo(name)); if (id != null) { return(id); } } return(null); }