Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / 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
- ProjectionPruner.cs
- HtmlTableRow.cs
- RepeatEnumerable.cs
- SystemIPGlobalProperties.cs
- Compensation.cs
- RegexCaptureCollection.cs
- TypeBuilder.cs
- KeyEventArgs.cs
- EntityDataSourceSelectingEventArgs.cs
- DecimalAnimation.cs
- Encoder.cs
- handlecollector.cs
- ContractTypeNameElement.cs
- AttachedPropertyBrowsableForTypeAttribute.cs
- ConfigXmlAttribute.cs
- EntityCommandCompilationException.cs
- cookieexception.cs
- BindingEntityInfo.cs
- Attribute.cs
- XmlResolver.cs
- DataTemplate.cs
- TextServicesLoader.cs
- DecoderFallback.cs
- EditorBrowsableAttribute.cs
- IssuedSecurityTokenProvider.cs
- WinFormsUtils.cs
- DeclarativeCatalogPart.cs
- ColorContextHelper.cs
- AndCondition.cs
- OdbcReferenceCollection.cs
- PermissionListSet.cs
- ValueQuery.cs
- FileDataSource.cs
- XmlWrappingReader.cs
- LinkConverter.cs
- WebServiceClientProxyGenerator.cs
- ParagraphVisual.cs
- RangeValuePatternIdentifiers.cs
- LinkedResourceCollection.cs
- MatrixConverter.cs
- OutputCacheModule.cs
- Image.cs
- Journaling.cs
- DesignTimeResourceProviderFactoryAttribute.cs
- Point3DAnimationBase.cs
- SelectionGlyph.cs
- WebProxyScriptElement.cs
- NativeMethods.cs
- WebPartEditorApplyVerb.cs
- Effect.cs
- mactripleDES.cs
- DataSet.cs
- ZipIOLocalFileDataDescriptor.cs
- AvTraceFormat.cs
- RequestContext.cs
- DataListGeneralPage.cs
- ModuleBuilderData.cs
- CqlQuery.cs
- Publisher.cs
- WebHeaderCollection.cs
- RightsManagementInformation.cs
- ListSortDescription.cs
- ImageList.cs
- XhtmlBasicCommandAdapter.cs
- HttpListenerRequest.cs
- ArraySortHelper.cs
- StaticExtension.cs
- EnumBuilder.cs
- TextServicesHost.cs
- ConfigurationManagerInternal.cs
- WindowsSolidBrush.cs
- LightweightEntityWrapper.cs
- BinaryObjectReader.cs
- HtmlLiteralTextAdapter.cs
- Rule.cs
- TextServicesProperty.cs
- Keywords.cs
- SapiGrammar.cs
- TraceListeners.cs
- ButtonStandardAdapter.cs
- Converter.cs
- LinqDataSourceStatusEventArgs.cs
- Drawing.cs
- DbMetaDataFactory.cs
- MsmqInputChannelListener.cs
- PropVariant.cs
- ObjectDataSourceEventArgs.cs
- ComboBoxAutomationPeer.cs
- FixedSOMTableCell.cs
- ShellProvider.cs
- RuleRefElement.cs
- SerializationHelper.cs
- CustomPopupPlacement.cs
- Vector.cs
- SafeFileHandle.cs
- SystemMulticastIPAddressInformation.cs
- Bitmap.cs
- AspNetHostingPermission.cs
- StylusCaptureWithinProperty.cs
- ObjectDataSourceChooseMethodsPanel.cs