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
- ObjectFactoryCodeDomTreeGenerator.cs
- ProgressBar.cs
- ProviderConnectionPoint.cs
- StorageEndPropertyMapping.cs
- CssStyleCollection.cs
- FillBehavior.cs
- ManagedWndProcTracker.cs
- PartialCachingControl.cs
- HttpInputStream.cs
- BindingOperations.cs
- TypeConverterHelper.cs
- WebBrowser.cs
- GridProviderWrapper.cs
- MouseEvent.cs
- EnumerableWrapperWeakToStrong.cs
- Point.cs
- DocumentOrderQuery.cs
- MessageSecurityOverHttpElement.cs
- Parsers.cs
- ErasingStroke.cs
- URL.cs
- TextEffect.cs
- Set.cs
- CommandLibraryHelper.cs
- EncryptedXml.cs
- OpacityConverter.cs
- AtomServiceDocumentSerializer.cs
- BypassElementCollection.cs
- DllNotFoundException.cs
- SystemIPv6InterfaceProperties.cs
- DataGridColumnCollection.cs
- PartBasedPackageProperties.cs
- ConfigurationSectionCollection.cs
- CompilerWrapper.cs
- AtomServiceDocumentSerializer.cs
- InteropBitmapSource.cs
- Assert.cs
- SafeNativeMethods.cs
- Deflater.cs
- NonBatchDirectoryCompiler.cs
- IncomingWebRequestContext.cs
- Evidence.cs
- FixedStringLookup.cs
- PassportPrincipal.cs
- SpeakCompletedEventArgs.cs
- COM2FontConverter.cs
- MatrixAnimationUsingPath.cs
- ObjectViewListener.cs
- MetadataCache.cs
- TypeNameHelper.cs
- UidManager.cs
- PeerCredential.cs
- dtdvalidator.cs
- ParserStreamGeometryContext.cs
- Viewport3DVisual.cs
- CLSCompliantAttribute.cs
- StrokeCollection2.cs
- VirtualPathUtility.cs
- AssemblyCache.cs
- NativeMethods.cs
- OracleConnectionFactory.cs
- MetafileHeader.cs
- BatchStream.cs
- SqlDelegatedTransaction.cs
- InvalidComObjectException.cs
- Vector3dCollection.cs
- AccessControlList.cs
- Form.cs
- DataRow.cs
- DataGridTextBoxColumn.cs
- WorkflowWebService.cs
- WebPartEditorOkVerb.cs
- _OSSOCK.cs
- FrameworkTemplate.cs
- Matrix.cs
- JsonUriDataContract.cs
- Int16AnimationUsingKeyFrames.cs
- InternalPermissions.cs
- ReaderWriterLock.cs
- EntityModelBuildProvider.cs
- BaseValidator.cs
- Size3D.cs
- SchemaHelper.cs
- StrokeNodeOperations.cs
- XmlSchemaAll.cs
- InstanceDescriptor.cs
- DataGridViewSelectedRowCollection.cs
- XsltLoader.cs
- JsonReader.cs
- AggregatePushdown.cs
- ProxyGenerationError.cs
- CacheDependency.cs
- DependentList.cs
- ObjectPersistData.cs
- EndpointAddressAugust2004.cs
- ContextMenu.cs
- Main.cs
- PolyLineSegmentFigureLogic.cs
- EntityCommandDefinition.cs
- DataTableClearEvent.cs