Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / 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
- SoapElementAttribute.cs
- ObjectAnimationBase.cs
- InternalUserCancelledException.cs
- TableItemProviderWrapper.cs
- TextTreeInsertUndoUnit.cs
- WebPartConnectionCollection.cs
- DBBindings.cs
- DBConnectionString.cs
- SvcMapFile.cs
- Calendar.cs
- DataSourceXmlTextReader.cs
- MenuItemStyleCollection.cs
- SelectingProviderEventArgs.cs
- SelectionPattern.cs
- XmlSchemaAttributeGroup.cs
- EntityDataSourceChangingEventArgs.cs
- ScrollBar.cs
- WebPartHelpVerb.cs
- coordinatorscratchpad.cs
- WorkflowTransactionOptions.cs
- SettingsAttributes.cs
- RecognizerInfo.cs
- ProtocolsConfigurationEntry.cs
- SecureUICommand.cs
- HttpDictionary.cs
- ValuePatternIdentifiers.cs
- TransformConverter.cs
- StylusPointDescription.cs
- Avt.cs
- InvalidOperationException.cs
- Scene3D.cs
- HttpWrapper.cs
- UnauthorizedWebPart.cs
- CharEnumerator.cs
- XhtmlConformanceSection.cs
- DragDrop.cs
- DeclarativeConditionsCollection.cs
- ArrayExtension.cs
- XmlSchemaAppInfo.cs
- OleDbInfoMessageEvent.cs
- DropShadowBitmapEffect.cs
- BooleanAnimationBase.cs
- XmlParserContext.cs
- CopyOnWriteList.cs
- SafeFileHandle.cs
- AssemblyName.cs
- ListControlBoundActionList.cs
- WsdlExporter.cs
- MenuBase.cs
- OutputCacheProfileCollection.cs
- WCFModelStrings.Designer.cs
- XmlAttributeProperties.cs
- WebPartMenuStyle.cs
- TextChange.cs
- UTF8Encoding.cs
- Attributes.cs
- UriExt.cs
- AudioBase.cs
- Operator.cs
- ScalarOps.cs
- ResourceAttributes.cs
- MiniLockedBorderGlyph.cs
- ClientConvert.cs
- grammarelement.cs
- CompilerParameters.cs
- ButtonBaseAutomationPeer.cs
- filewebrequest.cs
- BinaryParser.cs
- AppDomainManager.cs
- CatalogZone.cs
- QuaternionAnimation.cs
- PermissionToken.cs
- TextMarkerSource.cs
- X509CertificateChain.cs
- TextElementEnumerator.cs
- UnsafeNativeMethods.cs
- XpsResourceDictionary.cs
- SchemaSetCompiler.cs
- CharacterHit.cs
- ListMarkerLine.cs
- SortedDictionary.cs
- DataBoundControl.cs
- EmptyQuery.cs
- FormViewUpdatedEventArgs.cs
- HideDisabledControlAdapter.cs
- KeyPressEvent.cs
- CryptoApi.cs
- InputBuffer.cs
- SafeArrayTypeMismatchException.cs
- OleDbRowUpdatingEvent.cs
- TransformerConfigurationWizardBase.cs
- PointCollectionConverter.cs
- BitmapSource.cs
- FrameworkContextData.cs
- ReliableOutputSessionChannel.cs
- ListDictionaryInternal.cs
- CodeSnippetStatement.cs
- ConversionContext.cs
- EmptyTextWriter.cs
- FixedSOMLineRanges.cs