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
- sqlstateclientmanager.cs
- DataKey.cs
- ExpandSegmentCollection.cs
- LogicalExpr.cs
- CurrentChangedEventManager.cs
- PersonalizationProvider.cs
- GradientSpreadMethodValidation.cs
- RelationshipEndCollection.cs
- LineInfo.cs
- IfElseDesigner.xaml.cs
- Point3DIndependentAnimationStorage.cs
- SqlUtils.cs
- RequestUriProcessor.cs
- CommonGetThemePartSize.cs
- DoubleLinkList.cs
- SafeRegistryHandle.cs
- PropertyIDSet.cs
- OlePropertyStructs.cs
- UniqueIdentifierService.cs
- DataBindingValueUIHandler.cs
- PropertyOrder.cs
- PlanCompilerUtil.cs
- TextOutput.cs
- AssemblyInfo.cs
- SystemKeyConverter.cs
- Funcletizer.cs
- QueryConverter.cs
- ManualWorkflowSchedulerService.cs
- XmlException.cs
- DesignRelation.cs
- DrawingDrawingContext.cs
- SafeMILHandle.cs
- SerializationObjectManager.cs
- GraphicsState.cs
- Ray3DHitTestResult.cs
- FileNotFoundException.cs
- ExtendedProperty.cs
- LoadedOrUnloadedOperation.cs
- PointCollectionConverter.cs
- MimeObjectFactory.cs
- CommandField.cs
- CodeDirectionExpression.cs
- XappLauncher.cs
- DateTimeOffset.cs
- RichTextBox.cs
- CornerRadiusConverter.cs
- ConfigXmlWhitespace.cs
- SelectionChangedEventArgs.cs
- XMLUtil.cs
- PerformanceCounterCategory.cs
- CompositeKey.cs
- Compiler.cs
- SimpleFileLog.cs
- WebPartDescriptionCollection.cs
- PixelFormats.cs
- WmlLinkAdapter.cs
- X509ChainPolicy.cs
- HeaderCollection.cs
- FormViewModeEventArgs.cs
- ResourceReferenceKeyNotFoundException.cs
- ConfigXmlElement.cs
- SemanticResolver.cs
- OdbcDataReader.cs
- MsmqIntegrationMessageProperty.cs
- ModuleConfigurationInfo.cs
- ClosureBinding.cs
- WebPartCollection.cs
- MessageQueueTransaction.cs
- XamlTypeMapper.cs
- TreeNodeMouseHoverEvent.cs
- sqlmetadatafactory.cs
- SessionStateUtil.cs
- BuildProviderCollection.cs
- DataGridViewTopRowAccessibleObject.cs
- PackagePartCollection.cs
- BackStopAuthenticationModule.cs
- DetailsViewUpdatedEventArgs.cs
- ListViewTableCell.cs
- XmlTextReaderImplHelpers.cs
- CodeNamespaceImport.cs
- XPathException.cs
- DynamicValueConverter.cs
- DataConnectionHelper.cs
- DataGridViewSortCompareEventArgs.cs
- PageAction.cs
- FixedLineResult.cs
- MouseGestureValueSerializer.cs
- PeerToPeerException.cs
- TraceUtility.cs
- NestedContainer.cs
- SmtpReplyReaderFactory.cs
- TextEditorThreadLocalStore.cs
- HttpContext.cs
- XmlSchemaGroupRef.cs
- CodeCatchClauseCollection.cs
- SiteMap.cs
- TraceContextRecord.cs
- WebPartDisplayModeCancelEventArgs.cs
- FixedLineResult.cs
- InstanceKey.cs