/// <summary> Sets the new value of the <see cref="DataSource"/> property. </summary>
        /// <param name="dataSource"> The new <see cref="IBusinessObjectDataSource"/>. Can be <see langword="null"/>. </param>
        private void SetDataSource(IBusinessObjectDataSource dataSource)
        {
            if (_control == dataSource && _control is IBusinessObjectReferenceDataSource)
            {
                throw new ArgumentException("Assigning a reference data source as its own data source is not allowed.", "value");
            }

            if (_dataSource == dataSource)
            {
                return;
            }

            if (_dataSource != null)
            {
                _dataSource.Unregister(_control);
            }

            _dataSource = dataSource;

            if (dataSource != null)
            {
                dataSource.Register(_control);
            }
            _bindingChanged = true;
        }
        public void Unregister()
        {
            var stubControl1 = _mockRepository.Stub <IBusinessObjectBoundControl>();
            var stubControl2 = _mockRepository.Stub <IBusinessObjectBoundControl>();

            _mockRepository.ReplayAll();

            _dataSource.Register(stubControl1);
            _dataSource.Register(stubControl2);
            Assert.That(_dataSource.GetAllBoundControls(), Is.EqualTo(new[] { stubControl1, stubControl2 }));

            _dataSource.Unregister(stubControl1);
            Assert.That(_dataSource.GetAllBoundControls(), Is.EqualTo(new[] { stubControl2 }));

            _dataSource.Unregister(stubControl2);
            Assert.That(_dataSource.GetAllBoundControls(), Is.EqualTo(new IBusinessObjectBoundControl[0]));

            _mockRepository.VerifyAll();
        }
예제 #3
0
 /// <summary>
 ///   Removes the passed <see cref="IBusinessObjectBoundControl"/> from the list of controls bound to this <see cref="BusinessObjectDataSourceControl"/>.
 /// </summary>
 /// <param name="control">
 ///   The <see cref="IBusinessObjectBoundControl"/> to be unregistered from this <see cref="BusinessObjectDataSourceControl"/>.
 /// </param>
 /// <remarks>
 ///   Executes the <see cref="IBusinessObjectDataSource.Unregister"/> method of the encapsulated <see cref="IBusinessObjectDataSource"/>.
 /// </remarks>
 public virtual void Unregister(IBusinessObjectBoundControl control)
 {
     InnerDataSource.Unregister(control);
 }