コード例 #1
0
 protected void OnBeforeItemRemovedEvent(object objSender, BeforeItemRemovedEventArgs <TObjectType> objArguments)
 {
     if (Initializing == false)
     {
         BeforeItemRemovedEventHandler <TObjectType> objHandler = BeforeItemRemovedEvent;
         if (objHandler != null)
         {
             objHandler(objSender, objArguments);
         }
     }
 }
コード例 #2
0
        public virtual void RemoveAt(int intIndex)
        {
            if ((intIndex < 0) || (intIndex > _objItems.Count - 1))
            {
                throw new ArgumentOutOfRangeException("intIndex", "The index is out of range: " + intIndex);
            }

            TObjectType objItem = this[intIndex];

            BeforeItemRemovedEventArgs <TObjectType> objArguments = new BeforeItemRemovedEventArgs <TObjectType>(objItem);

            OnBeforeItemRemovedEvent(this, objArguments);
            if (objArguments.Cancel == false)
            {
                _objItems.RemoveAt(intIndex);
                OnItemRemovedEvent(this, new ItemRemovedEventArgs <TObjectType>(objItem));
            }
        }
コード例 #3
0
        public virtual bool Remove(TObjectType objItem)
        {
            bool blnResult = false;

            if (Initializing == true)
            {
                blnResult = _objItems.Remove(objItem);
            }
            else
            {
                BeforeItemRemovedEventArgs <TObjectType> objArguments = new BeforeItemRemovedEventArgs <TObjectType>(objItem);
                OnBeforeItemRemovedEvent(this, objArguments);
                if (objArguments.Cancel == false)
                {
                    blnResult = _objItems.Remove(objItem);
                    if (blnResult == true)
                    {
                        OnItemRemovedEvent(this, new ItemRemovedEventArgs <TObjectType>(objItem));
                    }
                }
            }

            return(blnResult);
        }