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
- CodeTypeReferenceSerializer.cs
- COM2PictureConverter.cs
- Point.cs
- ObservableCollectionDefaultValueFactory.cs
- PropertyChangingEventArgs.cs
- StylusPlugInCollection.cs
- JumpPath.cs
- XmlSchemaSet.cs
- ExtentCqlBlock.cs
- EmptyEnumerable.cs
- Triplet.cs
- TextControlDesigner.cs
- CalendarAutoFormat.cs
- Trace.cs
- ToolStripScrollButton.cs
- SafeCoTaskMem.cs
- Viewport3DAutomationPeer.cs
- WebBaseEventKeyComparer.cs
- WebBrowser.cs
- QueryExpr.cs
- SchemaReference.cs
- _BaseOverlappedAsyncResult.cs
- RefExpr.cs
- Span.cs
- ValueExpressions.cs
- IISMapPath.cs
- FilterQuery.cs
- RestHandlerFactory.cs
- HtmlInputImage.cs
- QueueProcessor.cs
- DocumentViewerBase.cs
- HttpFileCollection.cs
- CompoundFileIOPermission.cs
- CustomAttributeBuilder.cs
- QilCloneVisitor.cs
- Control.cs
- Selection.cs
- AppLevelCompilationSectionCache.cs
- MatrixStack.cs
- ConnectionStringEditor.cs
- ClientTargetSection.cs
- SqlUtil.cs
- x509utils.cs
- ModelItemImpl.cs
- RMEnrollmentPage2.cs
- SystemWebCachingSectionGroup.cs
- RepeaterDesigner.cs
- ComponentRenameEvent.cs
- QilIterator.cs
- _ShellExpression.cs
- FixedTextPointer.cs
- PointKeyFrameCollection.cs
- ValueChangedEventManager.cs
- XmlLanguageConverter.cs
- IgnoreFileBuildProvider.cs
- SqlFunctionAttribute.cs
- IntegerFacetDescriptionElement.cs
- HitTestParameters.cs
- TransformerTypeCollection.cs
- KeyToListMap.cs
- DocumentPageHost.cs
- MetabaseServerConfig.cs
- SqlBooleanMismatchVisitor.cs
- StorageBasedPackageProperties.cs
- VirtualPath.cs
- WebConfigManager.cs
- CompilerError.cs
- MatrixAnimationUsingKeyFrames.cs
- DateTimeConverter2.cs
- Pair.cs
- UDPClient.cs
- COM2PropertyPageUITypeConverter.cs
- MasterPageCodeDomTreeGenerator.cs
- PseudoWebRequest.cs
- SequenceRangeCollection.cs
- SByteStorage.cs
- GenericIdentity.cs
- DataObjectCopyingEventArgs.cs
- HttpFileCollection.cs
- ToolBarTray.cs
- CapabilitiesSection.cs
- CodeSubDirectoriesCollection.cs
- EncryptedType.cs
- CqlErrorHelper.cs
- QueueProcessor.cs
- SerializationException.cs
- Trace.cs
- IndexExpression.cs
- PropertyNames.cs
- SparseMemoryStream.cs
- Transform.cs
- PropertyDescriptors.cs
- BamlBinaryWriter.cs
- Reference.cs
- MethodImplAttribute.cs
- CodeDomDecompiler.cs
- XamlInt32CollectionSerializer.cs
- XmlBaseWriter.cs
- UntypedNullExpression.cs
- AnnouncementEndpointElement.cs