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


C# VirtualPath.SimpleCombineWithDir方法代码示例

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


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

示例1: EnsureFirstTimeDirectoryInit

        private void EnsureFirstTimeDirectoryInit(VirtualPath virtualDir) {

            // Don't process local resources when precompiling for updatable deployment.
            // Instead, we deploy the App_LocalResources folder as is.
            if (PrecompilingForUpdatableDeployment)
                return;

            if (virtualDir == null)
                return;

            // Only do this once per directory
            if (_localResourcesAssemblies.Contains(virtualDir))
                return;

            // Don't do anything if it's outside the app root
            if (!virtualDir.IsWithinAppRoot)
                return;

            Debug.Trace("BuildManager", "EnsureFirstTimeDirectoryInit(" + virtualDir + ")");

            // Get the virtual path to the LocalResources subdirectory for this directory
            VirtualPath localResDir = virtualDir.SimpleCombineWithDir(HttpRuntime.LocalResourcesDirectoryName);

            bool dirExists;
            try {
                dirExists = localResDir.DirectoryExists();
            }
            catch {
                // If an exception happens, the directory may be outside the application,
                // in which case we should skip this logic, and act is if there are no
                // local resources (VSWhidbey 258776);

                _localResourcesAssemblies[virtualDir] = null;
                return;
            }

            Debug.Trace("BuildManager", "EnsureFirstTimeDirectoryInit: dirExists=" + dirExists);

            try {
                // Monitor changes to it so the appdomain can shut down when it changes
                HttpRuntime.StartListeningToLocalResourcesDirectory(localResDir);
            }
            catch {
                // could fail for long directory names
                if (dirExists) {
                    throw;
                }
            }

            Assembly resourceAssembly = null;

            // If it exists, build it
            if (dirExists) {

                string localResAssemblyName = GetLocalResourcesAssemblyName(virtualDir);

                bool gotLock = false;

                try {
                    // Grab the compilation mutex, since this method accesses the codegen files
                    CompilationLock.GetLock(ref gotLock);

                    resourceAssembly = CompileCodeDirectory(localResDir, CodeDirectoryType.LocalResources,
                        localResAssemblyName, null /*excludedSubdirectories*/);
                }
                finally {
                    // Always release the mutex if we had taken it
                    if (gotLock) {
                        CompilationLock.ReleaseLock();
                    }
                }
            }

            // Cache it whether it's null or not
            _localResourcesAssemblies[virtualDir] = resourceAssembly;
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:76,代码来源:BuildManager.cs

示例2: 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;
    }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:58,代码来源:MapPathBasedVirtualPathProvider.cs


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