Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / fx / src / Data / System / Data / DataError.cs / 1 / DataError.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //[....] //[....] //[....] //----------------------------------------------------------------------------- namespace System.Data { using System; using System.Diagnostics; ////// internal sealed class DataError { private string rowError = String.Empty; // column-level errors private int count; private ColumnError[] errorList; internal const int initialCapacity = 1; internal DataError() { } internal DataError(string rowError) { SetText(rowError); } internal string Text { get { return rowError; } set { SetText(value); } } internal bool HasErrors { get { return(rowError.Length != 0 || count != 0); } } // // this method resets the error to the new value. // internal void SetColumnError(DataColumn column, string error) { Debug.Assert(column != null, "Invalid (null) argument"); Debug.Assert(column.Table != null, "Invalid (loose) column"); if (error == null || error.Length == 0) { // remove error from the collection Clear(column); } else { if (errorList == null) { errorList = new ColumnError[initialCapacity]; } int i = IndexOf(column); errorList[i].column = column; errorList[i].error = error; column.errors++; if (i == count) count++; } } internal string GetColumnError(DataColumn column) { for (int i = 0; i < count; i++) { if (errorList[i].column == column) { return errorList[i].error; } } return String.Empty; } internal void Clear(DataColumn column) { if (count == 0) return; for (int i = 0; i < count; i++) { if (errorList[i].column == column) { System.Array.Copy(errorList, i+1, errorList, i, count-i-1); count--; column.errors--; Debug.Assert(column.errors >= 0, "missing error counts"); } } } internal void Clear() { for (int i = 0; i < count; i++) { errorList[i].column.errors--; Debug.Assert(errorList[i].column.errors >= 0, "missing error counts"); } count = 0; rowError = String.Empty; } internal DataColumn[] GetColumnsInError() { DataColumn[] cols = new DataColumn[count]; for (int i = 0; i < count; i++) { cols[i] = errorList[i].column; } return cols; } ///Represents an custom error that can be associated with a ///. /// private void SetText(string errorText) { if (null == errorText) { errorText = String.Empty; } rowError = errorText; } internal int IndexOf (DataColumn column) { // try to find the column for (int i = 0; i < count; i++) { if (errorList[i].column == column) { return i; } } if (count >= errorList.Length) { int newCapacity = Math.Min(count*2, column.Table.Columns.Count); ColumnError[] biggerList = new ColumnError[newCapacity]; System.Array.Copy(errorList, 0, biggerList, 0, count); errorList = biggerList; } return count; } internal struct ColumnError { internal DataColumn column; internal string error; }; } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.Sets the error message for the ///.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DbTransaction.cs
- BrowserCapabilitiesCodeGenerator.cs
- ReferencedAssembly.cs
- KeyFrames.cs
- CssClassPropertyAttribute.cs
- DocumentPageViewAutomationPeer.cs
- CodeMemberEvent.cs
- XmlSchemaSimpleTypeList.cs
- MetadataPropertyAttribute.cs
- latinshape.cs
- DiagnosticTraceSource.cs
- MultiTrigger.cs
- EncoderFallback.cs
- CompilerCollection.cs
- CachedPathData.cs
- TrustManagerMoreInformation.cs
- BidirectionalDictionary.cs
- ParenthesizePropertyNameAttribute.cs
- ContentIterators.cs
- MimePart.cs
- PointConverter.cs
- mediaeventargs.cs
- GcHandle.cs
- UserThread.cs
- DataControlLinkButton.cs
- CodeMethodInvokeExpression.cs
- ComAdminWrapper.cs
- MeshGeometry3D.cs
- DictionaryBase.cs
- OracleColumn.cs
- BaseTreeIterator.cs
- ToolStripContentPanelDesigner.cs
- PnrpPeerResolverBindingElement.cs
- Marshal.cs
- ClientTargetSection.cs
- DataGridViewDataErrorEventArgs.cs
- SizeAnimationBase.cs
- RoleService.cs
- XmlEntity.cs
- Transform3DGroup.cs
- MimeTypeMapper.cs
- DiscoveryService.cs
- NamedPermissionSet.cs
- EndEvent.cs
- BitmapFrame.cs
- DataPager.cs
- EntitySetBase.cs
- BaseServiceProvider.cs
- EraserBehavior.cs
- SqlDataSourceStatusEventArgs.cs
- Italic.cs
- PropertyOverridesTypeEditor.cs
- ComboBoxRenderer.cs
- ProviderUtil.cs
- SQLInt64Storage.cs
- ConsoleEntryPoint.cs
- DateTimeFormatInfo.cs
- ChannelDispatcher.cs
- BamlRecordHelper.cs
- JsonByteArrayDataContract.cs
- XmlSchemaImporter.cs
- DbTransaction.cs
- KeyFrames.cs
- DynamicILGenerator.cs
- XmlExpressionDumper.cs
- DataGridRow.cs
- Rotation3D.cs
- HatchBrush.cs
- DrawingBrush.cs
- Point3DCollectionConverter.cs
- PointKeyFrameCollection.cs
- Privilege.cs
- PropertyStore.cs
- WindowInteropHelper.cs
- FieldBuilder.cs
- Color.cs
- ControlPaint.cs
- DataObjectMethodAttribute.cs
- DataServiceClientException.cs
- SessionStateContainer.cs
- RemotingClientProxy.cs
- SerializationObjectManager.cs
- SoapHeaders.cs
- MetadataHelper.cs
- PackageRelationshipSelector.cs
- ZipIOExtraFieldElement.cs
- GridViewDeleteEventArgs.cs
- SvcMapFile.cs
- Int32Storage.cs
- SerializationFieldInfo.cs
- PrimitiveList.cs
- MinimizableAttributeTypeConverter.cs
- WebServiceData.cs
- Boolean.cs
- AttributeEmitter.cs
- _OverlappedAsyncResult.cs
- IisTraceWebEventProvider.cs
- XamlReader.cs
- CompiledELinqQueryState.cs
- ProcessHost.cs