CachedDataItem 클래스

Visual Studio의 Office 개발 도구를 사용하여 만든 문서 수준 사용자 지정의 캐시된 데이터 개체를 나타냅니다.

상속 계층 구조

System.Object
  Microsoft.VisualStudio.Tools.Applications.CachedDataNodeBase
    Microsoft.VisualStudio.Tools.Applications.CachedDataItem

네임스페이스:  Microsoft.VisualStudio.Tools.Applications
어셈블리:  Microsoft.VisualStudio.Tools.Applications.ServerDocument(Microsoft.VisualStudio.Tools.Applications.ServerDocument.dll)

구문

‘선언
<PermissionSetAttribute(SecurityAction.Demand, Name := "FullTrust")> _
Public NotInheritable Class CachedDataItem _
    Inherits CachedDataNodeBase
[PermissionSetAttribute(SecurityAction.Demand, Name = "FullTrust")]
public sealed class CachedDataItem : CachedDataNodeBase

CachedDataItem 형식에서는 다음과 같은 멤버를 노출합니다.

속성

  이름 설명
Public 속성 DataType 캐시된 데이터 개체 형식의 어셈블리로 한정된 이름을 가져오거나 설정합니다.
Public 속성 Id CachedDataItem 이 나타내는 캐시된 데이터 개체의 이름을 가져오거나 설정합니다.
Public 속성 Schema 캐시된 데이터 개체가 DataSet 또는 DataTable인 경우 CachedDataItem이 나타내는 캐시된 데이터 개체를 설명하는 스키마를 가져오거나 설정합니다.
Public 속성 Xml CachedDataItem 으로 표시되는 캐시된 데이터 개체의 XML 표현을 가져오거나 설정합니다.

위쪽

메서드

  이름 설명
Public 메서드 Equals 지정한 Object가 현재 Object와 같은지 여부를 확인합니다. (Object에서 상속됨)
Protected 메서드 Finalize 가비지 수집에서 회수하기 전에 개체에서 리소스를 해제하고 다른 정리 작업을 수행할 수 있게 합니다. (Object에서 상속됨)
Public 메서드 GetHashCode 특정 형식에 대한 해시 함수 역할을 합니다. (Object에서 상속됨)
Public 메서드 GetType 현재 인스턴스의 Type을 가져옵니다. (Object에서 상속됨)
Protected 메서드 MemberwiseClone 현재 Object의 단순 복사본을 만듭니다. (Object에서 상속됨)
Public 메서드 SerializeDataInstance CachedDataItem 이 나타내는 캐시된 데이터 개체로 데이터를 serialize합니다.
Public 메서드 ToString 현재 개체를 나타내는 문자열을 반환합니다. (Object에서 상속됨)

위쪽

설명

문서 수준 사용자 지정에서의 데이터 캐시에 대한 자세한 내용은 데이터 캐싱서버에 있는 문서의 데이터 액세스를 참조하십시오.

예제

다음 코드 예제에서는 Excel 통합 문서의 데이터 캐시에서 각 CachedDataItem을 검사하고 캐시된 각 데이터 개체의 이름을 표시합니다.

