Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / ndp / fx / src / xsp / System / Web / VirtualPathUtility.cs / 1 / VirtualPathUtility.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- /* * VirtualPathUtility class * * Copyright (c) 2004 Microsoft Corporation */ namespace System.Web { using System.Web.Util; using System.Security.Permissions; /* * Code to perform virtual path operations */ [AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)] public static class VirtualPathUtility { /* Discover virtual path type */ public static bool IsAbsolute(string virtualPath) { VirtualPath virtualPathObject = VirtualPath.Create(virtualPath); return !virtualPathObject.IsRelative && virtualPathObject.VirtualPathStringIfAvailable != null; } public static bool IsAppRelative(string virtualPath) { VirtualPath virtualPathObject = VirtualPath.Create(virtualPath); return virtualPathObject.VirtualPathStringIfAvailable == null; } /* Convert between virtual path types */ public static string ToAppRelative(string virtualPath) { VirtualPath virtualPathObject = VirtualPath.CreateNonRelative(virtualPath); return virtualPathObject.AppRelativeVirtualPathString; } public static string ToAppRelative(string virtualPath, string applicationPath) { VirtualPath virtualPathObject = VirtualPath.CreateNonRelative(virtualPath); // If it was already app relative, just return it if (virtualPathObject.AppRelativeVirtualPathStringIfAvailable != null) return virtualPathObject.AppRelativeVirtualPathStringIfAvailable; VirtualPath appVirtualPath = VirtualPath.CreateAbsoluteTrailingSlash(applicationPath); return UrlPath.MakeVirtualPathAppRelative(virtualPathObject.VirtualPathString, appVirtualPath.VirtualPathString, true /*nullIfNotInApp*/); } public static string ToAbsolute(string virtualPath) { VirtualPath virtualPathObject = VirtualPath.CreateNonRelative(virtualPath); return virtualPathObject.VirtualPathString; } public static string ToAbsolute(string virtualPath, string applicationPath) { VirtualPath virtualPathObject = VirtualPath.CreateNonRelative(virtualPath); // If it was already absolute, just return it if (virtualPathObject.VirtualPathStringIfAvailable != null) return virtualPathObject.VirtualPathStringIfAvailable; VirtualPath appVirtualPath = VirtualPath.CreateAbsoluteTrailingSlash(applicationPath); return UrlPath.MakeVirtualPathAppAbsolute(virtualPathObject.AppRelativeVirtualPathString, appVirtualPath.VirtualPathString); } /* Get pieces of virtual path */ public static string GetFileName(string virtualPath) { VirtualPath virtualPathObject = VirtualPath.CreateNonRelative(virtualPath); return virtualPathObject.FileName; } public static string GetDirectory(string virtualPath) { VirtualPath virtualPathObject = VirtualPath.CreateNonRelative(virtualPath); virtualPathObject = virtualPathObject.Parent; if (virtualPathObject == null) return null; return virtualPathObject.VirtualPathStringWhicheverAvailable; } public static string GetExtension(string virtualPath) { VirtualPath virtualPathObject = VirtualPath.Create(virtualPath); return virtualPathObject.Extension; } /* Canonicalize virtual paths */ public static string AppendTrailingSlash(string virtualPath) { return UrlPath.AppendSlashToPathIfNeeded(virtualPath); } public static string RemoveTrailingSlash(string virtualPath) { return UrlPath.RemoveSlashFromPathIfNeeded(virtualPath); } // Removing Reduce per DevDiv 43118 #if OLD public static string Reduce(string virtualPath) { VirtualPath virtualPathObject = VirtualPath.CreateNonRelative(virtualPath); return virtualPathObject.VirtualPathString; } #endif /* Work with multiple virtual paths */ public static string Combine(string basePath, string relativePath) { VirtualPath virtualPath = VirtualPath.Combine(VirtualPath.CreateNonRelative(basePath), VirtualPath.Create(relativePath)); return virtualPath.VirtualPathStringWhicheverAvailable; } public static string MakeRelative(string fromPath, string toPath) { return UrlPath.MakeRelative(fromPath, toPath); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- /* * VirtualPathUtility class * * Copyright (c) 2004 Microsoft Corporation */ namespace System.Web { using System.Web.Util; using System.Security.Permissions; /* * Code to perform virtual path operations */ [AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)] public static class VirtualPathUtility { /* Discover virtual path type */ public static bool IsAbsolute(string virtualPath) { VirtualPath virtualPathObject = VirtualPath.Create(virtualPath); return !virtualPathObject.IsRelative && virtualPathObject.VirtualPathStringIfAvailable != null; } public static bool IsAppRelative(string virtualPath) { VirtualPath virtualPathObject = VirtualPath.Create(virtualPath); return virtualPathObject.VirtualPathStringIfAvailable == null; } /* Convert between virtual path types */ public static string ToAppRelative(string virtualPath) { VirtualPath virtualPathObject = VirtualPath.CreateNonRelative(virtualPath); return virtualPathObject.AppRelativeVirtualPathString; } public static string ToAppRelative(string virtualPath, string applicationPath) { VirtualPath virtualPathObject = VirtualPath.CreateNonRelative(virtualPath); // If it was already app relative, just return it if (virtualPathObject.AppRelativeVirtualPathStringIfAvailable != null) return virtualPathObject.AppRelativeVirtualPathStringIfAvailable; VirtualPath appVirtualPath = VirtualPath.CreateAbsoluteTrailingSlash(applicationPath); return UrlPath.MakeVirtualPathAppRelative(virtualPathObject.VirtualPathString, appVirtualPath.VirtualPathString, true /*nullIfNotInApp*/); } public static string ToAbsolute(string virtualPath) { VirtualPath virtualPathObject = VirtualPath.CreateNonRelative(virtualPath); return virtualPathObject.VirtualPathString; } public static string ToAbsolute(string virtualPath, string applicationPath) { VirtualPath virtualPathObject = VirtualPath.CreateNonRelative(virtualPath); // If it was already absolute, just return it if (virtualPathObject.VirtualPathStringIfAvailable != null) return virtualPathObject.VirtualPathStringIfAvailable; VirtualPath appVirtualPath = VirtualPath.CreateAbsoluteTrailingSlash(applicationPath); return UrlPath.MakeVirtualPathAppAbsolute(virtualPathObject.AppRelativeVirtualPathString, appVirtualPath.VirtualPathString); } /* Get pieces of virtual path */ public static string GetFileName(string virtualPath) { VirtualPath virtualPathObject = VirtualPath.CreateNonRelative(virtualPath); return virtualPathObject.FileName; } public static string GetDirectory(string virtualPath) { VirtualPath virtualPathObject = VirtualPath.CreateNonRelative(virtualPath); virtualPathObject = virtualPathObject.Parent; if (virtualPathObject == null) return null; return virtualPathObject.VirtualPathStringWhicheverAvailable; } public static string GetExtension(string virtualPath) { VirtualPath virtualPathObject = VirtualPath.Create(virtualPath); return virtualPathObject.Extension; } /* Canonicalize virtual paths */ public static string AppendTrailingSlash(string virtualPath) { return UrlPath.AppendSlashToPathIfNeeded(virtualPath); } public static string RemoveTrailingSlash(string virtualPath) { return UrlPath.RemoveSlashFromPathIfNeeded(virtualPath); } // Removing Reduce per DevDiv 43118 #if OLD public static string Reduce(string virtualPath) { VirtualPath virtualPathObject = VirtualPath.CreateNonRelative(virtualPath); return virtualPathObject.VirtualPathString; } #endif /* Work with multiple virtual paths */ public static string Combine(string basePath, string relativePath) { VirtualPath virtualPath = VirtualPath.Combine(VirtualPath.CreateNonRelative(basePath), VirtualPath.Create(relativePath)); return virtualPath.VirtualPathStringWhicheverAvailable; } public static string MakeRelative(string fromPath, string toPath) { return UrlPath.MakeRelative(fromPath, toPath); } } } // 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
- ToolTip.cs
- NativeMethods.cs
- TemplateLookupAction.cs
- WindowInteropHelper.cs
- AttributeData.cs
- DesignOnlyAttribute.cs
- IndexerNameAttribute.cs
- RuntimeVariablesExpression.cs
- ImageList.cs
- QilName.cs
- ConfigurationManagerHelper.cs
- SoapEnvelopeProcessingElement.cs
- JsonReaderDelegator.cs
- LeftCellWrapper.cs
- MultiDataTrigger.cs
- RIPEMD160.cs
- NavigationHelper.cs
- BindValidationContext.cs
- BitmapImage.cs
- XmlPropertyBag.cs
- SchemaTypeEmitter.cs
- DispatcherProcessingDisabled.cs
- InvokeHandlers.cs
- NativeMethods.cs
- Utils.cs
- AppSettingsExpressionBuilder.cs
- PageContentAsyncResult.cs
- ProxyHwnd.cs
- InputMethod.cs
- KnownTypesProvider.cs
- AccessDataSourceView.cs
- ZipIOLocalFileDataDescriptor.cs
- Int16AnimationBase.cs
- FontStyleConverter.cs
- TargetException.cs
- InvokePatternIdentifiers.cs
- LiteralControl.cs
- XmlSchemaExternal.cs
- WhiteSpaceTrimStringConverter.cs
- ScrollPatternIdentifiers.cs
- DateTimeOffsetStorage.cs
- ConnectionPointGlyph.cs
- SuppressMergeCheckAttribute.cs
- _SslStream.cs
- DeflateStream.cs
- GridViewRow.cs
- ApplicationSettingsBase.cs
- IBuiltInEvidence.cs
- StrokeCollection.cs
- ContentPresenter.cs
- WmlSelectionListAdapter.cs
- TreeNodeCollection.cs
- KnownTypesHelper.cs
- XmlSchemaSimpleTypeRestriction.cs
- LicenseProviderAttribute.cs
- MethodBuilder.cs
- EncoderParameter.cs
- EncodingNLS.cs
- EntityViewGenerationAttribute.cs
- Literal.cs
- Send.cs
- LocalizationCodeDomSerializer.cs
- VisualStyleElement.cs
- DataTableReader.cs
- DocumentsTrace.cs
- PropertyTabAttribute.cs
- TdsParserStaticMethods.cs
- PagePropertiesChangingEventArgs.cs
- ProxyAttribute.cs
- MemberInfoSerializationHolder.cs
- BamlLocalizabilityResolver.cs
- Button.cs
- InvalidateEvent.cs
- CultureMapper.cs
- PropertyValueChangedEvent.cs
- MouseActionValueSerializer.cs
- DataRecordInternal.cs
- ProcessManager.cs
- RunInstallerAttribute.cs
- PrintEvent.cs
- StylusDevice.cs
- FixedSOMTable.cs
- ConnectionManagementElement.cs
- PropertyFilterAttribute.cs
- DesignerRegionCollection.cs
- PreservationFileWriter.cs
- HierarchicalDataBoundControlAdapter.cs
- EqualityArray.cs
- ListView.cs
- ACL.cs
- SweepDirectionValidation.cs
- TextEditor.cs
- StorageModelBuildProvider.cs
- SortKey.cs
- Win32NamedPipes.cs
- ButtonBaseAdapter.cs
- Validator.cs
- InputEventArgs.cs
- UIPropertyMetadata.cs
- FileFormatException.cs