PartialCachingAttribute 클래스
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
Web Forms 사용자가 제어하는 메타데이터 특성(.ascx 파일)을 정의하여 출력이 캐시되는지와 방법을 나타냅니다. 이 클래스는 상속할 수 없습니다.
public ref class PartialCachingAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Class)]
public sealed class PartialCachingAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Class)>]
type PartialCachingAttribute = class
inherit Attribute
Public NotInheritable Class PartialCachingAttribute
Inherits Attribute
- 상속
- 특성
예제
다음 코드 예제에서는 .를 사용하는 방법을 PartialCachingAttribute보여 줍니다. 이 예제에는 다음 세 부분이 있습니다.
기본 클래스
ctlMine에서 UserControl 상속되고 PartialCachingAttribute 특성이 적용되는 부분 클래스입니다.partial 클래스와 함께
ctlMine사용되는 사용자 컨트롤입니다.사용자 컨트롤을 호스트하는 Web Forms 페이지입니다.
예제의 첫 번째 부분은 기본 클래스에서 UserControl 상속되고 특성이 적용되는 부분 클래스를 PartialCachingAttribute 보여 줍니다. 이 예제에서 특성은 사용자 컨트롤을 20초 동안 캐시해야 한다고 지정합니다.
// [filename partialcache.cs]
// Create a code-behind user control that is cached
// for 20 seconds using the PartialCachingAttribute class.
// This control uses a DataGrid server control to display
// XML data.
using System;
using System.IO;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Samples.AspNet.CS.Controls
{
// Set the PartialCachingAttribute.Duration property to 20 seconds.
[PartialCaching(20)]
public partial class ctlMine : UserControl
{
protected void Page_Load(Object Src, EventArgs E)
{
DataSet ds = new DataSet();
FileStream fs = new FileStream(Server.MapPath("schemadata.xml"), FileMode.Open, FileAccess.Read);
StreamReader reader = new StreamReader(fs);
ds.ReadXml(reader);
fs.Close();
DataView Source = new DataView(ds.Tables[0]);
// Use the LiteralControl constructor to create a new
// instance of the class.
LiteralControl myLiteral = new LiteralControl();
// Set the LiteralControl.Text property to an HTML
// string and the TableName value of a data source.
myLiteral.Text = "<h6><font face=verdana>Caching an XML Table: " + Source.Table.TableName + " </font></h6>";
MyDataGrid.DataSource = Source;
MyDataGrid.DataBind();
TimeMsg.Text = DateTime.Now.ToString("G");
}
}
}
' Filename is partialcache.vb
' Create a code-behind user control that is cached
' for 20 seconds using the PartialCachingAttribute class.
' This control uses a DataGrid server control to display
' XML data.
Imports System.IO
Imports System.Data
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Namespace Samples.AspNet.VB.Controls
' Set the PartialCachingAttribute.Duration property to 20 seconds.
<PartialCaching(20)> _
Partial Class ctlMine
Inherits UserControl
Protected Sub Page_Load(ByVal Src As [Object], ByVal E As EventArgs)
Dim ds As New DataSet()
Dim fs As New FileStream(Server.MapPath("schemadata.xml"), FileMode.Open, FileAccess.Read)
Dim reader As New StreamReader(fs)
ds.ReadXml(reader)
fs.Close()
Dim [Source] As New DataView(ds.Tables(0))
' Use the LiteralControl constructor to create a new
' instance of the class.
Dim myLiteral As New LiteralControl()
' Set the LiteralControl.Text property to an HTML
' string and the TableName value of a data source.
myLiteral.Text = "<h6><font face=verdana>Caching an XML Table: " & [Source].Table.TableName & " </font></h6>"
MyDataGrid.DataSource = [Source]
MyDataGrid.DataBind()
TimeMsg.Text = DateTime.Now.ToString("G")
End Sub
End Class
End Namespace
예제의 두 번째 부분에서는 이전 예제와 함께 사용자 컨트롤 캐싱을 보여 주는 데 사용되는 사용자 컨트롤을 보여 줍니다.
<!-- The mark-up .ascx file that displays the output of
the partialcache.cs user control code-behind file. -->
<%@ Control language="C#" inherits="Samples.AspNet.CS.Controls.ctlMine" CodeFile="partialcache.cs.ascx.cs" %>
<ASP:DataGrid id="MyDataGrid" runat="server"
Width="900"
BackColor="#ccccff"
BorderColor="black"
ShowFooter="false"
CellPadding="3"
CellSpacing="0"
Font-Names="Verdana"
Font-Size="8pt"
HeaderStyle-BackColor="#aaaadd"
EnableViewState="false"
/>
<br />
<i>Control last generated on:</i> <asp:label id="TimeMsg" runat="server" />
<!-- The mark-up .ascx file that displays the output of
the partialcache.vb user control code-behind file. -->
<%@ Control language="vb" inherits="Samples.AspNet.VB.Controls.ctlMine" CodeFile="partialcache.vb.ascx.vb" %>
<ASP:DataGrid id="MyDataGrid" runat="server"
Width="900"
BackColor="#ccccff"
BorderColor="black"
ShowFooter="false"
CellPadding="3"
CellSpacing="0"
Font-Names="Verdana"
Font-Size="8pt"
HeaderStyle-BackColor="#aaaadd"
EnableViewState="false"
/>
<br />
<i>Control last generated on:</i> <asp:label id="TimeMsg" runat="server" />
이 예제의 세 번째 부분에서는 사용자 컨트롤을 호스트하는 Web Forms 페이지를 보여 줍니다.
<!-- The WebForms page that contains the user control generated
by partialcache.cs. -->
<%@ Register TagPrefix="Acme" TagName="Cache" Src="partialcache.cs.ascx" %>
<!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" >
<script language="C#" runat="server">
void Page_Load(Object Src, EventArgs E ) {
TimeMsg.Text = DateTime.Now.ToString("G");
}
</script>
<head runat="server">
<title>ASP.NET Example</title>
</head>
<body>
<form id="form1" runat="server">
<Acme:Cache runat="server"/>
<br />
<i>Page last generated on:</i> <asp:label id="TimeMsg" runat="server" />
</form>
</body>
</html>
<!-- The WebForms page that contains the user control generated
by partialcache.vb. -->
<%@ Register TagPrefix="Acme" TagName="Cache" Src="partialcache.vb.ascx" %>
<!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" >
<script language="vb" runat="server">
Sub Page_Load(Src As [Object], E As EventArgs)
TimeMsg.Text = DateTime.Now.ToString("G")
End Sub 'Page_Load
</script>
<head runat="server">
<title>ASP.NET Example</title>
</head>
<body>
<form id="form1" runat="server">
<Acme:Cache runat="server"/>
<br />
<i>Page last generated on:</i> <asp:label id="TimeMsg" runat="server" />
</form>
</body>
</html>
설명
PartialCachingAttribute 특성 클래스는 조각 캐싱을 지원하는 사용자 컨트롤(.ascx 파일)을 표시하고 컨트롤을 캐싱할 때 ASP.NET 사용하는 캐시 설정을 캡슐화합니다. 페이지 및 컨트롤 개발자는 이 특성을 사용하여 PartialCachingAttribute 코드 숨김 파일에서 사용자 컨트롤에 대한 출력 캐싱을 사용하도록 설정합니다.
이 방법을 PartialCachingAttribute 사용하면 출력 캐싱을 사용하도록 설정할 수 있는 여러 가지 방법 중 하나입니다. 다음 목록에서는 출력 캐싱을 사용하도록 설정하는 데 사용할 수 있는 방법을 설명합니다.
지시문을
@ OutputCache사용하여 선언적 시나리오에서 출력 캐싱을 사용하도록 설정합니다.코드 숨김 PartialCachingAttribute 파일에서 사용자 컨트롤에 대한 캐싱을 사용하도록 설정하는 데 사용합니다.
클래스를 ControlCachePolicy 사용하여 인스턴스로 작업 BasePartialCachingControl 하는 프로그래밍 방식 시나리오에서 캐시 설정을 프로그래밍 방식으로 지정합니다.
사용자 컨트롤에 @ OutputCache 지시문이 포함되어 있거나 PartialCachingAttribute 적용된 경우 ASP.NET 파서는 PartialCachingControl 클래스의 인스턴스를 생성하여 사용자 컨트롤을 래핑합니다.
ASP.NET 캐싱에 대한 자세한 내용은 Caching 참조하세요. 특성 사용에 대한 자세한 내용은 특성을 참조하세요.
생성자
| Name | Description |
|---|---|
| PartialCachingAttribute(Int32, String, String, String, Boolean) |
캐싱 기간, 값 |
| PartialCachingAttribute(Int32, String, String, String, String, Boolean) |
캐시, 데이터베이스 종속성 및 사용자 정의 컨트롤 출력을 여러 페이지와 |
| PartialCachingAttribute(Int32, String, String, String) |
캐싱 기간, GET 및 POST 값, 컨트롤 이름 및 캐시를 다양화하는 데 사용되는 사용자 지정 출력 캐싱 요구 사항을 지정하여 클래스의 PartialCachingAttribute 새 인스턴스를 초기화합니다. |
| PartialCachingAttribute(Int32) |
캐시할 사용자 컨트롤에 PartialCachingAttribute 지정된 기간을 할당하여 클래스의 새 인스턴스를 초기화합니다. |
속성
| Name | Description |
|---|---|
| Duration |
캐시된 항목이 출력 캐시에 남아 있어야 하는 시간(초)을 가져옵니다. |
| ProviderName |
연결된 컨트롤에 대한 출력 캐시 데이터를 저장하는 데 사용되는 공급자의 이름을 가져오거나 설정합니다. |
| Shared |
사용자 제어 출력을 여러 페이지와 공유할 수 있는지 여부를 나타내는 값을 가져옵니다. |
| SqlDependency |
캐시된 사용자 컨트롤이 종속된 하나 이상의 데이터베이스 및 테이블 이름 쌍을 식별하는 구분된 문자열을 가져옵니다. |
| TypeId |
파생 클래스에서 구현되는 경우 이 Attribute대한 고유 식별자를 가져옵니다. (다음에서 상속됨 Attribute) |
| VaryByControls |
출력 캐시가 사용자 컨트롤을 변경하기 위해 사용하는 사용자 컨트롤 속성 목록을 가져옵니다. |
| VaryByCustom |
출력 캐시에서 사용자 정의 컨트롤을 변경하기 위해 사용할 사용자 지정 문자열 목록을 가져옵니다. |
| VaryByParams |
출력 캐시가 사용자 컨트롤을 다양하게 하는 데 사용할 쿼리 문자열 또는 양식 |
메서드
| Name | Description |
|---|---|
| Equals(Object) |
이 인스턴스가 지정된 개체와 같은지 여부를 나타내는 값을 반환합니다. (다음에서 상속됨 Attribute) |
| GetHashCode() |
이 인스턴스의 해시 코드를 반환합니다. (다음에서 상속됨 Attribute) |
| GetType() |
현재 인스턴스의 Type 가져옵니다. (다음에서 상속됨 Object) |
| IsDefaultAttribute() |
파생 클래스에서 재정의되는 경우 이 인스턴스의 값이 파생 클래스의 기본값인지 여부를 나타냅니다. (다음에서 상속됨 Attribute) |
| Match(Object) |
파생 클래스에서 재정의되는 경우 이 인스턴스가 지정된 개체와 같은지 여부를 나타내는 값을 반환합니다. (다음에서 상속됨 Attribute) |
| MemberwiseClone() |
현재 Object단순 복사본을 만듭니다. (다음에서 상속됨 Object) |
| ToString() |
현재 개체를 나타내는 문자열을 반환합니다. (다음에서 상속됨 Object) |
명시적 인터페이스 구현
| Name | Description |
|---|---|
| _Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) |
이름 집합을 해당 디스패치 식별자 집합에 매핑합니다. (다음에서 상속됨 Attribute) |
| _Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) |
인터페이스의 형식 정보를 가져오는 데 사용할 수 있는 개체의 형식 정보를 검색합니다. (다음에서 상속됨 Attribute) |
| _Attribute.GetTypeInfoCount(UInt32) |
개체가 제공하는 형식 정보 인터페이스의 수를 검색합니다(0 또는 1). (다음에서 상속됨 Attribute) |
| _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) |
개체에 의해 노출되는 속성 및 메서드에 대한 액세스를 제공합니다. (다음에서 상속됨 Attribute) |