Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Framework / MS / Internal / Data / BindingCollection.cs / 1305600 / 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
- ControlSerializer.cs
- InvalidCastException.cs
- CallSiteHelpers.cs
- MimeWriter.cs
- CachedFontFamily.cs
- BamlTreeMap.cs
- DataBoundLiteralControl.cs
- SubstitutionList.cs
- XmlAttributeAttribute.cs
- PerformanceCounterPermissionAttribute.cs
- LabelDesigner.cs
- BasicHttpBindingElement.cs
- FormatVersion.cs
- CommandBindingCollection.cs
- AxWrapperGen.cs
- PersonalizationProviderCollection.cs
- SignerInfo.cs
- HttpHandlerActionCollection.cs
- OptionUsage.cs
- OleDbTransaction.cs
- RTLAwareMessageBox.cs
- MarkupObject.cs
- ExpressionQuoter.cs
- FastEncoderWindow.cs
- Themes.cs
- DataServiceRequest.cs
- SelectionProviderWrapper.cs
- OdbcConnectionString.cs
- ITextView.cs
- ContextMenuAutomationPeer.cs
- LayoutEvent.cs
- ImplicitInputBrush.cs
- GenericTransactionFlowAttribute.cs
- ShapingWorkspace.cs
- ToolStripButton.cs
- URIFormatException.cs
- MediaPlayer.cs
- SecurityPermission.cs
- XmlSortKey.cs
- InputMethod.cs
- FixUp.cs
- LabelLiteral.cs
- HttpCookieCollection.cs
- ViewStateModeByIdAttribute.cs
- TabItemAutomationPeer.cs
- RoleGroup.cs
- ClientSettings.cs
- ViewCellRelation.cs
- ErrorInfoXmlDocument.cs
- StringExpressionSet.cs
- CompilationAssemblyInstallComponent.cs
- BamlReader.cs
- GeometryModel3D.cs
- EntitySqlQueryCacheEntry.cs
- DocumentSchemaValidator.cs
- GB18030Encoding.cs
- CopyAttributesAction.cs
- SmtpNetworkElement.cs
- XmlSchemaSimpleTypeList.cs
- DeleteIndexBinder.cs
- ExpressionBindingCollection.cs
- TrackingServices.cs
- Run.cs
- DeploymentSectionCache.cs
- EmbeddedMailObjectsCollection.cs
- ObjectStateManager.cs
- ScrollableControl.cs
- HtmlControlPersistable.cs
- WebPartUserCapability.cs
- FrameworkElementFactory.cs
- ListContractAdapter.cs
- KeyedCollection.cs
- ListManagerBindingsCollection.cs
- XNodeValidator.cs
- WebScriptEndpoint.cs
- XmlNodeChangedEventManager.cs
- MediaTimeline.cs
- WindowsContainer.cs
- Configuration.cs
- ResourceAttributes.cs
- TraceInternal.cs
- TextSegment.cs
- EastAsianLunisolarCalendar.cs
- EntityTypeBase.cs
- MultiView.cs
- IndexOutOfRangeException.cs
- LocatorPart.cs
- Normalization.cs
- TextEditorThreadLocalStore.cs
- returneventsaver.cs
- SetIterators.cs
- HtmlControl.cs
- NativeMethods.cs
- BitmapDecoder.cs
- EncoderReplacementFallback.cs
- QilNode.cs
- ManagementClass.cs
- DataIdProcessor.cs
- WebPartDescriptionCollection.cs
- OleDbRowUpdatingEvent.cs