/// <summary>
 /// Initializes a new instance of the VirtualDirectory class.
 /// </summary>
 /// <param name="provider">Provides the set of methods that enable a Web application to retrieve resources from a virtual file system.</param>
 /// <param name="virtualPath">The virtual path to the resource represented by this instance.</param>
 /// <param name="main">The virtual path to the parent directory.</param>
 public MvcModuleVirtualDirectory(MvcVirtualPathProvider provider, string virtualPath, VirtualDirectory main)
     : base(virtualPath)
 {
     _provider = provider;
     _parsed   = MvcModules.ParseContentPath(virtualPath);
     _dir      = main;
 }
        /// <summary>
        /// Gets the full path to the module if it is relative.
        /// </summary>
        /// <param name="path">The path to the module.</param>
        /// <returns>The full path to the module.</returns>
        protected string GetModulePath(string path)
        {
            if (path.StartsWith("~/"))
            {
                path = MvcModules.GetModulePath(this, path.Substring(2));
            }

            return(path);
        }
        /// <summary>
        /// Parses a virtual path to the MvcModuleContentPath structure.
        /// </summary>
        /// <param name="virtualPath">The path to the virtual file or directory.</param>
        /// <returns>The MvcModuleContentPath structure with information about the virtual file or virtual directory.</returns>
        private MvcModuleContentPath ParsePath(string virtualPath)
        {
            var parsed = MvcModules.ParseContentPath(virtualPath);

            if (parsed.Module == null && parsed.ModuleName.Length > 0 && !parsed.ModuleName.StartsWith("App_"))
            {
                Log.Warn("ParsePath: module '{0}' not found - {1}", parsed.ModuleName, virtualPath);
            }

            return(parsed);
        }
Esempio n. 4
0
        /// <summary>
        /// Returns a read-only stream to the virtual resource.
        /// </summary>
        /// <returns>A read-only stream to the virtual file.</returns>
        public override Stream Open()
        {
            var parsed = MvcModules.ParseContentPath(VirtualPath);

            if (parsed.Module == null || parsed.Module.FileSystem == null)
            {
                throw new FileNotFoundException(
                          string.Concat("File '", VirtualPath, "' not found"),
                          VirtualPath
                          );
            }

            MvcModules.CacheRequestedFile(parsed);

            return(parsed.Module.FileSystem.GetFile(parsed.ContentPath));
        }