Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / fx / src / CompMod / System / ComponentModel / SyntaxCheck.cs / 1 / SyntaxCheck.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.ComponentModel { using System; using System.Diagnostics; using System.IO; using System.Runtime.InteropServices; using System.Security.Permissions; ////// /// SyntaxCheck /// Helper class to check for path and machine name syntax. /// [HostProtection(SharedState = true)] public static class SyntaxCheck { ////// Checks the syntax of the machine name (no "\" anywhere in it). /// ///public static bool CheckMachineName(string value) { if (value == null) return false; value = value.Trim(); if (value.Equals(String.Empty)) return false; // Machine names shouldn't contain any "\" return (value.IndexOf('\\') == -1); } /// /// Checks the syntax of the path (must start with "\\"). /// ///public static bool CheckPath(string value) { if (value == null) return false; value = value.Trim(); if (value.Equals(String.Empty)) return false; // Path names should start with "\\" return value.StartsWith("\\\\"); } /// /// Checks the syntax of the path (must start with "\" or drive letter "C:"). /// NOTE: These denote a file or directory path!! /// /// ///public static bool CheckRootedPath(string value) { if (value == null) return false; value = value.Trim(); if (value.Equals(String.Empty)) return false; // Is it rooted? return Path.IsPathRooted(value); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ // // Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.ComponentModel { using System; using System.Diagnostics; using System.IO; using System.Runtime.InteropServices; using System.Security.Permissions; ////// /// SyntaxCheck /// Helper class to check for path and machine name syntax. /// [HostProtection(SharedState = true)] public static class SyntaxCheck { ////// Checks the syntax of the machine name (no "\" anywhere in it). /// ///public static bool CheckMachineName(string value) { if (value == null) return false; value = value.Trim(); if (value.Equals(String.Empty)) return false; // Machine names shouldn't contain any "\" return (value.IndexOf('\\') == -1); } /// /// Checks the syntax of the path (must start with "\\"). /// ///public static bool CheckPath(string value) { if (value == null) return false; value = value.Trim(); if (value.Equals(String.Empty)) return false; // Path names should start with "\\" return value.StartsWith("\\\\"); } /// /// Checks the syntax of the path (must start with "\" or drive letter "C:"). /// NOTE: These denote a file or directory path!! /// /// ///public static bool CheckRootedPath(string value) { if (value == null) return false; value = value.Trim(); if (value.Equals(String.Empty)) return false; // Is it rooted? return Path.IsPathRooted(value); } } } // 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
- ErrorHandler.cs
- GuidTagList.cs
- LazyInitializer.cs
- ObjectSecurity.cs
- SqlInfoMessageEvent.cs
- BaseProcessor.cs
- ServiceHostFactory.cs
- CacheSection.cs
- SqlDependencyListener.cs
- BaseServiceProvider.cs
- EnumMember.cs
- InteropEnvironment.cs
- IIS7WorkerRequest.cs
- CompilerState.cs
- ProfileInfo.cs
- Material.cs
- DataBindingExpressionBuilder.cs
- ListViewDeleteEventArgs.cs
- DesignSurfaceServiceContainer.cs
- NavigationCommands.cs
- IMembershipProvider.cs
- ModelVisual3D.cs
- Point3DKeyFrameCollection.cs
- PropertyConverter.cs
- FormViewModeEventArgs.cs
- followingsibling.cs
- EditCommandColumn.cs
- Nullable.cs
- ButtonChrome.cs
- DefaultParameterValueAttribute.cs
- UndirectedGraph.cs
- SiteMapNode.cs
- WebControlAdapter.cs
- SR.cs
- TypeUtils.cs
- PathFigureCollectionValueSerializer.cs
- ToolStripRenderEventArgs.cs
- PersonalizableTypeEntry.cs
- OracleConnectionFactory.cs
- GetTokenRequest.cs
- XmlNodeChangedEventManager.cs
- ThreadPool.cs
- FamilyTypeface.cs
- SharedPersonalizationStateInfo.cs
- SelectorItemAutomationPeer.cs
- XmlSchemaException.cs
- RectConverter.cs
- XmlSerializationReader.cs
- StylusPlugin.cs
- CqlWriter.cs
- DebugHandleTracker.cs
- Helpers.cs
- WebServiceHost.cs
- CellConstantDomain.cs
- StaticResourceExtension.cs
- SupportingTokenDuplexChannel.cs
- ArrayElementGridEntry.cs
- DesignerEventService.cs
- SymmetricSecurityProtocol.cs
- WsdlInspector.cs
- TextCompositionEventArgs.cs
- WebPartsPersonalization.cs
- COM2FontConverter.cs
- PageAsyncTaskManager.cs
- SurrogateSelector.cs
- ECDsa.cs
- BreakSafeBase.cs
- TextCollapsingProperties.cs
- SymmetricKeyWrap.cs
- WebBrowserUriTypeConverter.cs
- CommandDesigner.cs
- ExpressionEditorAttribute.cs
- RegistryKey.cs
- SQLDateTimeStorage.cs
- DispatcherProcessingDisabled.cs
- SqlCachedBuffer.cs
- GetLedgerEntryForRecipientRequest.cs
- WindowsGraphicsCacheManager.cs
- Compress.cs
- MsmqInputChannelListenerBase.cs
- TCPListener.cs
- DoubleCollection.cs
- Duration.cs
- TypeGeneratedEventArgs.cs
- PathFigureCollection.cs
- SyndicationItemFormatter.cs
- DataSourceXmlSubItemAttribute.cs
- TableAutomationPeer.cs
- ReflectionHelper.cs
- SafeNativeMethods.cs
- shaper.cs
- EventProviderWriter.cs
- SchemaRegistration.cs
- PrintEvent.cs
- ImageBrush.cs
- CommandValueSerializer.cs
- CompressedStack.cs
- XmlSerializerSection.cs
- HttpCachePolicy.cs
- SqlAggregateChecker.cs