Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / 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. //------------------------------------------------------------------------------ //Sets the error message for the ///. // 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.Sets the error message for the ///.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ShaderEffect.cs
- WebCategoryAttribute.cs
- loginstatus.cs
- UrlPath.cs
- Accessible.cs
- SEHException.cs
- ConfigurationLockCollection.cs
- EnumDataContract.cs
- TypedTableHandler.cs
- ITextView.cs
- DataTableNewRowEvent.cs
- DbMetaDataFactory.cs
- TableDetailsRow.cs
- TablePattern.cs
- ItemTypeToolStripMenuItem.cs
- WebSysDefaultValueAttribute.cs
- GB18030Encoding.cs
- HelpOperationInvoker.cs
- Deflater.cs
- DBDataPermissionAttribute.cs
- DataControlField.cs
- TdsParserHelperClasses.cs
- CqlErrorHelper.cs
- SessionStateSection.cs
- QilParameter.cs
- Int32EqualityComparer.cs
- AnimatedTypeHelpers.cs
- FlowDocumentPageViewerAutomationPeer.cs
- Block.cs
- TriState.cs
- Blend.cs
- SmtpSpecifiedPickupDirectoryElement.cs
- InvokeGenerator.cs
- SrgsElementFactoryCompiler.cs
- XmlSchemaAnnotation.cs
- DelegatedStream.cs
- HighlightVisual.cs
- FieldNameLookup.cs
- filewebresponse.cs
- AttributeCollection.cs
- FileDialogPermission.cs
- OfTypeExpression.cs
- CurrentChangingEventManager.cs
- XmlNavigatorStack.cs
- ClassDataContract.cs
- FileDialogCustomPlace.cs
- IUnknownConstantAttribute.cs
- CommonDialog.cs
- PropertyToken.cs
- PersonalizationProvider.cs
- TypeUtil.cs
- XmlHierarchyData.cs
- CellIdBoolean.cs
- AttributeProviderAttribute.cs
- CSharpCodeProvider.cs
- DataGridViewCellStyleChangedEventArgs.cs
- WebPartCollection.cs
- ErrorProvider.cs
- ScrollChrome.cs
- ContextMenu.cs
- RequiredAttributeAttribute.cs
- PostBackTrigger.cs
- TemplateApplicationHelper.cs
- StorageInfo.cs
- DataFieldEditor.cs
- smtpconnection.cs
- DesigntimeLicenseContext.cs
- QuaternionAnimationUsingKeyFrames.cs
- TextReturnReader.cs
- ConfigurationManagerHelperFactory.cs
- ListBindableAttribute.cs
- NullableFloatAverageAggregationOperator.cs
- CompositeKey.cs
- DispatcherObject.cs
- DLinqTableProvider.cs
- SystemInformation.cs
- rsa.cs
- CapabilitiesSection.cs
- TextEditorParagraphs.cs
- BinaryMessageEncoder.cs
- PipeStream.cs
- httpstaticobjectscollection.cs
- ProcessStartInfo.cs
- MenuStrip.cs
- Int16Converter.cs
- EncoderExceptionFallback.cs
- UnsafeCollabNativeMethods.cs
- PriorityBinding.cs
- SystemResourceKey.cs
- XmlMemberMapping.cs
- _NegotiateClient.cs
- ControlBuilder.cs
- Size.cs
- documentsequencetextview.cs
- PathData.cs
- ActivityBindForm.cs
- DefaultHttpHandler.cs
- CommonDialog.cs
- Int32AnimationBase.cs
- ErrorProvider.cs