protected override void InsertItem(int index, VObject item) { if (item.Layer != null) { throw ExceptionFactory.ItemBelongsCollection(); } base.InsertItem(index, item); }
protected override void InsertItem(int index, Layer item) { // Make sure item can not be added into multiple collections if (item.Canvas != null) { throw ExceptionFactory.ItemBelongsCollection(); } base.InsertItem(index, item); }
private void CheckIfItemExists(T newItem) { var itemBelongsCollection = false; foreach (var item in Items) { if (ReferenceEquals(item, newItem)) { itemBelongsCollection = true; break; } } if (itemBelongsCollection) { throw ExceptionFactory.ItemBelongsCollection(); } }