Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / 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
- XmlSchemaResource.cs
- PeerToPeerException.cs
- SmtpFailedRecipientsException.cs
- SQLDecimalStorage.cs
- FileInfo.cs
- SystemIPGlobalStatistics.cs
- ObjectResult.cs
- LifetimeServices.cs
- DBCommandBuilder.cs
- PropVariant.cs
- TextLineBreak.cs
- DesignRelation.cs
- ApplicationTrust.cs
- ScriptControl.cs
- InvalidEnumArgumentException.cs
- BulletDecorator.cs
- PolicyException.cs
- ObjectListCommand.cs
- ResourceAttributes.cs
- NamespaceTable.cs
- SerializationException.cs
- ObjectPropertyMapping.cs
- SecurityContextSecurityTokenAuthenticator.cs
- ObjectListCommandEventArgs.cs
- SecurityElement.cs
- DropSourceBehavior.cs
- XmlSchemaInclude.cs
- WindowManager.cs
- _HTTPDateParse.cs
- mda.cs
- Gdiplus.cs
- base64Transforms.cs
- ScrollBarRenderer.cs
- EditableTreeList.cs
- MULTI_QI.cs
- TypeInfo.cs
- HtmlLinkAdapter.cs
- EventHandlerList.cs
- XmlComment.cs
- FragmentNavigationEventArgs.cs
- DataTableTypeConverter.cs
- ObjectHelper.cs
- SqlMethods.cs
- TemplatedWizardStep.cs
- DataMember.cs
- QueryCursorEventArgs.cs
- TreeViewCancelEvent.cs
- AutomationPatternInfo.cs
- SoundPlayerAction.cs
- StringReader.cs
- BitmapFrame.cs
- FontWeights.cs
- DocumentViewerHelper.cs
- PageAdapter.cs
- ComponentDesigner.cs
- EntityDataSourceState.cs
- ClientRuntimeConfig.cs
- FocusTracker.cs
- RtfFormatStack.cs
- MemberInfoSerializationHolder.cs
- HMACRIPEMD160.cs
- ObjectView.cs
- SerialPinChanges.cs
- CqlErrorHelper.cs
- IndividualDeviceConfig.cs
- Internal.cs
- XmlSchemaInclude.cs
- PassportPrincipal.cs
- ViewBase.cs
- Substitution.cs
- ScriptResourceInfo.cs
- XmlSchemaCollection.cs
- SchemaSetCompiler.cs
- HwndKeyboardInputProvider.cs
- TabControl.cs
- CompModSwitches.cs
- ParsedAttributeCollection.cs
- HttpWrapper.cs
- CachedRequestParams.cs
- ResumeStoryboard.cs
- PageThemeBuildProvider.cs
- StateValidator.cs
- InvokePatternIdentifiers.cs
- HitTestDrawingContextWalker.cs
- DiscoveryViaBehavior.cs
- EventLogTraceListener.cs
- serverconfig.cs
- Image.cs
- AppDomainFactory.cs
- GregorianCalendarHelper.cs
- MemoryStream.cs
- XmlValueConverter.cs
- WindowsTokenRoleProvider.cs
- DesignerCategoryAttribute.cs
- Operator.cs
- ToolStripItem.cs
- DiscoveryDocumentReference.cs
- Msmq.cs
- SmiContext.cs
- wgx_sdk_version.cs