예제 #1
0
        public void Activate(ICommandBindingContainer bindingContainer)
        {
            if (bindingContainer == null)
            {
                throw new ArgumentNullException("bindingContainer");
            }
            if (!_validEvent)
            {
                throw new InvalidOperationException(Resources.EventForCommandBindingIsNotValid);
            }
            if (!_attached)
            {
                throw new InvalidOperationException(Resources.EventForCommandBindingIsNotValid);
            }
            if (!bindingContainer.CommandBindings.Contains(this))
            {
                throw new InvalidOperationException(Resources.CommandBindingMustBeActivatedInOwningContainer);
            }

            if (Interlocked.CompareExchange(ref _activated, 1, 0) != 0)
            {
                throw new InvalidOperationException(Resources.AlreadyActivated);
            }

            _container = bindingContainer;
            OnActivated();
        }
예제 #2
0
 /// <summary>
 /// Deactivates this <c>CommandBinding</c> so that it can be activated again.
 /// </summary>
 internal void Deactivate()
 {
     if (Interlocked.Exchange(ref _activated, 0) == 1)
     {
         _container = null;
         OnDeactivated();
     }
 }
예제 #3
0
 /// <summary>
 /// Deactivates this <c>CommandBinding</c> so that it can be activated again.
 /// </summary>
 internal void Deactivate()
 {
     if (Interlocked.Exchange(ref _activated, 0) == 1)
     {
         _container = null;
         OnDeactivated();
     }
 }
예제 #4
0
        public void Activate(ICommandBindingContainer bindingContainer)
        {
            if (bindingContainer == null)
                throw new ArgumentNullException("bindingContainer");
            if (!_validEvent)
                throw new InvalidOperationException(Resources.EventForCommandBindingIsNotValid);
            if (!_attached)
                throw new InvalidOperationException(Resources.EventForCommandBindingIsNotValid);
            if (!bindingContainer.CommandBindings.Contains(this))
                throw new InvalidOperationException(Resources.CommandBindingMustBeActivatedInOwningContainer);

            if (Interlocked.CompareExchange(ref _activated, 1, 0) != 0)
            {
                throw new InvalidOperationException(Resources.AlreadyActivated);
            }

            _container = bindingContainer;
            OnActivated();
        }