Ejemplo n.º 1
0
        private bool FireCollectionChangingEvent(NotifyCollectionChangeAction action, T item, int index)
        {
            EditActionAttribute.FireBeforeEventCall(this, false);

            if (CollectionChanging != null)
            {
                if (EventSettings.EnableLogging)
                {
                    eventsLog.DebugFormat(EditActionAttribute.BubbleIndent + "CollectionChanging L>> '{0}[{1}]', item:{2}, index:{3}, action:{4} - BEGIN >>>>>>>>>>>>>>", "EventedList", typeof(T).Name, item, index, action);
                }

                var args = new NotifyCollectionChangingEventArgs(action, item, index, -1);

                try
                {
                    CollectionChanging(this, args);
                }
                catch
                {
                    EditActionAttribute.FireAfterEventCall(this, false, args.Cancel);
                    throw;
                }

                if (args.Cancel)
                {
                    EditActionAttribute.FireAfterEventCall(this, false, args.Cancel);
                }

                return(!args.Cancel);
            }

            return(true);
        }
 protected static void FireBeforeEventCall(object sender, bool isPropertyChange)
 {
     EditActionAttribute.FireBeforeEventCall(sender, isPropertyChange);
 }