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
- BufferModesCollection.cs
- ParameterElement.cs
- PolyLineSegmentFigureLogic.cs
- HttpCacheVary.cs
- WindowsGraphics.cs
- ConstructorNeedsTagAttribute.cs
- ParameterCollection.cs
- DoubleAnimationUsingPath.cs
- AddInController.cs
- RequiredAttributeAttribute.cs
- TryExpression.cs
- DataGridRowAutomationPeer.cs
- Group.cs
- DataGridViewCellPaintingEventArgs.cs
- ClientConvert.cs
- HtmlForm.cs
- ObjectItemCollectionAssemblyCacheEntry.cs
- assertwrapper.cs
- TransformValueSerializer.cs
- SqlTriggerContext.cs
- Exception.cs
- EntryPointNotFoundException.cs
- AssemblyGen.cs
- PersonalizationProviderCollection.cs
- SecurityContext.cs
- HttpCapabilitiesSectionHandler.cs
- ApplicationGesture.cs
- _NegoStream.cs
- GroupBox.cs
- CallTemplateAction.cs
- InvalidDocumentContentsException.cs
- EmptyReadOnlyDictionaryInternal.cs
- LOSFormatter.cs
- validationstate.cs
- SystemIPv6InterfaceProperties.cs
- UndoManager.cs
- EllipseGeometry.cs
- EventLogPermissionAttribute.cs
- Stack.cs
- BoundField.cs
- StylusPointPropertyInfoDefaults.cs
- XmlSchemaAny.cs
- SqlDataSourceQueryConverter.cs
- XmlConvert.cs
- SecurityVerifiedMessage.cs
- ToolboxDataAttribute.cs
- CollectionChangedEventManager.cs
- _PooledStream.cs
- HttpEncoder.cs
- NativeCppClassAttribute.cs
- ValueUtilsSmi.cs
- VisualTarget.cs
- PrintPreviewControl.cs
- Cursor.cs
- SchemaDeclBase.cs
- TreeBuilderBamlTranslator.cs
- X509CertificateCollection.cs
- TableCell.cs
- XmlValidatingReaderImpl.cs
- Schema.cs
- FlowchartStart.xaml.cs
- LinqDataSourceContextEventArgs.cs
- DashStyle.cs
- PlatformCulture.cs
- COM2IDispatchConverter.cs
- AuthenticationSection.cs
- GenericFlowSwitchHelper.cs
- CoTaskMemUnicodeSafeHandle.cs
- SoapExtensionTypeElement.cs
- XPathPatternBuilder.cs
- SqlNotificationEventArgs.cs
- LineBreakRecord.cs
- SharedStatics.cs
- Model3D.cs
- ViewSimplifier.cs
- AspNetHostingPermission.cs
- HttpServerVarsCollection.cs
- CheckoutException.cs
- DataGridViewCellValueEventArgs.cs
- Int32Converter.cs
- ModelItemKeyValuePair.cs
- ProjectionNode.cs
- DataGridViewCellStateChangedEventArgs.cs
- ManagementNamedValueCollection.cs
- isolationinterop.cs
- Path.cs
- OracleNumber.cs
- TableColumnCollectionInternal.cs
- NotifyIcon.cs
- EdgeModeValidation.cs
- codemethodreferenceexpression.cs
- TargetConverter.cs
- SiteMapProvider.cs
- ViewLoader.cs
- TextProperties.cs
- SwitchAttribute.cs
- FontFamilyConverter.cs
- XmlSchemaSequence.cs
- XsltConvert.cs
- AttributeCollection.cs