本文整理汇总了C#中VirtualPath.MapPath方法的典型用法代码示例。如果您正苦于以下问题:C# VirtualPath.MapPath方法的具体用法?C# VirtualPath.MapPath怎么用?C# VirtualPath.MapPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VirtualPath
的用法示例。
在下文中一共展示了VirtualPath.MapPath方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetCodeDirectoryAssembly
internal static Assembly GetCodeDirectoryAssembly(VirtualPath virtualDir,
CodeDirectoryType dirType, string assemblyName,
StringSet excludedSubdirectories, bool isDirectoryAllowed) {
string physicalDir = virtualDir.MapPath();
if (!isDirectoryAllowed) {
// The directory should never exist in a precompiled app
if (Directory.Exists(physicalDir)) {
throw new HttpException(SR.GetString(SR.Bar_dir_in_precompiled_app, virtualDir));
}
}
bool supportLocalization = IsResourceCodeDirectoryType(dirType);
// Determine the proper cache key based on the type of directory we're processing
string cacheKey = assemblyName;
// Try the cache first
BuildResult result = BuildManager.GetBuildResultFromCache(cacheKey);
Assembly resultAssembly = null;
// If it's cached, just return it
if (result != null) {
// It should always be a BuildResultCompiledAssembly, though if there is
// a VirtualPathProvider doing very bad things, it may not (VSWhidbey 341701)
Debug.Assert(result is BuildResultCompiledAssembly);
if (result is BuildResultCompiledAssembly) {
// If it's the main code assembly, keep track of it so we can later call
// the AppInitialize method
if (result is BuildResultMainCodeAssembly) {
Debug.Assert(dirType == CodeDirectoryType.MainCode);
Debug.Assert(_mainCodeBuildResult == null);
_mainCodeBuildResult = (BuildResultMainCodeAssembly) result;
}
resultAssembly = ((BuildResultCompiledAssembly)result).ResultAssembly;
if (!supportLocalization)
return resultAssembly;
// We found a preserved resource assembly. However, we may not be done,
// as the culture specific files may have changed.
// But don't make any further checks if the directory is not allowed (precomp secenario).
// In that case, we should always return the assembly (VSWhidbey 533498)
if (!isDirectoryAllowed)
return resultAssembly;
BuildResultResourceAssembly buildResultResAssembly = (BuildResultResourceAssembly)result;
string newResourcesDependenciesHash = HashCodeCombiner.GetDirectoryHash(virtualDir);
// If the resources hash (which includes satellites) is up to date, we're done
if (newResourcesDependenciesHash == buildResultResAssembly.ResourcesDependenciesHash)
return resultAssembly;
}
}
// If app was precompiled, don't attempt compilation
if (!isDirectoryAllowed)
return null;
// Check whether the virtual dir is mapped to a different application,
// which we don't support (VSWhidbey 218603). But don't do this for LocalResource (VSWhidbey 237935)
if (dirType != CodeDirectoryType.LocalResources && !StringUtil.StringStartsWithIgnoreCase(physicalDir, HttpRuntime.AppDomainAppPathInternal)) {
throw new HttpException(SR.GetString(SR.Virtual_codedir, virtualDir.VirtualPathString));
}
// If the directory doesn't exist, we may be done
if (!Directory.Exists(physicalDir)) {
// We're definitely done if it's not the main code dir
if (dirType != CodeDirectoryType.MainCode)
return null;
// If it is the main code dir, we're only done is there is no profile to compile
// since the profice gets built as part of the main assembly.
if (!ProfileBuildProvider.HasCompilableProfile)
return null;
}
// Otherwise, compile it
BuildManager.ReportDirectoryCompilationProgress(virtualDir);
DateTime utcStart = DateTime.UtcNow;
CodeDirectoryCompiler cdc = new CodeDirectoryCompiler(virtualDir,
dirType, excludedSubdirectories);
string outputAssemblyName = null;
if (resultAssembly != null) {
// If resultAssembly is not null, we are in the case where we just need to build
// the localized resx file in a resources dir (local or global)
//.........这里部分代码省略.........