VirtualPathProvider Classe
Definição
Fornece um conjunto de métodos que permitem que um aplicativo Web recupere recursos de um sistema de arquivos virtual.Provides a set of methods that enable a Web application to retrieve resources from a virtual file system.
public ref class VirtualPathProvider abstract : MarshalByRefObject
public abstract class VirtualPathProvider : MarshalByRefObject
type VirtualPathProvider = class
inherit MarshalByRefObject
Public MustInherit Class VirtualPathProvider
Inherits MarshalByRefObject
- Herança
Exemplos
O exemplo de código a seguir é uma VirtualPathProvider implementação de classe que cria um sistema de arquivos virtual usando informações armazenadas em um DataSet objeto.The following code example is a VirtualPathProvider class implementation that creates a virtual file system using information stored in a DataSet object. O exemplo de código funciona com os exemplos de código para as VirtualFile VirtualDirectory classes e para fornecer recursos virtuais de um armazenamento de dados que é carregado em um DataSet objeto.The code example works with the code examples for the VirtualFile and VirtualDirectory classes to provide virtual resources from a data store that is loaded into a DataSet object.
Este exemplo tem quatro partes: a VirtualPathProvider implementação de classe, um arquivo de dados XML usado para popular o DataSet objeto, um AppStart objeto que contém um AppInitialize método usado para registrar a VirtualPathProvider classe com o sistema de compilação e uma página ASP.NET que fornece links para os arquivos virtuais.This example has four parts: the VirtualPathProvider class implementation, an XML data file used to populate the DataSet object, an AppStart object that contains an AppInitialize method used to register the VirtualPathProvider class with the compilation system, and an ASP.NET page that provides links to the virtual files.
Para usar este código de exemplo em um aplicativo, siga estas etapas.To use this sample code in an application, follow these steps.
Crie um aplicativo de exemplo em seu servidor Web.Create a sample application on your Web server.
Copie o código-fonte do VirtualPathProvider objeto personalizado (veja abaixo) em um arquivo no diretório do aplicativo
App_Code.Copy the source code for the custom VirtualPathProvider object (see below) into a file in the application'sApp_Codedirectory.Copie o código-fonte do VirtualDirectory objeto personalizado (consulte a seção de exemplo no VirtualDirectory tópico Visão geral da classe) em um arquivo no diretório do aplicativo
App_Code.Copy the source code for the custom VirtualDirectory object (see the Example section in the VirtualDirectory class overview topic) into a file in the application'sApp_Codedirectory.Copie o código-fonte do VirtualFile objeto personalizado (consulte a seção de exemplo no VirtualFile tópico Visão geral da classe) em um arquivo no diretório do aplicativo
App_Code.Copy the source code for the custom VirtualFile object (see the Example section in the VirtualFile class overview topic) into a file in the application'sApp_Codedirectory.Copie o código-fonte do
AppStartobjeto (veja abaixo) em um arquivo no diretório do aplicativoApp_Code.Copy the source code for theAppStartobject (see below) into a file in the application'sApp_Codedirectory.Copie os dados XML (veja abaixo) em um arquivo chamado
XMLData.xmlem um arquivo no diretório do aplicativoApp_Data.Copy the XML data (see below) into a file namedXMLData.xmlinto a file in the application'sApp_Datadirectory.Copie o
default.aspxarquivo (veja abaixo) no diretório raiz do aplicativo de exemplo.Copy thedefault.aspxfile (see below) into the root directory of the sample application. Use um navegador da Web para abrir odefault.aspxarquivo e, em seguida, clique nos links na página para ver o conteúdo dos arquivos virtuais.Use a Web browser to open thedefault.aspxfile, and then click the links on the page to see the contents of the virtual files.
O primeiro exemplo é uma VirtualPathProvider classe personalizada.The first example is a custom VirtualPathProvider class. Os DirectoryExists FileExists métodos e são substituídos para indicar se um diretório solicitado está presente no sistema de arquivos virtual.The DirectoryExists and FileExists methods are overridden to indicate whether a requested directory is present in the virtual file system. Os GetDirectory GetFile métodos e são substituídos para retornar VirtualDirectory VirtualFile as instâncias e personalizadas que contêm informações do sistema de arquivos virtual.The GetDirectory and GetFile methods are overridden to return custom VirtualDirectory and VirtualFile instances containing information from the virtual file system.
A classe também fornece um GetVirtualData método usado pelas VirtualDirectory classes e VirtualFile para acessar o DataSet objeto que contém os dados do sistema de arquivos virtual.The class also provides a GetVirtualData method used by the VirtualDirectory and VirtualFile classes to access the DataSet object containing the virtual file system data. Em uma implementação de produção, esse método normalmente seria implementado em um objeto de negócios responsável por interagir com o armazenamento de dados.In a production implementation, this method would typically be implemented in a business object responsible for interacting with the data store.
using System;
using System.Data;
using System.Security.Permissions;
using System.Web;
using System.Web.Caching;
using System.Web.Hosting;
namespace Samples.AspNet.CS
{
[AspNetHostingPermission(SecurityAction.Demand, Level = AspNetHostingPermissionLevel.Medium)]
[AspNetHostingPermission(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.High)]
public class SamplePathProvider : VirtualPathProvider
{
private string dataFile;
public SamplePathProvider()
: base()
{
}
protected override void Initialize()
{
// Set the datafile path relative to the application's path.
dataFile = HostingEnvironment.ApplicationPhysicalPath + "App_Data\\XMLData.xml";
}
/// <summary>
/// Data set provider for the SampleVirtualDirectory and
/// SampleVirtualFile classes. In a production application
/// this method would be on a provider class that accesses
/// the virtual resource data source.
/// </summary>
/// <returns>
/// The System.Data.DataSet containing the virtual resources
/// provided by the SamplePathProvider.
/// </returns>
public DataSet GetVirtualData()
{
// Get the data from the cache.
DataSet ds = (DataSet)HostingEnvironment.Cache.Get("VPPData");
if (ds == null)
{
// Data not in cache. Read XML file.
ds = new DataSet();
ds.ReadXml(dataFile);
// Make DataSet dependent on XML file.
CacheDependency cd = new CacheDependency(dataFile);
// Put DataSet into cache for maximum of 20 minutes.
HostingEnvironment.Cache.Add("VPPData", ds, cd,
Cache.NoAbsoluteExpiration,
new TimeSpan(0, 20, 0),
CacheItemPriority.Default, null);
// Set data timestamp.
DateTime dataTimeStamp = DateTime.Now;
// Cache it so we can get the timestamp in later calls.
HostingEnvironment.Cache.Insert("dataTimeStamp", dataTimeStamp, null,
Cache.NoAbsoluteExpiration,
new TimeSpan(0, 20, 0),
CacheItemPriority.Default, null);
}
return ds;
}
/// <summary>
/// Determines whether a specified virtual path is within
/// the virtual file system.
/// </summary>
/// <param name="virtualPath">An absolute virtual path.</param>
/// <returns>
/// true if the virtual path is within the
/// virtual file sytem; otherwise, false.
/// </returns>
private bool IsPathVirtual(string virtualPath)
{
String checkPath = VirtualPathUtility.ToAppRelative(virtualPath);
return checkPath.StartsWith("~/vrdir", StringComparison.InvariantCultureIgnoreCase);
}
public override bool FileExists(string virtualPath)
{
if (IsPathVirtual(virtualPath))
{
SampleVirtualFile file = (SampleVirtualFile)GetFile(virtualPath);
return file.Exists;
}
else
{
return Previous.FileExists(virtualPath);
}
}
public override bool DirectoryExists(string virtualDir)
{
if (IsPathVirtual(virtualDir))
{
SampleVirtualDirectory dir = (SampleVirtualDirectory)GetDirectory(virtualDir);
return dir.Exists;
}
else
{
return Previous.DirectoryExists(virtualDir);
}
}
public override VirtualFile GetFile(string virtualPath)
{
if (IsPathVirtual(virtualPath))
return new SampleVirtualFile(virtualPath, this);
else
return Previous.GetFile(virtualPath);
}
public override VirtualDirectory GetDirectory(string virtualDir)
{
if (IsPathVirtual(virtualDir))
return new SampleVirtualDirectory(virtualDir, this);
else
return Previous.GetDirectory(virtualDir);
}
public override CacheDependency GetCacheDependency(
string virtualPath,
System.Collections.IEnumerable virtualPathDependencies,
DateTime utcStart)
{
if (IsPathVirtual(virtualPath))
{
System.Collections.Specialized.StringCollection fullPathDependencies = null;
// Get the full path to all dependencies.
foreach (string virtualDependency in virtualPathDependencies)
{
if (fullPathDependencies == null)
fullPathDependencies = new System.Collections.Specialized.StringCollection();
fullPathDependencies.Add(virtualDependency);
}
if (fullPathDependencies == null)
return null;
// Copy the list of full-path dependencies into an array.
string[] fullPathDependenciesArray = new string[fullPathDependencies.Count];
fullPathDependencies.CopyTo(fullPathDependenciesArray, 0);
// Copy the virtual path into an array.
string[] virtualPathArray = new string[1];
virtualPathArray[0] = virtualPath;
return new CacheDependency(virtualPathArray, fullPathDependenciesArray, utcStart);
}
else
{
return Previous.GetCacheDependency(virtualPath, virtualPathDependencies, utcStart);
}
}
}
}
Imports System.Data
Imports System.Security.Permissions
Imports System.Web
Imports System.Web.Caching
Imports System.Web.Hosting
Namespace Samples.AspNet.VB
<AspNetHostingPermission(SecurityAction.Demand, Level:=AspNetHostingPermissionLevel.Medium), _
AspNetHostingPermission(SecurityAction.InheritanceDemand, level:=AspNetHostingPermissionLevel.High)> _
Public Class SamplePathProvider
Inherits VirtualPathProvider
Private dataFile As String
Public Sub New()
MyBase.New()
End Sub
Protected Overrides Sub Initialize()
' Set the datafile path relative to the application's path.
dataFile = HostingEnvironment.ApplicationPhysicalPath & _
"App_Data\XMLData.xml"
End Sub
' Data set provider for the SampleVirtualFile and
' SampleVirtualDirectory classes. In a production application
' this method would be on a provider class that accesses
' the virtual resource data source.
' The System.Data.DataSet containing the virtual resources
' provided by the SamplePathProvider.
Public Function GetVirtualData() As DataSet
' Get the data from the cache.
Dim ds As DataSet
ds = CType(HostingEnvironment.Cache.Get("VPPData"), DataSet)
If ds Is Nothing Then
' Data set not in cache. Read XML file.
ds = New DataSet
ds.ReadXml(dataFile)
' Make DataSet dependent on XML file.
Dim cd As CacheDependency
cd = New CacheDependency(dataFile)
' Put DataSet into cache for maximum of 20 minutes.
HostingEnvironment.Cache.Add("VPPData", ds, cd, _
Cache.NoAbsoluteExpiration, _
New TimeSpan(0, 20, 0), _
CacheItemPriority.Default, Nothing)
' Set data timestamp.
Dim dataTimeStamp As DateTime
dataTimeStamp = DateTime.Now
' Cache it so we can get the timestamp in later calls.
HostingEnvironment.Cache.Add("dataTimeStamp", dataTimeStamp, Nothing, _
Cache.NoAbsoluteExpiration, _
New TimeSpan(0, 20, 0), _
CacheItemPriority.Default, Nothing)
End If
Return ds
End Function
Private Function IsPathVirtual(ByVal virtualPath As String) As Boolean
Dim checkPath As String
checkPath = VirtualPathUtility.ToAppRelative(virtualPath)
Return checkPath.StartsWith("~/vrdir", StringComparison.InvariantCultureIgnoreCase)
End Function
Public Overrides Function FileExists(ByVal virtualPath As String) As Boolean
If (IsPathVirtual(virtualPath)) Then
Dim file As SampleVirtualFile
file = CType(GetFile(virtualPath), SampleVirtualFile)
Return file.Exists
Else
Return Previous.FileExists(virtualPath)
End If
End Function
Public Overrides Function DirectoryExists(ByVal virtualDir As String) As Boolean
If (IsPathVirtual(virtualDir)) Then
Dim dir As SampleVirtualDirectory
dir = CType(GetDirectory(virtualDir), SampleVirtualDirectory)
Return dir.exists
Else
Return Previous.DirectoryExists(virtualDir)
End If
End Function
Public Overrides Function GetFile(ByVal virtualPath As String) As VirtualFile
If (IsPathVirtual(virtualPath)) Then
Return New SampleVirtualFile(virtualPath, Me)
Else
Return Previous.GetFile(virtualPath)
End If
End Function
Public Overrides Function GetDirectory(ByVal virtualDir As String) As VirtualDirectory
If (IsPathVirtual(virtualDir)) Then
Return New SampleVirtualDirectory(virtualDir, Me)
Else
Return Previous.GetDirectory(virtualDir)
End If
End Function
Public Overrides Function GetCacheDependency(ByVal virtualPath As String, ByVal virtualPathDependencies As IEnumerable, ByVal utcStart As Date) As CacheDependency
If (IsPathVirtual(virtualPath)) Then
Dim fullPathDependencies As System.Collections.Specialized.StringCollection
fullPathDependencies = Nothing
' Get the full path to all dependencies.
For Each virtualDependency As String In virtualPathDependencies
If fullPathDependencies Is Nothing Then
fullPathDependencies = New System.Collections.Specialized.StringCollection
End If
fullPathDependencies.Add(virtualDependency)
Next
If fullPathDependencies Is Nothing Then
Return Nothing
End If
Dim fullPathDependenciesArray As String()
fullPathDependencies.CopyTo(fullPathDependenciesArray, 0)
Return New CacheDependency(fullPathDependenciesArray, utcStart)
Else
Return Previous.GetCacheDependency(virtualPath, virtualPathDependencies, utcStart)
End If
End Function
End Class
End Namespace
O segundo exemplo é o arquivo de dados XML usado para popular o DataSet objeto retornado pelo VirtualPathProvider objeto personalizado.The second example is the XML data file used to populate the DataSet object returned by the custom VirtualPathProvider object. Esses dados XML são usados para demonstrar o uso VirtualPathProvider dos VirtualDirectory objetos, e VirtualFile para recuperar dados de dados externos e não se destina a representar um armazenamento de dados de qualidade de produção.This XML data is used to demonstrate using the VirtualPathProvider, VirtualDirectory, and VirtualFile objects to retrieve data from external data and is not intended to represent a production-quality data store.
<?xml version="1.0" encoding="utf-8" ?>
<resource type="dir"
path="/vrDir"
parentPath=""
content="">
<resource type="file"
path="/vrDir/Level1FileA.vrf"
parentPath="/vrDir"
content="This is the content of file Level1FileA.">
</resource>
<resource type="file"
path="/vrDir/Level1FileB.vrf"
parentPath="/vrDir"
content="This is the content of file Level1FileB.">
</resource>
<resource type="dir"
path="/vrDir/Level2DirA"
parentPath="/vrDir"
content="">
<resource type="file"
path="/vrDir/Level2DirA/Level2FileA.vrf"
parentPath="/vrDir/Level2DirA"
content="This is the content of file Level2FileA.">
</resource>
<resource type="file"
path="/vrDir/Level2DirA/Level2FileB.vrf"
parentPath="/vrDir/Level2DirA"
content="This is the content of file Level2FileB.">
</resource>
</resource>
<resource type="dir"
path="/vrDir/Level2DirB"
parentPath="/vrDir"
content="">
<resource type="file"
path="/vrDir/Level2DirB/Level2FileA.vrf"
parentPath="/vrDir/Level2DirB"
content="This is the content of file Level2FileA.">
</resource>
<resource type="file"
path="/vrDir/Level2DirB/Level2FileB.vrf"
parentPath="/vrDir/Level2DirB"
content="This is the content of file Level2FileB.">
</resource>
</resource>
</resource>
O terceiro exemplo fornece um AppStart objeto que contém um AppInitialize método.The third example provides an AppStart object that contains an AppInitialize method. Esse método é chamado durante a inicialização de um aplicativo ASP.NET para executar qualquer inicialização personalizada necessária.This method is called during the initialization of an ASP.NET application to perform any custom initialization required. Nesse caso, ele registra o objeto personalizado VirtualPathProvider com o sistema de compilação ASP.net.In this case, it registers the custom VirtualPathProvider object with the ASP.NET build system.
using System.Web.Hosting;
namespace Samples.AspNet.CS
{
/// <summary>
/// Contains the application initialization method
/// for the sample application.
/// </summary>
public static class AppStart
{
public static void AppInitialize()
{
SamplePathProvider sampleProvider = new SamplePathProvider();
HostingEnvironment.RegisterVirtualPathProvider(sampleProvider);
}
}
}
Imports System.Web.Hosting
Namespace Samples.AspNet.VB
Public Class AppStart
Public Shared Sub AppInitialize()
Dim sampleProvider As SamplePathProvider = New SamplePathProvider()
HostingEnvironment.RegisterVirtualPathProvider(sampleProvider)
End Sub
End Class
End Namespace
O último exemplo é uma página ASP.NET que contém links para os arquivos virtuais contidos no sistema de arquivos virtual.The last example is an ASP.NET page that contains links to the virtual files contained in the virtual file system.
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html" />
<title>Virtual Path Provider Example</title>
</head>
<body>
<form id="form1" runat="server">
<asp:HyperLink ID="hyperLink1" runat="server" NavigateUrl="vrDir/Level1FileA.vrf" Text="Level 1, File A" /><br />
<asp:HyperLink ID="hyperLink2" runat="server" NavigateUrl="vrDir/Level1FileB.vrf" Text="Level 1, File B" /><br />
<asp:HyperLink ID="hyperLink3" runat="server" NavigateUrl="vrDir/Level2DirA/Level2FileA.vrf" Text="Level 2a, File A" /><br />
<asp:HyperLink ID="hyperLink4" runat="server" NavigateUrl="vrDir/Level2DirA/Level2FileB.vrf" Text="Level 2a, File B" /><br />
<asp:HyperLink ID="hyperLink5" runat="server" NavigateUrl="vrDir/Level2DirB/Level2FileA.vrf" Text="Level 2b, File A" /><br />
<asp:HyperLink ID="hyperLink6" runat="server" NavigateUrl="vrDir/Level2DirB/Level2FileB.vrf" Text="Level 2b, File B" /><br />
</form>
</body>
</html>
<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<meta http-equiv="Content-Type" content="text/html" />
<title>Virtual Path Provider Example</title>
</head>
<body>
<form id="form1" runat="server">
<asp:HyperLink ID="hyperLink1" runat="server" NavigateUrl="vrDir/Level1FileA.vrf" Text="Level 1, File A" /><br />
<asp:HyperLink ID="hyperLink2" runat="server" NavigateUrl="vrDir/Level1FileB.vrf" Text="Level 1, File B" /><br />
<asp:HyperLink ID="hyperLink3" runat="server" NavigateUrl="vrDir/Level2DirA/Level2FileA.vrf" Text="Level 2a, File A" /><br />
<asp:HyperLink ID="hyperLink4" runat="server" NavigateUrl="vrDir/Level2DirA/Level2FileB.vrf" Text="Level 2a, File B" /><br />
<asp:HyperLink ID="hyperLink5" runat="server" NavigateUrl="vrDir/Level2DirB/Level2FileA.vrf" Text="Level 2b, File A" /><br />
<asp:HyperLink ID="hyperLink6" runat="server" NavigateUrl="vrDir/Level2DirB/Level2FileB.vrf" Text="Level 2b, File B" /><br />
</form>
</body>
</html>
Comentários
A VirtualPathProvider classe fornece um conjunto de métodos para implementar um sistema de arquivos virtual para um aplicativo Web.The VirtualPathProvider class provides a set of methods for implementing a virtual file system for a Web application. Em um sistema de arquivos virtual, os arquivos e diretórios são gerenciados por um armazenamento de dados diferente do sistema de arquivos fornecido pelo sistema operacional do servidor.In a virtual file system, the files and directories are managed by a data store other than the file system provided by the server's operating system. Por exemplo, você pode usar um sistema de arquivos virtual para armazenar o conteúdo em um banco de dados SQL Server.For example, you can use a virtual file system to store content in a SQL Server database.
Você pode armazenar qualquer arquivo processado em uma solicitação em um sistema de arquivos virtual.You can store any file that is processed on request in a virtual file system. Isso inclui:This includes:
Páginas ASP.NET, páginas mestras, controles de usuário e outros objetos.ASP.NET pages, master pages, user controls, and other objects.
Páginas da Web padrão com extensões como. htm e. jpg.Standard Web pages with extensions such as .htm and .jpg.
Qualquer extensão personalizada mapeada para uma BuildProvider instância.Any custom extension mapped to a BuildProvider instance.
Qualquer tema nomeado na
App_Themepasta.Any named theme in theApp_Themefolder.
Você não pode armazenar pastas de aplicativo ASP.NET ou arquivos que geram assemblies de nível de aplicativo em um sistema de arquivos virtual.You cannot store ASP.NET application folders or files that generate application-level assemblies in a virtual file system. Isso inclui:This includes:
O arquivo global. asax.The Global.asax file.
Web.config arquivos.Web.config files.
Arquivos de dados de mapa do site usados pelo XmlSiteMapProvider .Site map data files used by the XmlSiteMapProvider.
Diretórios que contêm assemblies de aplicativo ou que geram assemblies de aplicativo:
Bin,App_Code,App_GlobalResources, AnyApp_LocalResources.Directories that contain application assemblies or that generate application assemblies:Bin,App_Code,App_GlobalResources, anyApp_LocalResources.A pasta dados do aplicativo,
App_Data.The application data folder,App_Data.
Observação
Se um site da Web for pré-compilado para implantação, o conteúdo fornecido por uma VirtualPathProvider instância não será compilado e nenhuma VirtualPathProvider instância será usada pelo site pré-compilado.If a Web site is precompiled for deployment, content provided by a VirtualPathProvider instance is not compiled, and no VirtualPathProvider instances are used by the precompiled site.
Registrando um VirtualPathProviderRegistering a VirtualPathProvider
Uma VirtualPathProvider instância personalizada deve ser registrada com o sistema de compilação ASP.NET usando o HostingEnvironment.RegisterVirtualPathProvider método antes que qualquer análise de página ou compilação seja executada pelo aplicativo Web.A custom VirtualPathProvider instance should be registered with the ASP.NET compilation system by using the HostingEnvironment.RegisterVirtualPathProvider method before any page parsing or compilation is performed by the Web application.
Normalmente, uma VirtualPathProvider instância é registrada em um AppInitialize método definido no App_Code diretório ou durante o Application_Start evento no Global.asax arquivo.Typically, a VirtualPathProvider instance is registered in an AppInitialize method defined in the App_Code directory, or during the Application_Start event in the Global.asax file. Para obter um exemplo de registro de uma VirtualPathProvider instância em um AppInitialize método, consulte a seção de exemplo.For an example of registering a VirtualPathProvider instance in an AppInitialize method, see the Example section.
Você pode registrar uma VirtualPathProvider instância durante outros eventos, mas as páginas compiladas e armazenadas em cache antes da VirtualPathProvider instância ser registrada não serão invalidadas, mesmo que a nova VirtualPathProvider instância agora forneça a origem para a página compilada anteriormente.You can register a VirtualPathProvider instance during other events, but pages compiled and cached before the VirtualPathProvider instance is registered will not be invalidated, even if the new VirtualPathProvider instance would now provide the source for the previously compiled page.
Notas aos Implementadores
Ao herdar do VirtualPathProvider , você deve substituir os seguintes membros:When you inherit from VirtualPathProvider, you must override the following members:
Se sua VirtualPathProvider classe personalizada oferecer suporte a diretórios no sistema de arquivos virtual, você deverá substituir os membros a seguir.If your custom VirtualPathProvider class supports directories in the virtual file system, you must override the following members.
Se o seu sistema de arquivos virtual contiver temas para o site (criando um diretório deApp_Themesvirtual), sua VirtualPathProvider classe personalizada deverá dar suporte a diretórios.If your virtual file system will contain themes for the Web site (by creating a virtualApp_Themesdirectory), your custom VirtualPathProvider class must support directories.Uma VirtualPathProvider classe personalizada funciona com classes derivadas das VirtualFile classes e VirtualDirectory .A custom VirtualPathProvider class works with classes derived from the VirtualFile and VirtualDirectory classes. Você deve implementar classes derivadas desses tipos para fornecer informações de arquivo e diretório do seu sistema de arquivos virtual.You should implement derived classes from these types to provide file and directory information from your virtual file system. Para obter um exemplo de uma VirtualFile implementação personalizada, consulte a seção de exemplo do VirtualFile tópico Visão geral da classe.For an example of a custom VirtualFile implementation, see the Example section of the VirtualFile class overview topic. Para obter um exemplo de uma VirtualDirectory implementação personalizada, consulte a seção de exemplo do VirtualDirectory tópico Visão geral da classe.For an example of a custom VirtualDirectory implementation, see the Example section of the VirtualDirectory class overview topic.
Construtores
| VirtualPathProvider() |
Inicializa a classe para uso por uma instância de classe herdada.Initializes the class for use by an inherited class instance. Esse construtor pode ser chamado apenas por uma classe herdada.This constructor can be called only by an inherited class. |
Propriedades
| Previous |
Obtém uma referência a um objeto VirtualPathProvider registrado anteriormente no sistema de compilação.Gets a reference to a previously registered VirtualPathProvider object in the compilation system. |
Métodos
| CombineVirtualPaths(String, String) |
Combina um caminho base com um caminho relativo para retornar um caminho completo para um recurso virtual.Combines a base path with a relative path to return a complete path to a virtual resource. |
| CreateObjRef(Type) |
Cria um objeto que contém todas as informações relevantes necessárias para gerar um proxy usado para se comunicar com um objeto remoto.Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Herdado de MarshalByRefObject) |
| DirectoryExists(String) |
Obtém um valor que indica se um diretório existe no sistema de arquivos virtual.Gets a value that indicates whether a directory exists in the virtual file system. |
| Equals(Object) |
Determina se o objeto especificado é igual ao objeto atual.Determines whether the specified object is equal to the current object. (Herdado de Object) |
| FileExists(String) |
Obtém um valor que indica se um arquivo existe no sistema de arquivos virtual.Gets a value that indicates whether a file exists in the virtual file system. |
| GetCacheDependency(String, IEnumerable, DateTime) |
Cria uma dependência de cache com base nos caminhos virtuais especificados.Creates a cache dependency based on the specified virtual paths. |
| GetCacheKey(String) |
Retorna uma chave de cache a ser usada para o caminho virtual especificado.Returns a cache key to use for the specified virtual path. |
| GetDirectory(String) |
Obtém um diretório virtual do sistema de arquivos virtual.Gets a virtual directory from the virtual file system. |
| GetFile(String) |
Obtém um arquivo virtual do sistema de arquivos virtual.Gets a virtual file from the virtual file system. |
| GetFileHash(String, IEnumerable) |
Retorna um hash de caminhos virtuais especificados.Returns a hash of the specified virtual paths. |
| GetHashCode() |
Serve como a função de hash padrão.Serves as the default hash function. (Herdado de Object) |
| GetLifetimeService() |
Obsoleto.
Recupera o objeto de serviço de tempo de vida atual que controla a política de ciclo de vida para esta instância.Retrieves the current lifetime service object that controls the lifetime policy for this instance. (Herdado de MarshalByRefObject) |
| GetType() |
Obtém o Type da instância atual.Gets the Type of the current instance. (Herdado de Object) |
| Initialize() |
Inicializa a instância VirtualPathProvider.Initializes the VirtualPathProvider instance. |
| InitializeLifetimeService() |
Fornece ao objeto VirtualPathProvider um tempo de vida infinito ao impedir que uma concessão seja criada.Gives the VirtualPathProvider object an infinite lifetime by preventing a lease from being created. |
| MemberwiseClone() |
Cria uma cópia superficial do Object atual.Creates a shallow copy of the current Object. (Herdado de Object) |
| MemberwiseClone(Boolean) |
Cria uma cópia superficial do objeto MarshalByRefObject atual.Creates a shallow copy of the current MarshalByRefObject object. (Herdado de MarshalByRefObject) |
| OpenFile(String) |
Retorna um fluxo de um arquivo virtual.Returns a stream from a virtual file. |
| ToString() |
Retorna uma cadeia de caracteres que representa o objeto atual.Returns a string that represents the current object. (Herdado de Object) |