예제 #1
0
        private bool OnBeforeRemoveItemEvent(AttributeDefinition item)
        {
            BeforeRemoveItemEventHandler ae = this.BeforeRemoveItem;

            if (ae != null)
            {
                AttributeDefinitionDictionaryEventArgs e = new AttributeDefinitionDictionaryEventArgs(item);
                ae(this, e);
                return(e.Cancel);
            }
            return(false);
        }
예제 #2
0
        protected virtual bool OnBeforeAddItemEvent(AttributeDefinition item)
        {
            BeforeAddItemEventHandler ae = BeforeAddItem;

            if (ae != null)
            {
                AttributeDefinitionDictionaryEventArgs e = new AttributeDefinitionDictionaryEventArgs(item);
                ae(this, e);
                return(e.Cancel);
            }
            return(false);
        }
예제 #3
0
 private void AttributeDefinitions_RemoveItem(AttributeDefinitionDictionary sender, AttributeDefinitionDictionaryEventArgs e)
 {
     if (this.readOnly) return;
     this.OnAttributeDefinitionRemovedEvent(e.Item);
     e.Item.Owner = null;
     if(this.attributes.Count == 0)
         this.flags &= ~BlockTypeFlags.NonConstantAttributeDefinitions;
 }
예제 #4
0
 private void AttributeDefinitions_ItemAdd(AttributeDefinitionDictionary sender, AttributeDefinitionDictionaryEventArgs e)
 {
     if (this.readOnly) return;
     this.OnAttributeDefinitionAddedEvent(e.Item);
     e.Item.Owner = this;
     // the block has attributes
     this.flags |= BlockTypeFlags.NonConstantAttributeDefinitions;
 }
예제 #5
0
 private void AttributeDefinitions_BeforeRemoveItem(AttributeDefinitionDictionary sender, AttributeDefinitionDictionaryEventArgs e)
 {
     // only attribute definitions owned by the actual block can be removed
     e.Cancel = !ReferenceEquals(e.Item.Owner, this) || this.readOnly;
 }
예제 #6
0
 private void AttributeDefinitions_BeforeAddItem(AttributeDefinitionDictionary sender, AttributeDefinitionDictionaryEventArgs e)
 {
     // null, attributes with the same tag, and attribute definitions already owned by another Block are not allowed in the attributes list.
     if (e.Item == null)
         e.Cancel = true;
     else if (this.attributes.ContainsTag(e.Item.Tag))
         e.Cancel = true;
     else if (this.readOnly)
         e.Cancel = true;
     else if (e.Item.Owner != null)
     {
         // if the block does not belong to a document, all attribute definitions which owner is not null will be rejected
         if (this.Record.Owner == null)
             e.Cancel = true;
         // if the block belongs to a document, the entity will be added to the block only if both, the block and the attribute definitions document, are the same
         // this is handled by the BlocksRecordCollection
     }
     else
         e.Cancel = false;
 }