Exemple #1
0
        public override VirtualFile GetFile(string virtualPath)
        {
            // file remains null if it exists in the filesystem and AllowOverrides is true

            VirtualFile file = null;

            ResourceExists(
                virtualPath,
                (assembly, resources) =>
            {
                file = new EmbeddedResourceVirtualFile(virtualPath, assembly, resources);
                return(true);
            });

            file = file ?? Previous.GetFile(virtualPath);

            return(file);
        }
Exemple #2
0
    /// <summary>
    /// Locate the path in the virtual path provider
    /// </summary>
    /// <param name="subpath">The path that identifies the file</param>
    /// <param name="fileInfo">The discovered file if any</param>
    /// <returns>
    /// True if a file was located at the given path
    /// </returns>
    public bool TryGetFileInfo(string subpath, out IFileInfo fileInfo)
    {
        MyCustomVirtualPathProvider virtualPathProvider =
            (MyCustomVirtualPathProvider)HostingEnvironment.VirtualPathProvider;

        if (!virtualPathProvider.FileExists(subpath))
        {
            fileInfo = null;
            return(false);
        }
        try
        {
            EmbeddedResourceVirtualFile virtualFile =
                (EmbeddedResourceVirtualFile)virtualPathProvider.GetFile(subpath);
            fileInfo = new EmbeddedResourceFileInfo(virtualFile);
            return(true);
        }
        catch (InvalidCastException)
        {
            fileInfo = null;
            return(false);
        }
    }
Exemple #3
0
 /// <summary>
 /// Construct using a <see cref="EmbeddedResourceVirtualFile"/>
 /// </summary>
 /// <param name="virtualFile"></param>
 public EmbeddedResourceFileInfo(EmbeddedResourceVirtualFile virtualFile)
 {
     this.virtualFile = virtualFile;
 }