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
- AssemblyCacheEntry.cs
- DataControlFieldCollection.cs
- DesignerFrame.cs
- PowerStatus.cs
- HttpApplicationFactory.cs
- AssemblyInfo.cs
- rsa.cs
- HostingEnvironment.cs
- DataGridColumnCollection.cs
- AssemblyInfo.cs
- ClientScriptManager.cs
- Freezable.cs
- FillRuleValidation.cs
- RightsManagementEncryptedStream.cs
- SerializationHelper.cs
- CustomErrorsSectionWrapper.cs
- StyleBamlTreeBuilder.cs
- Pair.cs
- FormViewPageEventArgs.cs
- ProfileProvider.cs
- PackageFilter.cs
- DashStyles.cs
- HtmlMeta.cs
- HttpCapabilitiesBase.cs
- EventRecord.cs
- SignatureGenerator.cs
- ExtensionDataObject.cs
- codemethodreferenceexpression.cs
- HtmlFormParameterWriter.cs
- DateTimeValueSerializerContext.cs
- RadioButton.cs
- FixedTextView.cs
- HtmlInputRadioButton.cs
- TextEditorSelection.cs
- DBPropSet.cs
- MenuItemAutomationPeer.cs
- AsyncDataRequest.cs
- ActivityBuilderXamlWriter.cs
- ContentPathSegment.cs
- DataAccessor.cs
- RequiredFieldValidator.cs
- SafeHandle.cs
- ConnectionConsumerAttribute.cs
- RangeValuePattern.cs
- FacetChecker.cs
- HttpStreamMessageEncoderFactory.cs
- CTreeGenerator.cs
- MexTcpBindingElement.cs
- ScrollBar.cs
- DateTimeParse.cs
- DataGridViewRowHeightInfoNeededEventArgs.cs
- BasicBrowserDialog.designer.cs
- HandledEventArgs.cs
- exports.cs
- ScrollBarRenderer.cs
- ErrorFormatter.cs
- GuidelineCollection.cs
- XmlSchemaResource.cs
- VectorAnimation.cs
- DSACryptoServiceProvider.cs
- MimeTypeAttribute.cs
- SqlProfileProvider.cs
- TableItemStyle.cs
- DataSysAttribute.cs
- ResourcesChangeInfo.cs
- ScriptServiceAttribute.cs
- NamedPipeTransportManager.cs
- CheckStoreFileValidityRequest.cs
- Byte.cs
- NodeFunctions.cs
- Brush.cs
- StrokeCollection.cs
- CollectionBase.cs
- PropertyIDSet.cs
- FontFamilyIdentifier.cs
- WindowInteropHelper.cs
- ellipse.cs
- DbInsertCommandTree.cs
- HtmlElementEventArgs.cs
- FunctionUpdateCommand.cs
- RowToParametersTransformer.cs
- ActivityUtilities.cs
- RulePatternOps.cs
- RewritingProcessor.cs
- FlowDocumentFormatter.cs
- TreeNode.cs
- NumericUpDownAccelerationCollection.cs
- WebBrowserPermission.cs
- DataRowCollection.cs
- DispatcherExceptionFilterEventArgs.cs
- WindowsListViewItemCheckBox.cs
- CompilerErrorCollection.cs
- XmlSchemaType.cs
- ExtensionMethods.cs
- TypefaceMap.cs
- ScriptHandlerFactory.cs
- ImageFormatConverter.cs
- ListViewCancelEventArgs.cs
- ExpressionVisitor.cs
- CurrentChangingEventManager.cs