Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / wpf / src / Framework / MS / Internal / Controls / ValidationErrorCollection.cs / 1 / ValidationErrorCollection.cs
//---------------------------------------------------------------------------- // //// Copyright (C) 2003 by Microsoft Corporation. All rights reserved. // // // // Description: // ValidationErrorCollection contains the list of ValidationErrors from // the various Bindings and MultiBindings on an Element. ValidationErrorCollection // be set through the Validation.ErrorsProperty. // // See specs at http://avalon/connecteddata/Specs/Validation.mht // // History: // 5/3/2004 mharper: created. // //--------------------------------------------------------------------------- using System; using System.ComponentModel; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Windows; using System.Windows.Controls; using System.Windows.Data; namespace MS.Internal.Controls { ////// ValidationErrorCollection contains the list of ValidationErrors from /// the various Bindings and MultiBindings on an Element. ValidationErrorCollection /// be set through the Validation.ErrorsProperty. /// internal class ValidationErrorCollection : ObservableCollection{ /// /// Empty collection that serves as a default value for /// Validation.ErrorsProperty. /// public static readonly ReadOnlyObservableCollectionEmpty = new ReadOnlyObservableCollection (new ValidationErrorCollection()); /// /// called by base class Collection<T> when an item is added to list; /// protected override void InsertItem(int index, ValidationError item) { int existingIndex = FindErrorForBinding(item.BindingInError); // if there is already a ValidationError for this binding, // then throw if (existingIndex > -1) { throw new ArgumentException(SR.Get(SRID.DuplicatesNotAllowed), "validationError"); } base.InsertItem(index, item); } //----------------------------------------------------- // // Internal Methods // //----------------------------------------------------- #region Internal Methods static internal ReadOnlyObservableCollectionGetReadOnlyErrors(DependencyObject d) { ValidationErrorCollection errors = Validation.GetErrorsInternal(d); if (errors != null) { if (errors._readonlyWrapper == null) { errors._readonlyWrapper = new ReadOnlyObservableCollection (errors); } return errors._readonlyWrapper; } else { return Empty; } } #endregion Internal Methods //------------------------------------------------------ // // Private Methods // //----------------------------------------------------- #region Private Methods private int FindErrorForBinding(object binding) { for (int i = 0; i < this.Count; i++) { if (this[i].BindingInError == binding) { return i; } } return -1; } #endregion Private Methods ReadOnlyObservableCollection _readonlyWrapper; } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. //---------------------------------------------------------------------------- // // // Copyright (C) 2003 by Microsoft Corporation. All rights reserved. // // // // Description: // ValidationErrorCollection contains the list of ValidationErrors from // the various Bindings and MultiBindings on an Element. ValidationErrorCollection // be set through the Validation.ErrorsProperty. // // See specs at http://avalon/connecteddata/Specs/Validation.mht // // History: // 5/3/2004 mharper: created. // //--------------------------------------------------------------------------- using System; using System.ComponentModel; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Windows; using System.Windows.Controls; using System.Windows.Data; namespace MS.Internal.Controls { ////// ValidationErrorCollection contains the list of ValidationErrors from /// the various Bindings and MultiBindings on an Element. ValidationErrorCollection /// be set through the Validation.ErrorsProperty. /// internal class ValidationErrorCollection : ObservableCollection{ /// /// Empty collection that serves as a default value for /// Validation.ErrorsProperty. /// public static readonly ReadOnlyObservableCollectionEmpty = new ReadOnlyObservableCollection (new ValidationErrorCollection()); /// /// called by base class Collection<T> when an item is added to list; /// protected override void InsertItem(int index, ValidationError item) { int existingIndex = FindErrorForBinding(item.BindingInError); // if there is already a ValidationError for this binding, // then throw if (existingIndex > -1) { throw new ArgumentException(SR.Get(SRID.DuplicatesNotAllowed), "validationError"); } base.InsertItem(index, item); } //----------------------------------------------------- // // Internal Methods // //----------------------------------------------------- #region Internal Methods static internal ReadOnlyObservableCollectionGetReadOnlyErrors(DependencyObject d) { ValidationErrorCollection errors = Validation.GetErrorsInternal(d); if (errors != null) { if (errors._readonlyWrapper == null) { errors._readonlyWrapper = new ReadOnlyObservableCollection (errors); } return errors._readonlyWrapper; } else { return Empty; } } #endregion Internal Methods //------------------------------------------------------ // // Private Methods // //----------------------------------------------------- #region Private Methods private int FindErrorForBinding(object binding) { for (int i = 0; i < this.Count; i++) { if (this[i].BindingInError == binding) { return i; } } return -1; } #endregion Private Methods ReadOnlyObservableCollection _readonlyWrapper; } } // 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
- DataServiceSaveChangesEventArgs.cs
- OneToOneMappingSerializer.cs
- OleDbConnectionFactory.cs
- WebPartsPersonalization.cs
- Accessible.cs
- AnnotationResourceChangedEventArgs.cs
- Metafile.cs
- BufferBuilder.cs
- SessionStateItemCollection.cs
- DecimalAverageAggregationOperator.cs
- PathSegmentCollection.cs
- SqlBinder.cs
- DataTableCollection.cs
- WorkflowView.cs
- FigureHelper.cs
- ObjectConverter.cs
- PathFigureCollectionValueSerializer.cs
- ComplexTypeEmitter.cs
- ChangeConflicts.cs
- WmpBitmapDecoder.cs
- ItemType.cs
- DatatypeImplementation.cs
- DesignTimeResourceProviderFactoryAttribute.cs
- AutoGeneratedFieldProperties.cs
- TextTreeInsertUndoUnit.cs
- Membership.cs
- DetailsViewCommandEventArgs.cs
- OleDbConnectionFactory.cs
- ADMembershipProvider.cs
- SqlTypesSchemaImporter.cs
- ConfigurationSettings.cs
- RichTextBoxContextMenu.cs
- DataGridCommandEventArgs.cs
- Span.cs
- HGlobalSafeHandle.cs
- ResolveNameEventArgs.cs
- OperationResponse.cs
- SingleAnimationBase.cs
- CalloutQueueItem.cs
- RoleService.cs
- DeferredReference.cs
- JsonReaderDelegator.cs
- EmptyEnumerable.cs
- URLIdentityPermission.cs
- KeyboardDevice.cs
- IntSecurity.cs
- EndpointDispatcher.cs
- ReceiveActivityValidator.cs
- ChildrenQuery.cs
- TrackingValidationObjectDictionary.cs
- ReflectPropertyDescriptor.cs
- ManagedFilter.cs
- EmptyCollection.cs
- ClientUrlResolverWrapper.cs
- ThicknessConverter.cs
- SelectionManager.cs
- _NetworkingPerfCounters.cs
- SafeFileHandle.cs
- ObjectViewListener.cs
- x509store.cs
- BamlResourceDeserializer.cs
- LogicalExpr.cs
- TraceLevelHelper.cs
- TransactionManager.cs
- XamlFilter.cs
- login.cs
- ListSortDescriptionCollection.cs
- DataGridTextBoxColumn.cs
- SystemTcpConnection.cs
- RefreshEventArgs.cs
- DesignerSelectionListAdapter.cs
- WebScriptMetadataFormatter.cs
- MgmtResManager.cs
- PerformanceCounter.cs
- SQLInt64Storage.cs
- ByteFacetDescriptionElement.cs
- ZipIOLocalFileBlock.cs
- PanelContainerDesigner.cs
- CodeNamespace.cs
- BinaryObjectReader.cs
- _AuthenticationState.cs
- _LocalDataStoreMgr.cs
- ByteArrayHelperWithString.cs
- DataBinding.cs
- WebPartPersonalization.cs
- RegularExpressionValidator.cs
- ToolStripEditorManager.cs
- DesignTimeParseData.cs
- HtmlElementErrorEventArgs.cs
- EditorPartChrome.cs
- ImageSourceValueSerializer.cs
- ConfigXmlElement.cs
- FormViewUpdatedEventArgs.cs
- FillErrorEventArgs.cs
- NotifyInputEventArgs.cs
- LoginCancelEventArgs.cs
- DesignerToolboxInfo.cs
- DaylightTime.cs
- DataFormats.cs
- BaseValidator.cs