Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / 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
- ClientConvert.cs
- ScriptingRoleServiceSection.cs
- DeferredReference.cs
- PropertyEmitter.cs
- SingleKeyFrameCollection.cs
- DataGridViewCellConverter.cs
- SocketException.cs
- AnnotationObservableCollection.cs
- TextServicesCompartmentContext.cs
- SerTrace.cs
- HttpUnhandledOperationInvoker.cs
- coordinatorscratchpad.cs
- TypedElement.cs
- PrePostDescendentsWalker.cs
- PageStatePersister.cs
- SmiConnection.cs
- UrlAuthorizationModule.cs
- EntityConnection.cs
- DataRecordInfo.cs
- MonikerProxyAttribute.cs
- ToolStripLocationCancelEventArgs.cs
- NotFiniteNumberException.cs
- Rotation3DKeyFrameCollection.cs
- DetailsViewInsertEventArgs.cs
- PopupRoot.cs
- ConfigurationSettings.cs
- validation.cs
- FormatException.cs
- ParseNumbers.cs
- ProfileSettings.cs
- RefreshEventArgs.cs
- EdmScalarPropertyAttribute.cs
- TableLayoutCellPaintEventArgs.cs
- ClientRolePrincipal.cs
- TextTabProperties.cs
- followingquery.cs
- BitArray.cs
- CryptoStream.cs
- DetailsViewRowCollection.cs
- DataBindingCollection.cs
- MsmqOutputChannel.cs
- X509CertificateChain.cs
- Filter.cs
- Pair.cs
- ActiveXContainer.cs
- ResourcePool.cs
- Constraint.cs
- StartUpEventArgs.cs
- CountdownEvent.cs
- DataMemberAttribute.cs
- UpdatePanelTriggerCollection.cs
- DelegatedStream.cs
- ClientSponsor.cs
- CellCreator.cs
- OSFeature.cs
- CodeDomSerializerBase.cs
- OutputCacheProfile.cs
- CodeArrayCreateExpression.cs
- RoleGroup.cs
- HttpHandler.cs
- QilTernary.cs
- SoundPlayer.cs
- DataContractSet.cs
- VectorConverter.cs
- VisualStyleInformation.cs
- TextElement.cs
- HttpContextBase.cs
- IisTraceListener.cs
- GetIsBrowserClientRequest.cs
- EndpointAddressAugust2004.cs
- WebDisplayNameAttribute.cs
- ZipIOCentralDirectoryBlock.cs
- EnumConverter.cs
- RuntimeWrappedException.cs
- SignatureResourcePool.cs
- DoubleUtil.cs
- UInt32Storage.cs
- SqlAliasesReferenced.cs
- DataGridViewSortCompareEventArgs.cs
- LongValidatorAttribute.cs
- NonSerializedAttribute.cs
- OpCopier.cs
- TreeIterator.cs
- ReturnEventArgs.cs
- BreakRecordTable.cs
- BuildResult.cs
- HtmlTableCell.cs
- XpsDocument.cs
- NonParentingControl.cs
- CodeDefaultValueExpression.cs
- CodeCastExpression.cs
- VirtualPathProvider.cs
- AssociationTypeEmitter.cs
- AttachmentCollection.cs
- Root.cs
- SafeRightsManagementPubHandle.cs
- XmlHierarchyData.cs
- WebPageTraceListener.cs
- ListViewItemMouseHoverEvent.cs
- IMembershipProvider.cs