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
- FormatVersion.cs
- TreeViewHitTestInfo.cs
- SQLMoney.cs
- RepeaterItemEventArgs.cs
- RoleGroup.cs
- SmtpCommands.cs
- NativeMethods.cs
- MessageHeaderAttribute.cs
- DataSourceComponent.cs
- ImportCatalogPart.cs
- OdbcErrorCollection.cs
- FormCollection.cs
- DataGridViewSelectedCellCollection.cs
- StandardToolWindows.cs
- ReadOnlyDictionary.cs
- ClientSettingsStore.cs
- BrowserCapabilitiesCodeGenerator.cs
- XmlName.cs
- CodeNamespace.cs
- TraceData.cs
- DetailsViewInsertedEventArgs.cs
- ProvidePropertyAttribute.cs
- ListControl.cs
- sqlinternaltransaction.cs
- Constants.cs
- IndexedSelectQueryOperator.cs
- FontCollection.cs
- ValidationSummaryDesigner.cs
- XmlnsDictionary.cs
- _KerberosClient.cs
- BuildProvider.cs
- DBSqlParser.cs
- TemplateNameScope.cs
- BasicExpandProvider.cs
- GridViewUpdateEventArgs.cs
- Stack.cs
- IDispatchConstantAttribute.cs
- EdmComplexTypeAttribute.cs
- TextBounds.cs
- UInt64Storage.cs
- ManifestResourceInfo.cs
- ModelVisual3D.cs
- NetworkInterface.cs
- ScrollItemPatternIdentifiers.cs
- Label.cs
- bindurihelper.cs
- COAUTHIDENTITY.cs
- PublisherMembershipCondition.cs
- VirtualizingPanel.cs
- ToolStripItemImageRenderEventArgs.cs
- FixUp.cs
- SqlDataRecord.cs
- TableCellCollection.cs
- RequestCache.cs
- designeractionlistschangedeventargs.cs
- PageThemeParser.cs
- HwndProxyElementProvider.cs
- AuthenticationService.cs
- PropertyInfo.cs
- DataTemplate.cs
- BitmapEffectInputData.cs
- GridViewCellAutomationPeer.cs
- MappingModelBuildProvider.cs
- SessionIDManager.cs
- TrackBar.cs
- LinkArea.cs
- SmiEventSink_DeferedProcessing.cs
- WorkflowCompensationBehavior.cs
- SpecialFolderEnumConverter.cs
- CopyOnWriteList.cs
- ToolboxCategory.cs
- MouseButtonEventArgs.cs
- HtmlSelect.cs
- OrderedDictionaryStateHelper.cs
- DataTransferEventArgs.cs
- ForeignKeyConstraint.cs
- WebPartsPersonalizationAuthorization.cs
- ComplexPropertyEntry.cs
- Transform.cs
- DocumentOrderQuery.cs
- KeyboardEventArgs.cs
- BrowserPolicyValidator.cs
- PassportAuthenticationModule.cs
- ComNativeDescriptor.cs
- HttpRequest.cs
- _NtlmClient.cs
- MenuRenderer.cs
- Int32Collection.cs
- Deserializer.cs
- AuthenticationServiceManager.cs
- RtType.cs
- XmlEventCache.cs
- TdsEnums.cs
- OutputCacheProfileCollection.cs
- oledbmetadatacollectionnames.cs
- ZipIOCentralDirectoryFileHeader.cs
- ClientEventManager.cs
- MULTI_QI.cs
- PreloadHost.cs
- DataRecordInternal.cs