Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / wpf / src / Framework / MS / Internal / Data / BindingCollection.cs / 1 / BindingCollection.cs
//---------------------------------------------------------------------------- // //// Copyright (C) Microsoft Corporation. All rights reserved. // // // Description: Defines BindingList object, a list of binds. // // Specs: http://avalon/connecteddata/M5%20Specs/UIBind.mht // //--------------------------------------------------------------------------- using System; using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Diagnostics; using System.Windows; using System.Windows.Markup; using System.Windows.Data; using MS.Utility; using MS.Internal; namespace MS.Internal.Data { ////// A list of bindingss, used by MultiBinding classes. /// internal class BindingCollection : Collection{ //----------------------------------------------------- // // Constructors // //----------------------------------------------------- /// Constructor internal BindingCollection(BindingBase owner, BindingCollectionChangedCallback callback) { Invariant.Assert(owner != null && callback != null); _owner = owner; _collectionChangedCallback = callback; } // disable default constructor private BindingCollection() { } //------------------------------------------------------ // // Protected Methods // //----------------------------------------------------- #region Protected Methods ////// called by base class Collection<T> when the list is being cleared; /// raises a CollectionChanged event to any listeners /// protected override void ClearItems() { _owner.CheckSealed(); base.ClearItems(); OnBindingCollectionChanged(); } ////// called by base class Collection<T> when an item is removed from list; /// raises a CollectionChanged event to any listeners /// protected override void RemoveItem(int index) { _owner.CheckSealed(); base.RemoveItem(index); OnBindingCollectionChanged(); } ////// called by base class Collection<T> when an item is added to list; /// raises a CollectionChanged event to any listeners /// protected override void InsertItem(int index, BindingBase item) { if (item == null) throw new ArgumentNullException("item"); ValidateItem(item); _owner.CheckSealed(); base.InsertItem(index, item); OnBindingCollectionChanged(); } ////// called by base class Collection<T> when an item is added to list; /// raises a CollectionChanged event to any listeners /// protected override void SetItem(int index, BindingBase item) { if (item == null) throw new ArgumentNullException("item"); ValidateItem(item); _owner.CheckSealed(); base.SetItem(index, item); OnBindingCollectionChanged(); } #endregion Protected Methods //------------------------------------------------------ // // Private Methods // //------------------------------------------------------ void ValidateItem(BindingBase binding) { // for V1, we only allow Binding as an item of BindingCollection. if (!(binding is Binding)) throw new NotSupportedException(SR.Get(SRID.BindingCollectionContainsNonBinding, binding.GetType().Name)); } void OnBindingCollectionChanged() { if (_collectionChangedCallback != null) _collectionChangedCallback(); } //----------------------------------------------------- // // Private Fields // //------------------------------------------------------ BindingBase _owner; private BindingCollectionChangedCallback _collectionChangedCallback; } // the delegate to use for getting BindingListChanged notifications internal delegate void BindingCollectionChangedCallback(); } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. //---------------------------------------------------------------------------- // //// Copyright (C) Microsoft Corporation. All rights reserved. // // // Description: Defines BindingList object, a list of binds. // // Specs: http://avalon/connecteddata/M5%20Specs/UIBind.mht // //--------------------------------------------------------------------------- using System; using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Diagnostics; using System.Windows; using System.Windows.Markup; using System.Windows.Data; using MS.Utility; using MS.Internal; namespace MS.Internal.Data { ////// A list of bindingss, used by MultiBinding classes. /// internal class BindingCollection : Collection{ //----------------------------------------------------- // // Constructors // //----------------------------------------------------- /// Constructor internal BindingCollection(BindingBase owner, BindingCollectionChangedCallback callback) { Invariant.Assert(owner != null && callback != null); _owner = owner; _collectionChangedCallback = callback; } // disable default constructor private BindingCollection() { } //------------------------------------------------------ // // Protected Methods // //----------------------------------------------------- #region Protected Methods ////// called by base class Collection<T> when the list is being cleared; /// raises a CollectionChanged event to any listeners /// protected override void ClearItems() { _owner.CheckSealed(); base.ClearItems(); OnBindingCollectionChanged(); } ////// called by base class Collection<T> when an item is removed from list; /// raises a CollectionChanged event to any listeners /// protected override void RemoveItem(int index) { _owner.CheckSealed(); base.RemoveItem(index); OnBindingCollectionChanged(); } ////// called by base class Collection<T> when an item is added to list; /// raises a CollectionChanged event to any listeners /// protected override void InsertItem(int index, BindingBase item) { if (item == null) throw new ArgumentNullException("item"); ValidateItem(item); _owner.CheckSealed(); base.InsertItem(index, item); OnBindingCollectionChanged(); } ////// called by base class Collection<T> when an item is added to list; /// raises a CollectionChanged event to any listeners /// protected override void SetItem(int index, BindingBase item) { if (item == null) throw new ArgumentNullException("item"); ValidateItem(item); _owner.CheckSealed(); base.SetItem(index, item); OnBindingCollectionChanged(); } #endregion Protected Methods //------------------------------------------------------ // // Private Methods // //------------------------------------------------------ void ValidateItem(BindingBase binding) { // for V1, we only allow Binding as an item of BindingCollection. if (!(binding is Binding)) throw new NotSupportedException(SR.Get(SRID.BindingCollectionContainsNonBinding, binding.GetType().Name)); } void OnBindingCollectionChanged() { if (_collectionChangedCallback != null) _collectionChangedCallback(); } //----------------------------------------------------- // // Private Fields // //------------------------------------------------------ BindingBase _owner; private BindingCollectionChangedCallback _collectionChangedCallback; } // the delegate to use for getting BindingListChanged notifications internal delegate void BindingCollectionChangedCallback(); } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ListBox.cs
- GridViewCommandEventArgs.cs
- InvalidDataException.cs
- X509SecurityToken.cs
- TracePayload.cs
- RelationshipFixer.cs
- XmlSerializerAssemblyAttribute.cs
- MemoryStream.cs
- OutputWindow.cs
- RecognizerBase.cs
- HttpResponseWrapper.cs
- UpdateManifestForBrowserApplication.cs
- SqlExpressionNullability.cs
- InternalConfigSettingsFactory.cs
- KeyInstance.cs
- StdValidatorsAndConverters.cs
- TemplateBindingExpression.cs
- CustomError.cs
- ProcessHostConfigUtils.cs
- Parser.cs
- RectangleGeometry.cs
- Size.cs
- ListBoxItem.cs
- TargetConverter.cs
- SymmetricSecurityProtocol.cs
- AlphabeticalEnumConverter.cs
- StructuralCache.cs
- TemplatedMailWebEventProvider.cs
- InternalPolicyElement.cs
- Model3D.cs
- WindowsUpDown.cs
- ToolStripPanelCell.cs
- ContractNamespaceAttribute.cs
- Stylesheet.cs
- FormsAuthenticationEventArgs.cs
- ObjectComplexPropertyMapping.cs
- ControllableStoryboardAction.cs
- MenuItemBinding.cs
- WindowsStatusBar.cs
- NetworkStream.cs
- LoginName.cs
- ScriptMethodAttribute.cs
- XmlDsigSep2000.cs
- OrderPreservingSpoolingTask.cs
- CryptoKeySecurity.cs
- HtmlWindowCollection.cs
- QilInvoke.cs
- MatrixKeyFrameCollection.cs
- ToolStripItemClickedEventArgs.cs
- SetIndexBinder.cs
- HideDisabledControlAdapter.cs
- EndpointAddressMessageFilterTable.cs
- WindowsScroll.cs
- OLEDB_Util.cs
- InternalConfigHost.cs
- MostlySingletonList.cs
- BoolExpressionVisitors.cs
- EventsTab.cs
- TextRangeSerialization.cs
- _HTTPDateParse.cs
- ReceiveReply.cs
- AuthenticationConfig.cs
- VersionPair.cs
- BorderSidesEditor.cs
- Page.cs
- SchemaTableColumn.cs
- Attributes.cs
- Storyboard.cs
- RegexCaptureCollection.cs
- RadioButtonFlatAdapter.cs
- Accessors.cs
- WinEventTracker.cs
- OrderedEnumerableRowCollection.cs
- WSDualHttpBindingCollectionElement.cs
- DispatchWrapper.cs
- NetTcpBindingElement.cs
- XmlUrlResolver.cs
- RootProjectionNode.cs
- DataGridView.cs
- ControlEvent.cs
- ValueTypeFixupInfo.cs
- IOThreadScheduler.cs
- CultureInfo.cs
- _SslStream.cs
- FormatException.cs
- GeneralTransform3D.cs
- WebPartEditorOkVerb.cs
- ValidationHelpers.cs
- ObjectSecurity.cs
- DatatypeImplementation.cs
- IInstanceTable.cs
- NavigationService.cs
- MenuStrip.cs
- ExtentJoinTreeNode.cs
- DiscoveryMessageSequence.cs
- HttpModule.cs
- VerticalAlignConverter.cs
- ObjectSecurityT.cs
- Certificate.cs
- WebAdminConfigurationHelper.cs