public int GenerateObjectId(object Obj) { int Id = ObjIds.GenerateId(); if (Id == -1) { throw new InvalidOperationException(); } Objects.Add(Id, Obj); return(Id); }