Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / 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
- DecimalAnimationUsingKeyFrames.cs
- TransformerTypeCollection.cs
- ElementMarkupObject.cs
- TokenBasedSet.cs
- ExplicitDiscriminatorMap.cs
- CorrelationTokenTypeConvertor.cs
- SqlDataSourceStatusEventArgs.cs
- FontFamilyConverter.cs
- StrongNameSignatureInformation.cs
- MsmqBindingMonitor.cs
- ObjectDataSourceWizardForm.cs
- OleDbEnumerator.cs
- CategoryGridEntry.cs
- DateTimeConverter.cs
- TrustManager.cs
- assemblycache.cs
- InheritanceContextHelper.cs
- TypeLoadException.cs
- ObjectDataSourceFilteringEventArgs.cs
- WebServiceClientProxyGenerator.cs
- HttpProfileGroupBase.cs
- OutputScopeManager.cs
- ContentOperations.cs
- HyperlinkAutomationPeer.cs
- ItemAutomationPeer.cs
- SecurityKeyType.cs
- EntitySqlException.cs
- ItemMap.cs
- Activator.cs
- Translator.cs
- UshortList2.cs
- ThreadAttributes.cs
- TextCollapsingProperties.cs
- ExtenderProvidedPropertyAttribute.cs
- PlaceHolder.cs
- EnvelopedSignatureTransform.cs
- util.cs
- MasterPageCodeDomTreeGenerator.cs
- XmlMapping.cs
- BridgeDataRecord.cs
- LinqDataSourceContextEventArgs.cs
- MainMenu.cs
- TabControlCancelEvent.cs
- ToolStripItemEventArgs.cs
- UnmanagedBitmapWrapper.cs
- TypeSystemHelpers.cs
- SqlBuilder.cs
- UrlAuthorizationModule.cs
- DictionaryEntry.cs
- ReadOnlyCollection.cs
- GeneratedContractType.cs
- HTMLTagNameToTypeMapper.cs
- TextElementEnumerator.cs
- ZoneLinkButton.cs
- SettingsBase.cs
- CodePageEncoding.cs
- UncommonField.cs
- NullEntityWrapper.cs
- EntitySqlException.cs
- Mouse.cs
- QilLiteral.cs
- StateInitializationDesigner.cs
- SplitterPanel.cs
- DirectoryObjectSecurity.cs
- RegexGroupCollection.cs
- Vector3DCollectionConverter.cs
- Logging.cs
- Int32RectValueSerializer.cs
- ApplicationId.cs
- basemetadatamappingvisitor.cs
- NullableFloatMinMaxAggregationOperator.cs
- FormViewPageEventArgs.cs
- UMPAttributes.cs
- NativeStructs.cs
- Selector.cs
- XmlException.cs
- ChildDocumentBlock.cs
- TextAnchor.cs
- UnsafeNativeMethods.cs
- SvcMapFileLoader.cs
- StylusLogic.cs
- SafeArrayRankMismatchException.cs
- MultiView.cs
- AspCompat.cs
- CfgArc.cs
- CrossAppDomainChannel.cs
- SecurityContext.cs
- ThreadWorkerController.cs
- PageCodeDomTreeGenerator.cs
- ClientTargetCollection.cs
- Pkcs9Attribute.cs
- HostedHttpContext.cs
- CacheSection.cs
- QuaternionRotation3D.cs
- QueryableDataSourceView.cs
- _CacheStreams.cs
- WebPartDescriptionCollection.cs
- FieldAccessException.cs
- FileChangeNotifier.cs
- XmlDataSourceView.cs