public ItemSpec AddSpec(ItemSpec spec) { // todo: the cloning behaviour of the ItemSpec is a bit, confusing. lock (this) { // if the spec is already available, then return the old one and don't add this new one var duplicate = GetDuplicate(spec); if (duplicate != null) { return(duplicate); } var id = ++_nextSpec; spec = spec.Clone(id); _specs.Add(id, spec); } OnItemAdded(spec); return(spec); }