Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / 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
- WindowsServiceElement.cs
- AsymmetricKeyExchangeFormatter.cs
- codemethodreferenceexpression.cs
- ZoneButton.cs
- ObjectQueryState.cs
- WebHttpBindingElement.cs
- ItemChangedEventArgs.cs
- DaylightTime.cs
- OracleTimeSpan.cs
- MessageBox.cs
- TypedElement.cs
- Helpers.cs
- JournalEntryStack.cs
- FastPropertyAccessor.cs
- PtsHelper.cs
- StringAnimationBase.cs
- Binding.cs
- SmiGettersStream.cs
- Part.cs
- ObjectDataProvider.cs
- DataGridViewTextBoxColumn.cs
- SlotInfo.cs
- ConfigurationManagerInternalFactory.cs
- WebException.cs
- BulletDecorator.cs
- ContentTextAutomationPeer.cs
- SequentialUshortCollection.cs
- WorkItem.cs
- DoubleLinkListEnumerator.cs
- WebServiceParameterData.cs
- SerialPinChanges.cs
- SQLBytesStorage.cs
- ColorConverter.cs
- DeadCharTextComposition.cs
- CodeSnippetStatement.cs
- ClientRuntimeConfig.cs
- NamespaceInfo.cs
- ConcurrentQueue.cs
- FixedSOMElement.cs
- DiffuseMaterial.cs
- DisplayNameAttribute.cs
- TreeNodeCollectionEditor.cs
- DataTemplateSelector.cs
- LinkButton.cs
- NameTable.cs
- ProfileBuildProvider.cs
- RootProfilePropertySettingsCollection.cs
- SecureEnvironment.cs
- XPathSelfQuery.cs
- PersonalizationState.cs
- MouseGestureConverter.cs
- ColorEditor.cs
- HttpStaticObjectsCollectionWrapper.cs
- RuleSetReference.cs
- ExtendedProperty.cs
- AgileSafeNativeMemoryHandle.cs
- ResponseBodyWriter.cs
- XhtmlBasicTextViewAdapter.cs
- ObjectParameter.cs
- Solver.cs
- ToolboxItemFilterAttribute.cs
- JsonEncodingStreamWrapper.cs
- Propagator.JoinPropagator.cs
- ReflectionUtil.cs
- TcpClientChannel.cs
- Char.cs
- QilCloneVisitor.cs
- HttpCachePolicy.cs
- RichTextBoxConstants.cs
- ProjectionCamera.cs
- ComponentRenameEvent.cs
- ApplicationProxyInternal.cs
- CharStorage.cs
- KeyInterop.cs
- BaseDataListPage.cs
- InvalidAsynchronousStateException.cs
- OciLobLocator.cs
- AuthenticationException.cs
- WorkflowMarkupSerializationException.cs
- Avt.cs
- AutomationElementCollection.cs
- XmlSchemaObjectTable.cs
- DataObjectMethodAttribute.cs
- DesignerSerializationManager.cs
- NativeMethods.cs
- ComProxy.cs
- CheckBoxStandardAdapter.cs
- MessageContractExporter.cs
- PartialCachingAttribute.cs
- input.cs
- DataGridClipboardHelper.cs
- RsaSecurityTokenAuthenticator.cs
- ForeignKeyConstraint.cs
- EpmContentDeSerializer.cs
- DataViewManager.cs
- ACL.cs
- WebContext.cs
- ResourceBinder.cs
- Row.cs
- OptionUsage.cs