private void Block_AttributeDefinitionAdded(Block sender, BlockAttributeDefinitionChangeEventArgs e) { if (e.Item.Owner != null) { // the block and its entities must belong to the same document if (!ReferenceEquals(e.Item.Owner.Record.Owner.Owner, this.Owner)) { throw new ArgumentException("The block and the entity must belong to the same document. Clone it instead."); } // the entity cannot belong to another block if (e.Item.Owner.Record.Layout == null) { throw new ArgumentException("The entity cannot belong to another block. Clone it instead."); } // we will exchange the owner of the entity this.Owner.RemoveAttributeDefinitionFromDocument(e.Item); } this.Owner.AddAttributeDefinitionToDocument(e.Item, string.IsNullOrEmpty(e.Item.Handle)); }
private void Block_AttributeDefinitionRemoved(Block sender, BlockAttributeDefinitionChangeEventArgs e) { this.Owner.RemoveAttributeDefinitionFromDocument(e.Item); }
private void Block_AttributeDefinitionAdded(Block sender, BlockAttributeDefinitionChangeEventArgs e) { this.Owner.AddAttributeDefinitionToDocument(e.Item, string.IsNullOrEmpty(e.Item.Handle)); }