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
- AuthenticationManager.cs
- xmlformatgeneratorstatics.cs
- SimpleType.cs
- DataControlImageButton.cs
- CellCreator.cs
- EdmFunctionAttribute.cs
- Transform3DGroup.cs
- codemethodreferenceexpression.cs
- SafeHandle.cs
- Formatter.cs
- ComplexPropertyEntry.cs
- PointAnimationBase.cs
- MultitargetingHelpers.cs
- CustomBinding.cs
- XslTransform.cs
- ObjectStateManager.cs
- HtmlPageAdapter.cs
- ListViewContainer.cs
- UiaCoreApi.cs
- SchemaImporterExtensionsSection.cs
- __TransparentProxy.cs
- DecimalConstantAttribute.cs
- PinProtectionHelper.cs
- NavigatorOutput.cs
- BitmapCodecInfoInternal.cs
- SimpleWebHandlerParser.cs
- HtmlListAdapter.cs
- Context.cs
- SystemUnicastIPAddressInformation.cs
- GridViewRow.cs
- SamlAudienceRestrictionCondition.cs
- ConnectionStringsExpressionBuilder.cs
- ToolStripContainer.cs
- WebPartTransformer.cs
- WebPartConnectionsEventArgs.cs
- Wildcard.cs
- DesignerTransaction.cs
- CompiledIdentityConstraint.cs
- ZoneIdentityPermission.cs
- WebPartTransformer.cs
- DesignerActionItemCollection.cs
- ConstrainedDataObject.cs
- ToolStripRenderEventArgs.cs
- ProfileInfo.cs
- LogWriteRestartAreaAsyncResult.cs
- ImageListStreamer.cs
- CommandValueSerializer.cs
- X509CertificateChain.cs
- HttpCachePolicy.cs
- ClientType.cs
- TemplateParser.cs
- XmlTypeMapping.cs
- FormsAuthenticationUser.cs
- XsltSettings.cs
- SequentialWorkflowRootDesigner.cs
- DiagnosticTraceSource.cs
- WorkflowViewStateService.cs
- EntityDataSourceSelectedEventArgs.cs
- SchemaCollectionCompiler.cs
- ButtonPopupAdapter.cs
- MembershipPasswordException.cs
- SurrogateSelector.cs
- ConfigsHelper.cs
- DeclarativeConditionsCollection.cs
- ShapeTypeface.cs
- InvalidCommandTreeException.cs
- FlowPosition.cs
- RawStylusInput.cs
- DebuggerAttributes.cs
- MimeTypePropertyAttribute.cs
- ListDictionaryInternal.cs
- ToolStripItemRenderEventArgs.cs
- ExpressionVisitor.cs
- BindingList.cs
- UInt32.cs
- StateRuntime.cs
- UnicastIPAddressInformationCollection.cs
- ParameterModifier.cs
- SiteMembershipCondition.cs
- DependencyObjectCodeDomSerializer.cs
- Misc.cs
- HTTPRemotingHandler.cs
- CodeTypeDelegate.cs
- XsdSchemaFileEditor.cs
- RequestUriProcessor.cs
- RelatedPropertyManager.cs
- BuilderElements.cs
- RangeValidator.cs
- ListDataHelper.cs
- Brushes.cs
- DataGridViewCell.cs
- Panel.cs
- VirtualPath.cs
- SQLGuidStorage.cs
- EntityCollection.cs
- RemotingException.cs
- SelectedDatesCollection.cs
- CompositeCollection.cs
- UnsafeNativeMethods.cs
- PointHitTestParameters.cs