Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / 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
- TextDecorationUnitValidation.cs
- assertwrapper.cs
- Annotation.cs
- DispatcherEventArgs.cs
- Manipulation.cs
- TagPrefixInfo.cs
- WindowsIPAddress.cs
- DictionaryCustomTypeDescriptor.cs
- Version.cs
- FormViewUpdateEventArgs.cs
- SendingRequestEventArgs.cs
- CodeDomConfigurationHandler.cs
- CriticalHandle.cs
- UnauthorizedAccessException.cs
- KernelTypeValidation.cs
- SqlDataSourceCustomCommandPanel.cs
- entityreference_tresulttype.cs
- FullTextBreakpoint.cs
- Privilege.cs
- StrongNameIdentityPermission.cs
- SystemException.cs
- RectangleConverter.cs
- FontDriver.cs
- ExchangeUtilities.cs
- baseaxisquery.cs
- Stacktrace.cs
- __Filters.cs
- MachineSettingsSection.cs
- XmlSchemaSimpleContentExtension.cs
- SQLSingle.cs
- PersonalizationDictionary.cs
- DataGridViewColumnCollection.cs
- WrappedReader.cs
- SignatureToken.cs
- MetadataUtilsSmi.cs
- DockPanel.cs
- DirtyTextRange.cs
- OracleBinary.cs
- ResumeStoryboard.cs
- AdjustableArrowCap.cs
- FormsAuthenticationConfiguration.cs
- BrowserDefinitionCollection.cs
- UpdateTracker.cs
- ArgIterator.cs
- DesignerVerbCollection.cs
- ZeroOpNode.cs
- SafeMemoryMappedViewHandle.cs
- OleDbDataAdapter.cs
- BackgroundFormatInfo.cs
- Encoder.cs
- OdbcConnectionPoolProviderInfo.cs
- ClientScriptManager.cs
- InvalidEnumArgumentException.cs
- ToolStripSystemRenderer.cs
- ChangeTracker.cs
- DecimalFormatter.cs
- StorageConditionPropertyMapping.cs
- WrappedReader.cs
- HeaderLabel.cs
- _IPv4Address.cs
- LocalizabilityAttribute.cs
- ConfigurationFileMap.cs
- DataService.cs
- basevalidator.cs
- XmlLanguage.cs
- BypassElement.cs
- XmlSerializerFormatAttribute.cs
- CounterSample.cs
- ExtensibleClassFactory.cs
- AsymmetricKeyExchangeFormatter.cs
- DesignBindingValueUIHandler.cs
- _TransmitFileOverlappedAsyncResult.cs
- HttpCacheVary.cs
- TreeNodeCollection.cs
- Event.cs
- XmlUtil.cs
- formatter.cs
- Int16KeyFrameCollection.cs
- ContractCodeDomInfo.cs
- HttpContext.cs
- TemplatedWizardStep.cs
- DataGridViewIntLinkedList.cs
- FieldBuilder.cs
- StreamReader.cs
- Window.cs
- NullableDecimalAverageAggregationOperator.cs
- ServiceCredentialsElement.cs
- XmlSerializerSection.cs
- ActivityPropertyReference.cs
- LayoutEvent.cs
- SecurityTokenProvider.cs
- HttpRequestWrapper.cs
- MessageQueuePermissionEntryCollection.cs
- CngProvider.cs
- PropertyPathConverter.cs
- WindowAutomationPeer.cs
- RewritingValidator.cs
- RectangleGeometry.cs
- ITreeGenerator.cs
- DateTimeConverter2.cs