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
- SQLInt16.cs
- parserscommon.cs
- FormViewCommandEventArgs.cs
- Select.cs
- TabRenderer.cs
- PostBackTrigger.cs
- _PooledStream.cs
- DataSvcMapFileSerializer.cs
- PtsContext.cs
- DeviceContext2.cs
- RuntimeHandles.cs
- EvidenceTypeDescriptor.cs
- InstancePersistence.cs
- RawAppCommandInputReport.cs
- XmlNamespaceDeclarationsAttribute.cs
- Bidi.cs
- ObjectSecurityT.cs
- InlineUIContainer.cs
- DrawingAttributesDefaultValueFactory.cs
- GlyphCache.cs
- TreeNodeEventArgs.cs
- ImageKeyConverter.cs
- WorkflowWebHostingModule.cs
- AbstractDataSvcMapFileLoader.cs
- EntitySqlQueryCacheEntry.cs
- FixedFindEngine.cs
- HostVisual.cs
- PriorityItem.cs
- EntitySqlQueryCacheKey.cs
- SessionEndingEventArgs.cs
- ListViewInsertionMark.cs
- Types.cs
- InputLangChangeRequestEvent.cs
- PeerSecurityHelpers.cs
- SocketException.cs
- RandomDelayQueuedSendsAsyncResult.cs
- ListenerConnectionDemuxer.cs
- FloaterParaClient.cs
- FormViewUpdatedEventArgs.cs
- DataGridViewCellParsingEventArgs.cs
- MatrixIndependentAnimationStorage.cs
- SqlStream.cs
- TypeUtil.cs
- IApplicationTrustManager.cs
- CultureMapper.cs
- ToolStripDropDownItem.cs
- PagedDataSource.cs
- PreloadedPackages.cs
- StandardToolWindows.cs
- DataAccessor.cs
- SerializationObjectManager.cs
- FileDetails.cs
- ObjectCloneHelper.cs
- FrameworkElementAutomationPeer.cs
- RectAnimationBase.cs
- TableAdapterManagerGenerator.cs
- ButtonFlatAdapter.cs
- _NetworkingPerfCounters.cs
- SQLConvert.cs
- ThreadExceptionDialog.cs
- BuildProvider.cs
- IndependentlyAnimatedPropertyMetadata.cs
- UpdatePanelControlTrigger.cs
- Matrix3D.cs
- EnvelopedPkcs7.cs
- EncoderReplacementFallback.cs
- XmlReturnWriter.cs
- StreamFormatter.cs
- Lazy.cs
- TextChange.cs
- XPathDocument.cs
- RectangleConverter.cs
- InstanceKey.cs
- Transform.cs
- MaskedTextBox.cs
- XamlLoadErrorInfo.cs
- SelectionRange.cs
- HitTestParameters3D.cs
- EmbeddedMailObject.cs
- MeasureData.cs
- __Filters.cs
- SqlServices.cs
- MatchAttribute.cs
- DropSource.cs
- QueryResponse.cs
- UInt64.cs
- HandledEventArgs.cs
- StreamReader.cs
- TextBoxView.cs
- ADMembershipUser.cs
- QuaternionValueSerializer.cs
- XmlRootAttribute.cs
- IriParsingElement.cs
- QueryableDataSourceEditData.cs
- PublisherIdentityPermission.cs
- DataBoundLiteralControl.cs
- IChannel.cs
- PtsContext.cs
- PersonalizablePropertyEntry.cs
- BindingListCollectionView.cs