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
- ConnectionPoolManager.cs
- ApplicationHost.cs
- OdbcEnvironmentHandle.cs
- XmlSchemaType.cs
- DockPanel.cs
- ColorConverter.cs
- WebBrowserNavigatingEventHandler.cs
- PrintingPermission.cs
- OutputCacheSettingsSection.cs
- JoinTreeSlot.cs
- ListViewItemCollectionEditor.cs
- EraserBehavior.cs
- ListSortDescriptionCollection.cs
- InitializerFacet.cs
- SerialStream.cs
- EventMappingSettingsCollection.cs
- HtmlInputHidden.cs
- ConnectionInterfaceCollection.cs
- EntityKey.cs
- RotateTransform.cs
- HGlobalSafeHandle.cs
- WhitespaceRuleLookup.cs
- PersonalizationEntry.cs
- FamilyTypefaceCollection.cs
- TraceSection.cs
- TemplateBindingExpression.cs
- PackagePart.cs
- CommandHelpers.cs
- WebServiceErrorEvent.cs
- TypeBinaryExpression.cs
- ObjectDataSourceDisposingEventArgs.cs
- EntityContainerEntitySetDefiningQuery.cs
- BitmapMetadata.cs
- RadialGradientBrush.cs
- WebBrowserHelper.cs
- ConfigurationValidatorAttribute.cs
- DataQuery.cs
- GridViewSelectEventArgs.cs
- XmlSchemaRedefine.cs
- EventData.cs
- SchemaElementLookUpTable.cs
- SamlAuthenticationStatement.cs
- SqlDependency.cs
- Screen.cs
- ICspAsymmetricAlgorithm.cs
- StorageScalarPropertyMapping.cs
- FixedSOMFixedBlock.cs
- Icon.cs
- PageRequestManager.cs
- InputProcessorProfiles.cs
- WebMessageEncoderFactory.cs
- IsolatedStorage.cs
- FormsAuthenticationEventArgs.cs
- SlotInfo.cs
- TcpServerChannel.cs
- SqlCrossApplyToCrossJoin.cs
- ApplicationFileParser.cs
- TextTreeInsertElementUndoUnit.cs
- ChangePassword.cs
- SoapHttpTransportImporter.cs
- ToolStripRenderer.cs
- TreeNodeEventArgs.cs
- DataGridViewTextBoxEditingControl.cs
- LateBoundBitmapDecoder.cs
- ManipulationDeltaEventArgs.cs
- UrlAuthFailedErrorFormatter.cs
- EntryIndex.cs
- AppSettingsExpressionEditor.cs
- PathSegment.cs
- ByteAnimationUsingKeyFrames.cs
- Compiler.cs
- SecurityRuntime.cs
- RepeatButton.cs
- QueryResults.cs
- Options.cs
- Int64AnimationBase.cs
- NumberSubstitution.cs
- OutOfMemoryException.cs
- DataSetUtil.cs
- Codec.cs
- Encoding.cs
- Shape.cs
- Size3DValueSerializer.cs
- HttpRawResponse.cs
- Simplifier.cs
- basenumberconverter.cs
- EventPrivateKey.cs
- XmlEncApr2001.cs
- DefaultCommandConverter.cs
- NonParentingControl.cs
- DataQuery.cs
- QilValidationVisitor.cs
- PreProcessInputEventArgs.cs
- ResourceSet.cs
- ErrorFormatterPage.cs
- JoinElimination.cs
- ColumnMapCopier.cs
- DynamicActionMessageFilter.cs
- EFColumnProvider.cs
- WaitHandleCannotBeOpenedException.cs