Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Data / System / Data / DataError.cs / 1305376 / 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
- ClonableStack.cs
- PrePostDescendentsWalker.cs
- InputBinding.cs
- NullableLongAverageAggregationOperator.cs
- XmlPreloadedResolver.cs
- Stream.cs
- CodeTypeReferenceExpression.cs
- SqlDelegatedTransaction.cs
- XmlSerializableWriter.cs
- DrawListViewColumnHeaderEventArgs.cs
- DataConnectionHelper.cs
- formatter.cs
- documentsequencetextview.cs
- ModelPerspective.cs
- StoreAnnotationsMap.cs
- MetadataLocation.cs
- Win32Exception.cs
- Object.cs
- RemotingSurrogateSelector.cs
- altserialization.cs
- ImportCatalogPart.cs
- SqlReferenceCollection.cs
- SafeWaitHandle.cs
- ResolvedKeyFrameEntry.cs
- ProgressiveCrcCalculatingStream.cs
- SchemaElementLookUpTableEnumerator.cs
- ProcessProtocolHandler.cs
- DataGridViewColumnDesigner.cs
- WorkflowRuntimeServiceElement.cs
- NameValuePermission.cs
- CompilationPass2TaskInternal.cs
- PresentationTraceSources.cs
- ReliabilityContractAttribute.cs
- PrintingPermission.cs
- MetadataPropertyAttribute.cs
- CodeTypeReferenceExpression.cs
- RC2CryptoServiceProvider.cs
- RectAnimationUsingKeyFrames.cs
- KeyedPriorityQueue.cs
- Listbox.cs
- CalendarButtonAutomationPeer.cs
- UserPreferenceChangingEventArgs.cs
- UserControl.cs
- Maps.cs
- WebControlParameterProxy.cs
- ButtonChrome.cs
- SafeFindHandle.cs
- CompatibleIComparer.cs
- GenericsInstances.cs
- GridEntry.cs
- ServicePoint.cs
- QilInvokeEarlyBound.cs
- WorkflowInstanceContextProvider.cs
- InfiniteIntConverter.cs
- ColumnMapCopier.cs
- SqlClientWrapperSmiStreamChars.cs
- Certificate.cs
- ListItemCollection.cs
- DataServiceBuildProvider.cs
- AspNetSynchronizationContext.cs
- XmlSerializerAssemblyAttribute.cs
- InputLanguageManager.cs
- EllipseGeometry.cs
- BidOverLoads.cs
- SqlMethodAttribute.cs
- AppSettingsReader.cs
- LiteralText.cs
- WinFormsUtils.cs
- DataTransferEventArgs.cs
- CryptoApi.cs
- sqlmetadatafactory.cs
- SslStream.cs
- EditorPartChrome.cs
- Privilege.cs
- CrossAppDomainChannel.cs
- SoapExtensionTypeElement.cs
- PathFigureCollectionConverter.cs
- versioninfo.cs
- SystemFonts.cs
- Mappings.cs
- DataGridViewSelectedRowCollection.cs
- HMAC.cs
- StreamUpdate.cs
- ErrorStyle.cs
- ShutDownListener.cs
- TaiwanCalendar.cs
- SqlDataReaderSmi.cs
- smtpconnection.cs
- ViewManager.cs
- MissingManifestResourceException.cs
- BindingSourceDesigner.cs
- SudsCommon.cs
- ItemList.cs
- TextContainer.cs
- MailMessage.cs
- DataControlLinkButton.cs
- X509CertificateValidator.cs
- RenderData.cs
- TransformGroup.cs
- Renderer.cs