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
- XmlSchemaObjectTable.cs
- DataGridTableCollection.cs
- CaseExpr.cs
- Buffer.cs
- ClientProxyGenerator.cs
- XmlSubtreeReader.cs
- DynamicActivityXamlReader.cs
- InvalidateEvent.cs
- DropShadowBitmapEffect.cs
- LayoutSettings.cs
- _OverlappedAsyncResult.cs
- RuntimeHandles.cs
- TraceHwndHost.cs
- AttributeEmitter.cs
- CodeGroup.cs
- Win32Native.cs
- ConnectionsZone.cs
- DataSourceSelectArguments.cs
- DialogBaseForm.cs
- ScalarType.cs
- TriggerCollection.cs
- TemplatedWizardStep.cs
- VirtualDirectoryMappingCollection.cs
- FilePrompt.cs
- DeclarationUpdate.cs
- WindowsGrip.cs
- TextViewSelectionProcessor.cs
- XmlAutoDetectWriter.cs
- GradientSpreadMethodValidation.cs
- GradientStopCollection.cs
- Internal.cs
- Convert.cs
- RepeaterCommandEventArgs.cs
- SiteMapNodeItemEventArgs.cs
- XmlUtil.cs
- WebResourceAttribute.cs
- OperandQuery.cs
- QilInvokeEarlyBound.cs
- MainMenu.cs
- FormsAuthentication.cs
- ZoneMembershipCondition.cs
- SerializationInfo.cs
- WebServiceClientProxyGenerator.cs
- MethodExpression.cs
- HtmlTableRow.cs
- Triangle.cs
- ReaderContextStackData.cs
- RankException.cs
- ThreadSafeList.cs
- URLAttribute.cs
- DetailsViewPageEventArgs.cs
- FeatureSupport.cs
- EntityDataSourceContainerNameConverter.cs
- SortDescriptionCollection.cs
- SchemaNames.cs
- Identity.cs
- EventKeyword.cs
- UInt64.cs
- StylusPointPropertyInfo.cs
- SymbolEqualComparer.cs
- StaticResourceExtension.cs
- HashSetEqualityComparer.cs
- ObjectList.cs
- DataSourceCache.cs
- ListBoxItemWrapperAutomationPeer.cs
- DrawingBrush.cs
- HtmlEncodedRawTextWriter.cs
- Process.cs
- StorageMappingFragment.cs
- Assert.cs
- METAHEADER.cs
- NaturalLanguageHyphenator.cs
- DataPager.cs
- FrameAutomationPeer.cs
- ListViewInsertEventArgs.cs
- DataView.cs
- SqlGatherConsumedAliases.cs
- Point3DConverter.cs
- NominalTypeEliminator.cs
- AstTree.cs
- SubtreeProcessor.cs
- GridViewCellAutomationPeer.cs
- DesignerAttribute.cs
- GridViewRowEventArgs.cs
- RoutedEvent.cs
- SmiRecordBuffer.cs
- RegistryConfigurationProvider.cs
- TextTreeTextBlock.cs
- ToolStripRenderEventArgs.cs
- DomNameTable.cs
- ShapingEngine.cs
- DynamicResourceExtensionConverter.cs
- IArgumentProvider.cs
- LowerCaseStringConverter.cs
- FormViewModeEventArgs.cs
- FontSource.cs
- CallbackValidator.cs
- IconConverter.cs
- DbProviderFactories.cs
- HTMLTagNameToTypeMapper.cs