Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / 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
- GuidelineSet.cs
- CompilerGlobalScopeAttribute.cs
- OutgoingWebResponseContext.cs
- ButtonPopupAdapter.cs
- ConfigurationValues.cs
- CardSpaceShim.cs
- StringPropertyBuilder.cs
- _HelperAsyncResults.cs
- arclist.cs
- XmlQueryTypeFactory.cs
- EventLogEntry.cs
- ConfigXmlWhitespace.cs
- WorkflowItemsPresenter.cs
- XmlSchemaException.cs
- Thumb.cs
- ItemsChangedEventArgs.cs
- BindingManagerDataErrorEventArgs.cs
- XmlElement.cs
- NumericExpr.cs
- CaseInsensitiveHashCodeProvider.cs
- SpecialTypeDataContract.cs
- ResourceManager.cs
- DateTime.cs
- DbProviderServices.cs
- DataServiceKeyAttribute.cs
- TextContainerChangeEventArgs.cs
- StubHelpers.cs
- AuthenticationModuleElementCollection.cs
- SchemaAttDef.cs
- QilXmlReader.cs
- MSAAEventDispatcher.cs
- OracleRowUpdatingEventArgs.cs
- CacheMemory.cs
- PropertyChange.cs
- PowerModeChangedEventArgs.cs
- UserControlBuildProvider.cs
- BinaryObjectReader.cs
- WebRequest.cs
- SimplePropertyEntry.cs
- RuleSettings.cs
- WebBaseEventKeyComparer.cs
- HostingPreferredMapPath.cs
- NullableBoolConverter.cs
- FormatterConverter.cs
- DataMemberFieldConverter.cs
- DockingAttribute.cs
- DependencyPropertyValueSerializer.cs
- FigureParagraph.cs
- WindowsNonControl.cs
- RectangleF.cs
- Clipboard.cs
- DiagnosticsConfiguration.cs
- ApplicationGesture.cs
- SoapEnumAttribute.cs
- bindurihelper.cs
- DataGridViewRow.cs
- validation.cs
- CaretElement.cs
- SmtpSection.cs
- HelloOperationAsyncResult.cs
- UncommonField.cs
- PassportAuthentication.cs
- TransformCollection.cs
- TargetControlTypeCache.cs
- MetadataArtifactLoaderCompositeFile.cs
- CodeGenerator.cs
- CommandID.cs
- ReferencedCategoriesDocument.cs
- HashStream.cs
- CommandID.cs
- SchemaDeclBase.cs
- SoapReflector.cs
- XmlMessageFormatter.cs
- SqlTriggerAttribute.cs
- DataControlFieldCell.cs
- Number.cs
- NetPipeSection.cs
- SapiRecoContext.cs
- hresults.cs
- ControlBuilder.cs
- DataGridTable.cs
- HtmlTitle.cs
- ProfileBuildProvider.cs
- MultiPropertyDescriptorGridEntry.cs
- StyleXamlParser.cs
- GZipDecoder.cs
- NgenServicingAttributes.cs
- GlobalEventManager.cs
- FormViewDeleteEventArgs.cs
- TextSchema.cs
- TraceUtils.cs
- BuilderInfo.cs
- SemanticResolver.cs
- GridViewUpdateEventArgs.cs
- ByteStream.cs
- CustomDictionarySources.cs
- ObjectFactoryCodeDomTreeGenerator.cs
- MetadataItemEmitter.cs
- PropertyGrid.cs
- TransformGroup.cs