当前位置: 首页>>代码示例>>C#>>正文


C# VirtualPath.FileExists方法代码示例

本文整理汇总了C#中VirtualPath.FileExists方法的典型用法代码示例。如果您正苦于以下问题:C# VirtualPath.FileExists方法的具体用法?C# VirtualPath.FileExists怎么用?C# VirtualPath.FileExists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在VirtualPath的用法示例。


在下文中一共展示了VirtualPath.FileExists方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CheckVirtualFileExists

 internal static void CheckVirtualFileExists(VirtualPath virtualPath) {
     if (!virtualPath.FileExists()) {
         throw new HttpException(
             HttpStatus.NotFound,
             SR.GetString(SR.FileName_does_not_exist,
                 virtualPath.VirtualPathString));
     }
 }
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:8,代码来源:Util.cs

示例2: VirtualFileExistsWithAssert

    internal static bool VirtualFileExistsWithAssert(VirtualPath virtualPath) {
        string physicalDir = virtualPath.MapPathInternal();

        if (physicalDir != null) {
            (InternalSecurityPermissions.PathDiscovery(physicalDir)).Assert();
        }

        return virtualPath.FileExists();
    }
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:9,代码来源:Util.cs

示例3: GetVPathBuildResultInternal

        private BuildResult GetVPathBuildResultInternal(VirtualPath virtualPath, bool noBuild, bool allowCrossApp, bool allowBuildInPrecompile, bool throwIfNotFound, bool ensureIsUpToDate = true) {

            Debug.Trace("BuildManager", "GetBuildResult(" + virtualPath + ")");

            // This should never be called while building top level files (VSWhidbey 480256)
            if (_compilationStage == CompilationStage.TopLevelFiles) {
                throw new HttpException(SR.GetString(SR.Too_early_for_webfile, virtualPath));
            }

            // Make sure the path is not relative
            Debug.Assert(!virtualPath.IsRelative);

            // Try the cache first before getting the mutex
            BuildResult result = GetVPathBuildResultFromCacheInternal(virtualPath, ensureIsUpToDate);
            if (result != null)
                return result;

            // If we were only checking the cache and it wasn't there, return null.
            if (noBuild)
                return null;

            // Check if it's trying to go cross app, or points to a special directory.
            // It's important to do this before checkin existence, to avoid revealing information
            // about other apps (VSWhidbey 442632)
            ValidateVirtualPathInternal(virtualPath, allowCrossApp, false /*codeFile*/);

            if (throwIfNotFound) {
                // Before grabbing the lock, make sure the file at least exists (ASURT 46465)
                Util.CheckVirtualFileExists(virtualPath);
            }
            else if (!virtualPath.FileExists()) {
                return null;
            }

            // If this is a precompiled app, complain if we couldn't find it in the cache
            if (IsNonUpdatablePrecompiledApp && !allowBuildInPrecompile) {
                throw new HttpException(
                    SR.GetString(SR.Cant_update_precompiled_app, virtualPath));
            }

            bool gotLock = false;

            try {
                // Grab the compilation mutex
                CompilationLock.GetLock(ref gotLock);

                // Check the cache a second time after getting the mutex
                result = GetVPathBuildResultFromCacheInternal(virtualPath, ensureIsUpToDate);
                if (result != null)
                    return result;

                // Get the circular reference checker (create it if needed)
                VirtualPathSet circularReferenceChecker;
                circularReferenceChecker = CallContext.GetData(CircularReferenceCheckerSlotName)
                    as VirtualPathSet;
                if (circularReferenceChecker == null) {
                    circularReferenceChecker = new VirtualPathSet();

                    // Create it and save it in the CallContext
                    CallContext.SetData(CircularReferenceCheckerSlotName, circularReferenceChecker);
                }

                // If a circular reference is detected, throw an error
                if (circularReferenceChecker.Contains(virtualPath)) {
                    throw new HttpException(
                        SR.GetString(SR.Circular_include));
                }

                // Add the current virtualPath to the circular reference checker
                circularReferenceChecker.Add(virtualPath);

                try {
                    // 
                    EnsureTopLevelFilesCompiled();
                    result = CompileWebFile(virtualPath);
                }
                finally {
                    // Remove the current virtualPath from the circular reference checker
                    Debug.Assert(circularReferenceChecker.Contains(virtualPath));
                    circularReferenceChecker.Remove(virtualPath);
                }
            }
            finally {
                // Always release the mutex if we had taken it
                if (gotLock) {
                    CompilationLock.ReleaseLock();
                }
            }

            return result;
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:91,代码来源:BuildManager.cs


注:本文中的VirtualPath.FileExists方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。