Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / CompMod / System / ComponentModel / SyntaxCheck.cs / 1305376 / 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
- FilteredSchemaElementLookUpTable.cs
- HostingEnvironmentWrapper.cs
- Stroke.cs
- QilPatternFactory.cs
- TdsParserStaticMethods.cs
- TypeDescriptionProviderAttribute.cs
- HtmlTable.cs
- RootDesignerSerializerAttribute.cs
- XmlSerializerFormatAttribute.cs
- DurationConverter.cs
- LazyInitializer.cs
- ZipIOZip64EndOfCentralDirectoryBlock.cs
- PermissionSetTriple.cs
- CompoundFileReference.cs
- FilterEventArgs.cs
- AssemblyBuilder.cs
- TextEditorThreadLocalStore.cs
- SerializerDescriptor.cs
- SmtpMail.cs
- Viewport2DVisual3D.cs
- BreakRecordTable.cs
- VisualStateGroup.cs
- SqlError.cs
- HtmlImage.cs
- WebServiceData.cs
- MemberInfoSerializationHolder.cs
- ProfileService.cs
- ProviderUtil.cs
- PreviousTrackingServiceAttribute.cs
- OleDbDataReader.cs
- TypeSchema.cs
- EventQueueState.cs
- EastAsianLunisolarCalendar.cs
- StylusPlugInCollection.cs
- WorkflowDefinitionDispenser.cs
- OperationCanceledException.cs
- PathSegment.cs
- CharKeyFrameCollection.cs
- FactoryGenerator.cs
- OuterGlowBitmapEffect.cs
- SendKeys.cs
- MarkupProperty.cs
- RtfToXamlLexer.cs
- BinaryMethodMessage.cs
- OverflowException.cs
- CompilationRelaxations.cs
- SettingsBindableAttribute.cs
- SymmetricAlgorithm.cs
- SqlConnectionPoolProviderInfo.cs
- ClientScriptManager.cs
- SchemaEntity.cs
- NotSupportedException.cs
- DefaultHttpHandler.cs
- SqlCacheDependencyDatabaseCollection.cs
- XmlSchemaExternal.cs
- MetroSerializationManager.cs
- PropertyDescriptorGridEntry.cs
- StrongName.cs
- FamilyTypefaceCollection.cs
- PolicyVersionConverter.cs
- ColumnPropertiesGroup.cs
- PageAsyncTaskManager.cs
- TextSpan.cs
- StyleCollection.cs
- Object.cs
- IOThreadScheduler.cs
- QilTypeChecker.cs
- NavigationHelper.cs
- CursorEditor.cs
- JpegBitmapEncoder.cs
- TraceData.cs
- _SingleItemRequestCache.cs
- PeerNameRecord.cs
- CalendarButtonAutomationPeer.cs
- ThrowHelper.cs
- _AuthenticationState.cs
- WebPartConnectionsDisconnectVerb.cs
- HashMembershipCondition.cs
- TraceListener.cs
- SHA384Cng.cs
- JapaneseCalendar.cs
- XmlSignatureProperties.cs
- DesignTimeHTMLTextWriter.cs
- MetadataUtilsSmi.cs
- EntitySet.cs
- MessageContractAttribute.cs
- PopupControlService.cs
- HttpBrowserCapabilitiesBase.cs
- EntitySet.cs
- ApplicationBuildProvider.cs
- ToolStripScrollButton.cs
- Oid.cs
- TreeNode.cs
- SvcMapFileSerializer.cs
- HeaderPanel.cs
- QilName.cs
- DotAtomReader.cs
- SettingsBase.cs
- ErrorStyle.cs
- MenuAdapter.cs