本文整理汇总了C#中VirtualPath.MapPathInternal方法的典型用法代码示例。如果您正苦于以下问题:C# VirtualPath.MapPathInternal方法的具体用法?C# VirtualPath.MapPathInternal怎么用?C# VirtualPath.MapPathInternal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VirtualPath
的用法示例。
在下文中一共展示了VirtualPath.MapPathInternal方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetDirectoryHash
internal static string GetDirectoryHash(VirtualPath virtualDir) {
HashCodeCombiner hashCodeCombiner = new HashCodeCombiner();
hashCodeCombiner.AddDirectory(virtualDir.MapPathInternal());
return hashCodeCombiner.CombinedHashString;
}
示例2: OpenFileAndGetDependency
///
/// Open a stream from either a virtual or physical path, and if possible get a CacheDependency
/// for the resulting Stream.
///
internal Stream OpenFileAndGetDependency(VirtualPath virtualPath, string physicalPath, out CacheDependency dependency) {
// Only one of the paths should be non-null
Debug.Assert((virtualPath == null) != (physicalPath == null));
// If we got a virtual path, and we're using the default VPP, call MapPath
if (physicalPath == null && HostingEnvironment.UsingMapPathBasedVirtualPathProvider) {
physicalPath = virtualPath.MapPathInternal(TemplateControlVirtualDirectory,
true /*allowCrossAppMapping*/);
}
Stream stream;
if (physicalPath != null) {
// Security check
HttpRuntime.CheckFilePermission(physicalPath);
// Work directly with the physical file, bypassing the VPP
stream = new FileStream(physicalPath, FileMode.Open, FileAccess.Read, FileShare.Read);
dependency = new CacheDependency(0, physicalPath);
}
else {
// It's non file system based, so go though the VirtualPathProvider
stream = virtualPath.OpenFile();
dependency = VirtualPathProvider.GetCacheDependency(virtualPath);
}
return stream;
}
示例3: VirtualDirectoryExistsWithAssert
private static bool VirtualDirectoryExistsWithAssert(VirtualPath virtualDir) {
try {
String physicalDir = virtualDir.MapPathInternal();
if (physicalDir != null) {
new FileIOPermission(FileIOPermissionAccess.Read, physicalDir).Assert();
}
return virtualDir.DirectoryExists();
}
catch {
return false;
}
}
示例4: VirtualFileExistsWithAssert
internal static bool VirtualFileExistsWithAssert(VirtualPath virtualPath) {
string physicalDir = virtualPath.MapPathInternal();
if (physicalDir != null) {
(InternalSecurityPermissions.PathDiscovery(physicalDir)).Assert();
}
return virtualPath.FileExists();
}
示例5: MapPathBasedVirtualPathEnumerator
internal MapPathBasedVirtualPathEnumerator(VirtualPath virtualPath, RequestedEntryType requestedEntryType) {
if (virtualPath.IsRelative) {
throw new ArgumentException(SR.GetString(SR.Invalid_app_VirtualPath), "virtualPath");
}
_virtualPath = virtualPath;
_requestedEntryType = requestedEntryType;
string physicalPath;
if (!ServerConfig.UseServerConfig) {
// Use the hosting environment to map the virtual path
physicalPath = _virtualPath.MapPathInternal();
}
else {
IServerConfig serverConfig = ServerConfig.GetInstance();
_serverConfig2 = serverConfig as IServerConfig2;
// Use serverConfig to map the virtual path
physicalPath = serverConfig.MapPath(null, _virtualPath);
if (_requestedEntryType != RequestedEntryType.Files) {
// For MetabaseServerConfig, get the subdirs that are not in the application, and add them to the exclude list.
if (_serverConfig2 == null) {
string [] virtualSubdirsNotInApp = serverConfig.GetVirtualSubdirs(_virtualPath, false);
if (virtualSubdirsNotInApp != null) {
_exclude = new Hashtable(StringComparer.OrdinalIgnoreCase);
foreach (string subdir in virtualSubdirsNotInApp) {
_exclude[subdir] = subdir;
}
}
}
// Get subdirs that are virtual directories, and record their physical mappings.
// Ignore the virtualPaths if we only need files, since it only contains directories
string [] virtualSubdirsInApp = serverConfig.GetVirtualSubdirs(_virtualPath, true);
if (virtualSubdirsInApp != null) {
_virtualPaths = new Hashtable(StringComparer.OrdinalIgnoreCase);
foreach (string subdir in virtualSubdirsInApp) {
VirtualPath subpath = _virtualPath.SimpleCombineWithDir(subdir);
string subPhysicalPath = serverConfig.MapPath(null, subpath);
if (FileUtil.DirectoryExists(subPhysicalPath)) {
_virtualPaths[subdir] = new MapPathBasedVirtualDirectory(subpath.VirtualPathString);
}
}
// Create enumerator for the virtual paths
_virtualEnumerator = _virtualPaths.Values.GetEnumerator();
}
}
}
// Create an enumerator for the physical files and directories at this path
_fileEnumerator = FileEnumerator.Create(physicalPath);
// Reset the enumerator. Note that we don't support the Reset method.
_useFileEnumerator = false;
}
示例6: ComputeSourceDependenciesHashCode
internal override string ComputeSourceDependenciesHashCode(VirtualPath virtualPath) {
// If no virtual path was passed in, use the one from the BuildResult
if (virtualPath == null)
virtualPath = VirtualPath;
// We don't want to use the default ComputeSourceDependenciesHashCode imnplementation,
// as it would use all files in the resources dir to calculate the hash. Instead,
// we only want the hash the be based on the culture neutral resources, so that
// changes to culture specific files don't cause a rebuild of the main res assembly
HashCodeCombiner hashCodeCombiner = new HashCodeCombiner();
hashCodeCombiner.AddResourcesDirectory(virtualPath.MapPathInternal());
return hashCodeCombiner.CombinedHashString;
}