이 예제에는 다음 사항이 필요합니다.

  • 콘솔 응용 프로그램 프로젝트 또는 다른 비 Office 프로젝트입니다.

  • 다음 어셈블리에 대한 참조:

    • Microsoft.VisualStudio.Tools.Applications.ServerDocument.dll 및 Microsoft.VisualStudio.Tools.Applications.Runtime.dll(.NET Framework 4를 대상으로 하는 프로젝트의 경우)

      또는

    • Microsoft.VisualStudio.Tools.Applications.ServerDocument.v10.0.dll 및 Microsoft.VisualStudio.Tools.Applications.Runtime.v9.0.dll(.NET Framework 3.5를 대상으로 하는 프로젝트의 경우)

  • 코드 파일 상단에 있는 Microsoft.VisualStudio.Tools.ApplicationsMicrosoft.VisualStudio.Tools.Applications.Runtime 네임스페이스에 대해 Imports(Visual Basic의 경우) 또는 using(C#의 경우) 문.

Private Sub DisplayDataCacheContents(ByVal documentPath As String)
    Dim runtimeVersion As Integer = 0
    Dim serverDocument1 As ServerDocument = Nothing

    Try
        runtimeVersion = ServerDocument.GetCustomizationVersion(documentPath)
        If runtimeVersion <> 3 Then
            MessageBox.Show("This document does not have a Visual Studio Tools for Office " & _
                "customization, or it has a customization that was created with a version of " & _
                "the runtime that is incompatible with this version of the ServerDocument class.")
            Return
        End If

        If ServerDocument.IsCacheEnabled(documentPath) Then
            serverDocument1 = New ServerDocument(documentPath)
            Dim stringBuilder1 As New System.Text.StringBuilder()

            ' Display all of the cached data items 
            ' in the document.
            Dim hostItem1 As CachedDataHostItem
            For Each hostItem1 In serverDocument1.CachedData.HostItems
                stringBuilder1.Append(vbLf & "Namespace and class: ")
                stringBuilder1.Append(hostItem1.Id & vbLf)
                Dim dataItem1 As CachedDataItem
                For Each dataItem1 In hostItem1.CachedData
                    stringBuilder1.Append("     Data item: ")
                    stringBuilder1.Append(dataItem1.Id & vbLf)
                Next dataItem1
            Next hostItem1
            MessageBox.Show(stringBuilder1.ToString())
        Else
            MessageBox.Show("The specified document does not have cached data.")
        End If

    Catch ex As System.IO.FileNotFoundException
        System.Windows.Forms.MessageBox.Show("The specified document does not exist.")
    Catch ex As UnknownCustomizationFileException
        System.Windows.Forms.MessageBox.Show("The specified document has a file " & _
            "extension that is not supported by Visual Studio Tools for Office.")
    Finally
        If Not (serverDocument1 Is Nothing) Then
            serverDocument1.Close()
        End If
    End Try
End Sub
private void DisplayDataCacheContents(string documentPath)
{
    int runtimeVersion = 0;
    ServerDocument serverDocument1 = null;

    try
    {
        runtimeVersion = ServerDocument.GetCustomizationVersion(documentPath);

        if (runtimeVersion != 3)
        {
            MessageBox.Show("This document does not have a Visual Studio Tools for " +
                "Office customization, or it has a customization that was created with " +
                "a version of the runtime that is incompatible with this version of the " +
                "ServerDocument class.");
            return;
        }

        if (ServerDocument.IsCacheEnabled(documentPath))
        {
            serverDocument1 = new ServerDocument(documentPath);
            System.Text.StringBuilder stringBuilder1 =
                new System.Text.StringBuilder();

            // Display all of the cached data items 
            // in the document.
            foreach (CachedDataHostItem hostItem1 in
                serverDocument1.CachedData.HostItems)
            {
                stringBuilder1.Append("\nNamespace and class: ");
                stringBuilder1.Append(hostItem1.Id + "\n");
                foreach (CachedDataItem dataItem1 in
                    hostItem1.CachedData)
                {
                    stringBuilder1.Append("     Data item: ");
                    stringBuilder1.Append(dataItem1.Id + "\n");
                }
            }
            MessageBox.Show(stringBuilder1.ToString());
        }
        else
        {
            MessageBox.Show("The specified document does not have cached data.");
        }
    }
    catch (System.IO.FileNotFoundException)
    {
        System.Windows.Forms.MessageBox.Show("The specified document does not exist.");
    }
    catch (UnknownCustomizationFileException)
    {
        System.Windows.Forms.MessageBox.Show("The specified document has a file " +
            "extension that is not supported by Visual Studio Tools for Office.");
    }
    finally
    {
        if (serverDocument1 != null)
            serverDocument1.Close();
    }
}

스레드로부터의 안전성

이 형식의 모든 공용 static(Visual Basic의 경우 Shared) 멤버는 스레드로부터 안전합니다. 인터페이스 멤버는 스레드로부터 안전하지 않습니다.

참고 항목

참조

Microsoft.VisualStudio.Tools.Applications 네임스페이스

기타 리소스

ServerDocument 클래스를 사용하여 서버의 문서 관리

데이터 캐싱

서버에 있는 문서의 데이터 액세스