Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / 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
- VirtualPathProvider.cs
- MissingFieldException.cs
- AccessedThroughPropertyAttribute.cs
- FormattedText.cs
- RtfToXamlReader.cs
- OrderedDictionary.cs
- _LocalDataStoreMgr.cs
- Pkcs7Signer.cs
- XmlDocumentType.cs
- KeyboardNavigation.cs
- SqlInternalConnection.cs
- GacUtil.cs
- MediaEntryAttribute.cs
- UpdateProgress.cs
- ItemCheckedEvent.cs
- KeyValueSerializer.cs
- DynamicQueryableWrapper.cs
- DetailsViewCommandEventArgs.cs
- ConfigViewGenerator.cs
- Span.cs
- EncryptedReference.cs
- HtmlUtf8RawTextWriter.cs
- EntityDataSourceWizardForm.cs
- StandardToolWindows.cs
- Vector.cs
- PropertyEmitterBase.cs
- IconConverter.cs
- SqlNodeAnnotations.cs
- MachineKeyConverter.cs
- RectConverter.cs
- xdrvalidator.cs
- ProfileSection.cs
- TypeConverterHelper.cs
- ExpressionVisitor.cs
- Executor.cs
- CharacterMetrics.cs
- TextFormatterContext.cs
- ColorConverter.cs
- InvalidateEvent.cs
- PersonalizationProviderCollection.cs
- LookupBindingPropertiesAttribute.cs
- SystemPens.cs
- ApplicationDirectory.cs
- LessThanOrEqual.cs
- NotifyParentPropertyAttribute.cs
- SamlSecurityToken.cs
- XmlTextReader.cs
- MissingMemberException.cs
- ListDictionaryInternal.cs
- WebPartTransformerAttribute.cs
- URLMembershipCondition.cs
- EventLog.cs
- InternalControlCollection.cs
- TracedNativeMethods.cs
- ListControl.cs
- Registry.cs
- Activity.cs
- ToolStripPanel.cs
- ShaperBuffers.cs
- SystemMulticastIPAddressInformation.cs
- DataGridViewColumnTypePicker.cs
- BindToObject.cs
- HttpModuleActionCollection.cs
- XmlSchemaSimpleTypeUnion.cs
- TemplateFactory.cs
- ComboBoxRenderer.cs
- QueryReaderSettings.cs
- ClientOperation.cs
- SelectedDatesCollection.cs
- ConditionalExpression.cs
- CompiledQuery.cs
- ActivatedMessageQueue.cs
- DataGridViewCellConverter.cs
- GlobalItem.cs
- DataGridParentRows.cs
- EventSourceCreationData.cs
- UpDownEvent.cs
- NotifyIcon.cs
- lengthconverter.cs
- LinqDataSourceContextEventArgs.cs
- SoapObjectReader.cs
- JulianCalendar.cs
- AttributeCollection.cs
- ComplexTypeEmitter.cs
- EntityChangedParams.cs
- ServiceInstanceProvider.cs
- DataSetUtil.cs
- TemplatePropertyEntry.cs
- SHA384Cng.cs
- DocumentPropertiesDialog.cs
- HandledMouseEvent.cs
- TextSchema.cs
- HttpHandlersSection.cs
- WindowsListViewItemStartMenu.cs
- ExtendLockCommand.cs
- ProjectionPlanCompiler.cs
- StringCollection.cs
- InitializationEventAttribute.cs
- ReflectionServiceProvider.cs
- SectionXmlInfo.cs