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
- PassportIdentity.cs
- EventEntry.cs
- Literal.cs
- ProviderUtil.cs
- Shape.cs
- HttpUnhandledOperationInvoker.cs
- UxThemeWrapper.cs
- Parser.cs
- DesignerForm.cs
- GenericEnumerator.cs
- LinearQuaternionKeyFrame.cs
- DefaultExpression.cs
- UiaCoreApi.cs
- RangeValidator.cs
- PeerCollaborationPermission.cs
- System.Data.OracleClient_BID.cs
- AsymmetricSignatureFormatter.cs
- Bits.cs
- RequestTimeoutManager.cs
- DelayedRegex.cs
- GACIdentityPermission.cs
- AdornerHitTestResult.cs
- GridViewRowEventArgs.cs
- ToolStripSeparatorRenderEventArgs.cs
- ReadOnlyCollection.cs
- DictionaryContent.cs
- XPathPatternParser.cs
- FontDifferentiator.cs
- safesecurityhelperavalon.cs
- NegatedConstant.cs
- SoapInteropTypes.cs
- DecimalConstantAttribute.cs
- Schema.cs
- RbTree.cs
- PageAsyncTaskManager.cs
- ICspAsymmetricAlgorithm.cs
- SimpleTypeResolver.cs
- CustomErrorCollection.cs
- RayMeshGeometry3DHitTestResult.cs
- FieldBuilder.cs
- NestPullup.cs
- DebuggerAttributes.cs
- XmlConvert.cs
- DataBinding.cs
- ConfigXmlElement.cs
- XmlSerializationGeneratedCode.cs
- XmlSchemaObjectCollection.cs
- ServicePoint.cs
- ScrollEvent.cs
- ContentPlaceHolder.cs
- RuntimeHandles.cs
- IndentTextWriter.cs
- StringOutput.cs
- DateRangeEvent.cs
- OutputCacheSettingsSection.cs
- mactripleDES.cs
- FileIOPermission.cs
- Matrix.cs
- StreamReader.cs
- ByteRangeDownloader.cs
- SQLCharsStorage.cs
- EntityConnection.cs
- Mappings.cs
- DataSvcMapFile.cs
- BitmapInitialize.cs
- DigestComparer.cs
- DesignerVerbCollection.cs
- TableLayout.cs
- HandlerBase.cs
- TemplateComponentConnector.cs
- NativeMethods.cs
- RawStylusSystemGestureInputReport.cs
- ItemContainerGenerator.cs
- InstanceCreationEditor.cs
- MenuTracker.cs
- InvalidPropValue.cs
- Nullable.cs
- DataGridViewComboBoxCell.cs
- DecoderExceptionFallback.cs
- StylusSystemGestureEventArgs.cs
- ButtonChrome.cs
- MaskedTextProvider.cs
- XmlSchemaSimpleTypeRestriction.cs
- ComAdminWrapper.cs
- CodeAttributeArgument.cs
- HtmlInputImage.cs
- Literal.cs
- Int16.cs
- Simplifier.cs
- TextEffectResolver.cs
- UpdatePanel.cs
- DetailsViewRowCollection.cs
- TableCell.cs
- documentsequencetextpointer.cs
- PropertyGridCommands.cs
- KeyFrames.cs
- VirtualizingPanel.cs
- ImpersonateTokenRef.cs
- FormsAuthenticationModule.cs
- ApplicationSettingsBase.cs