VirtualPathProvider.GetCacheDependency(String, IEnumerable, DateTime) 메서드

정의

지정된 가상 경로를 기반으로 캐시 종속성을 만듭니다.

public:
 virtual System::Web::Caching::CacheDependency ^ GetCacheDependency(System::String ^ virtualPath, System::Collections::IEnumerable ^ virtualPathDependencies, DateTime utcStart);
public virtual System.Web.Caching.CacheDependency GetCacheDependency (string virtualPath, System.Collections.IEnumerable virtualPathDependencies, DateTime utcStart);
abstract member GetCacheDependency : string * System.Collections.IEnumerable * DateTime -> System.Web.Caching.CacheDependency
override this.GetCacheDependency : string * System.Collections.IEnumerable * DateTime -> System.Web.Caching.CacheDependency
Public Overridable Function GetCacheDependency (virtualPath As String, virtualPathDependencies As IEnumerable, utcStart As DateTime) As CacheDependency

매개 변수

virtualPath
String

기본 가상 리소스의 경로입니다.

virtualPathDependencies
IEnumerable

기본 가상 리소스에 필요한 다른 리소스 경로의 배열입니다.

utcStart
DateTime

가상 리소스를 읽은 UTC 시간입니다.

반환

CacheDependency

지정된 가상 리소스에 대한 CacheDependency 개체입니다.

예제

다음 코드 예제에서는 구현 된 GetCacheDependency 사용자 지정에 대 한 메서드 VirtualPathProvider 클래스입니다. 예제를 실행 하는 데 필요한 전체 코드의 예제 섹션을 참조 하세요.를 VirtualPathProvider 클래스 개요 항목입니다.

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);
        }
    }
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

설명

기본 구현 된 GetCacheDependency 메서드가 반환 되는 null합니다. 캐시 가상 리소스를 나중에 사용할 재정의 해야 합니다 GetCacheDependency 메서드 또는 GetFileHash 메서드.

적용 대상