Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / ndp / fx / src / DataWeb / Design / system / Data / Common / Utils / StringUtil.cs / 1 / StringUtil.cs
//---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner [....] // @backupOwner [....] //--------------------------------------------------------------------- using System; using System.Collections; using System.Collections.Generic; using System.Text; using System.Globalization; using System.Diagnostics; namespace System.Data.Common.Utils { // This class provides some useful string utilities, e.g., converting a // list to string. internal static class StringUtil { ////// This private static method checks a string to make sure that it is not empty. /// Comparing with String.Empty is not sufficient since a string with nothing /// but white space isn't considered "empty" by that rationale. /// internal static bool IsNullOrEmptyOrWhiteSpace(string value) { return IsNullOrEmptyOrWhiteSpace(value, 0); } internal static bool IsNullOrEmptyOrWhiteSpace(string value, int offset) { // don't use Trim(), which will copy the string, which may be large, just to test for emptyness //return String.IsNullOrEmpty(value) || String.IsNullOrEmpty(value.Trim()); if (null != value) { for(int i = offset; i < value.Length; ++i) { if (!Char.IsWhiteSpace(value[i])) { return false; } } } return true; } // separate implementation from IsNullOrEmptyOrWhiteSpace(string, int) because that one will // pick up the jit optimization to avoid boundary checks and the this won't is unknown (most likely not) internal static bool IsNullOrEmptyOrWhiteSpace(string value, int offset, int length) { // don't use Trim(), which will copy the string, which may be large, just to test for emptyness //return String.IsNullOrEmpty(value) || String.IsNullOrEmpty(value.Trim()); if (null != value) { length = Math.Min(value.Length, length); for(int i = offset; i < length; ++i) { if (!Char.IsWhiteSpace(value[i])) { return false; } } } return true; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner [....] // @backupOwner [....] //--------------------------------------------------------------------- using System; using System.Collections; using System.Collections.Generic; using System.Text; using System.Globalization; using System.Diagnostics; namespace System.Data.Common.Utils { // This class provides some useful string utilities, e.g., converting a // list to string. internal static class StringUtil { ////// This private static method checks a string to make sure that it is not empty. /// Comparing with String.Empty is not sufficient since a string with nothing /// but white space isn't considered "empty" by that rationale. /// internal static bool IsNullOrEmptyOrWhiteSpace(string value) { return IsNullOrEmptyOrWhiteSpace(value, 0); } internal static bool IsNullOrEmptyOrWhiteSpace(string value, int offset) { // don't use Trim(), which will copy the string, which may be large, just to test for emptyness //return String.IsNullOrEmpty(value) || String.IsNullOrEmpty(value.Trim()); if (null != value) { for(int i = offset; i < value.Length; ++i) { if (!Char.IsWhiteSpace(value[i])) { return false; } } } return true; } // separate implementation from IsNullOrEmptyOrWhiteSpace(string, int) because that one will // pick up the jit optimization to avoid boundary checks and the this won't is unknown (most likely not) internal static bool IsNullOrEmptyOrWhiteSpace(string value, int offset, int length) { // don't use Trim(), which will copy the string, which may be large, just to test for emptyness //return String.IsNullOrEmpty(value) || String.IsNullOrEmpty(value.Trim()); if (null != value) { length = Math.Min(value.Length, length); for(int i = offset; i < length; ++i) { if (!Char.IsWhiteSpace(value[i])) { return false; } } } return true; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- View.cs
- Parser.cs
- AnnotationHelper.cs
- ConfigurationElement.cs
- TdsParserSessionPool.cs
- SiteOfOriginPart.cs
- ListViewContainer.cs
- StronglyTypedResourceBuilder.cs
- StorageSetMapping.cs
- PenContext.cs
- DiagnosticsConfigurationHandler.cs
- DoneReceivingAsyncResult.cs
- MonthCalendar.cs
- DataErrorValidationRule.cs
- TextFormatterImp.cs
- EpmSourceTree.cs
- ICspAsymmetricAlgorithm.cs
- TextElementCollectionHelper.cs
- SecurityAlgorithmSuite.cs
- OracleDataAdapter.cs
- RowUpdatedEventArgs.cs
- SaveFileDialog.cs
- ListControlBuilder.cs
- WindowsPrincipal.cs
- IndentTextWriter.cs
- UnsafeNativeMethods.cs
- WebEventTraceProvider.cs
- DetailsViewPagerRow.cs
- PropertyRecord.cs
- HostExecutionContextManager.cs
- DbConnectionInternal.cs
- WebPartVerbsEventArgs.cs
- AutomationPatternInfo.cs
- AudioDeviceOut.cs
- LocalizableResourceBuilder.cs
- RegexCapture.cs
- BaseDataList.cs
- TypedDataSetSchemaImporterExtension.cs
- StorageScalarPropertyMapping.cs
- ListViewUpdatedEventArgs.cs
- SchemaComplexType.cs
- FlowPosition.cs
- AsyncPostBackTrigger.cs
- Decorator.cs
- SqlRowUpdatedEvent.cs
- SchemaConstraints.cs
- StoreItemCollection.Loader.cs
- JoinGraph.cs
- WebPartHelpVerb.cs
- DefaultEventAttribute.cs
- CancelEventArgs.cs
- CompilationLock.cs
- AggregateNode.cs
- ByteAnimation.cs
- PlaceHolder.cs
- EntityDataSourceReferenceGroup.cs
- SafeWaitHandle.cs
- TreeView.cs
- ParseElementCollection.cs
- AVElementHelper.cs
- DataTableReader.cs
- coordinator.cs
- HttpServerVarsCollection.cs
- X509CertificateValidationMode.cs
- String.cs
- WebPartDisplayModeCollection.cs
- SmiMetaDataProperty.cs
- ThicknessConverter.cs
- X509AsymmetricSecurityKey.cs
- TrackingParameters.cs
- ImageCreator.cs
- RemoteArgument.cs
- WebPartUtil.cs
- SynchronizedInputPattern.cs
- OrderPreservingPipeliningSpoolingTask.cs
- OleDbTransaction.cs
- Point3DCollection.cs
- HtmlInputText.cs
- AttributeSetAction.cs
- Blend.cs
- SqlUnionizer.cs
- AffineTransform3D.cs
- FormViewPageEventArgs.cs
- TableLayoutSettings.cs
- StateBag.cs
- EventLogEntryCollection.cs
- WaitHandle.cs
- IntSecurity.cs
- AssociationSetMetadata.cs
- ChangePassword.cs
- ByteFacetDescriptionElement.cs
- CustomBindingElementCollection.cs
- DataServiceSaveChangesEventArgs.cs
- PathFigureCollection.cs
- FieldToken.cs
- TrackingExtract.cs
- DeploymentSection.cs
- ProcessProtocolHandler.cs
- SchemaNames.cs
- LookupBindingPropertiesAttribute.cs