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
- ProtectedConfigurationProviderCollection.cs
- WebUtil.cs
- ReadOnlyNameValueCollection.cs
- KnownBoxes.cs
- XPathAncestorQuery.cs
- OneWayBindingElement.cs
- Permission.cs
- HtmlUtf8RawTextWriter.cs
- SqlUDTStorage.cs
- BamlTreeNode.cs
- SiteMapProvider.cs
- PageHandlerFactory.cs
- PartManifestEntry.cs
- NumberAction.cs
- ImplicitInputBrush.cs
- ConfigDefinitionUpdates.cs
- Roles.cs
- OrthographicCamera.cs
- ClientRoleProvider.cs
- SqlMultiplexer.cs
- HostingPreferredMapPath.cs
- HttpCapabilitiesSectionHandler.cs
- X509CertificateChain.cs
- ErrorWrapper.cs
- WindowsAltTab.cs
- MessageQueuePermissionAttribute.cs
- TargetException.cs
- PackageStore.cs
- AstTree.cs
- WindowsAuthenticationModule.cs
- ConstraintStruct.cs
- TemplatedMailWebEventProvider.cs
- recordstatescratchpad.cs
- oledbconnectionstring.cs
- ZipFileInfoCollection.cs
- BamlLocalizerErrorNotifyEventArgs.cs
- MD5Cng.cs
- TripleDESCryptoServiceProvider.cs
- AutoSizeToolBoxItem.cs
- ScrollItemPattern.cs
- ContentControl.cs
- EntityContainerAssociationSetEnd.cs
- TextBoxRenderer.cs
- XmlSchemaIdentityConstraint.cs
- listitem.cs
- FactoryRecord.cs
- RepeaterItemEventArgs.cs
- DbDeleteCommandTree.cs
- DesignerAutoFormatCollection.cs
- SrgsDocumentParser.cs
- GeometryModel3D.cs
- CodeCompileUnit.cs
- ProfileManager.cs
- TypeLoadException.cs
- CaretElement.cs
- ErrorProvider.cs
- TreeNodeStyleCollectionEditor.cs
- TypedTableGenerator.cs
- StreamHelper.cs
- HtmlTableRowCollection.cs
- TreeNodeStyleCollection.cs
- UnsafeNativeMethods.cs
- HelpProvider.cs
- InstanceStore.cs
- ScriptRef.cs
- JsonQueryStringConverter.cs
- BindToObject.cs
- ReflectEventDescriptor.cs
- PerformanceCounterCategory.cs
- PopOutPanel.cs
- IntegrationExceptionEventArgs.cs
- MailSettingsSection.cs
- SoapFault.cs
- CacheMemory.cs
- codemethodreferenceexpression.cs
- PackagePart.cs
- UpdatePanelTriggerCollection.cs
- FixedSOMTable.cs
- ToolStripPanelRow.cs
- WebScriptServiceHostFactory.cs
- ExtensionSimplifierMarkupObject.cs
- SinglePhaseEnlistment.cs
- FusionWrap.cs
- XmlReaderSettings.cs
- LocationSectionRecord.cs
- DefaultProxySection.cs
- DeflateStream.cs
- TableLayoutPanelResizeGlyph.cs
- MediaPlayer.cs
- NamespaceDisplay.xaml.cs
- SQLDouble.cs
- SettingsProviderCollection.cs
- PathSegmentCollection.cs
- MouseGestureConverter.cs
- GlobalizationAssembly.cs
- XmlSchemaSimpleContent.cs
- EventLogTraceListener.cs
- MethodExpr.cs
- autovalidator.cs
- DetailsViewRow.cs