Package.GetRelationshipsByType(String) Package.GetRelationshipsByType(String) Package.GetRelationshipsByType(String) Package.GetRelationshipsByType(String) Method

정의

지정된 RelationshipType에 일치하는 모든 패키지 수준 관계의 컬렉션을 반환합니다.Returns a collection of all the package-level relationships that match a given RelationshipType.

public:
 System::IO::Packaging::PackageRelationshipCollection ^ GetRelationshipsByType(System::String ^ relationshipType);
public System.IO.Packaging.PackageRelationshipCollection GetRelationshipsByType (string relationshipType);
member this.GetRelationshipsByType : string -> System.IO.Packaging.PackageRelationshipCollection
Public Function GetRelationshipsByType (relationshipType As String) As PackageRelationshipCollection

매개 변수

relationshipType
String String String String

컬렉션에서 일치하고 반환할 RelationshipType입니다.The RelationshipType to match and return in the collection.

반환

지정된 relationshipType에 일치하는 패키지 수준 관계의 컬렉션입니다.A collection of package-level relationships that match the specified relationshipType.

예외

relationshipTypenull입니다.relationshipType is null.

relationshipType이 빈 문자열인 경우relationshipType is an empty string.

패키지가 열려 있지 않은 경우(Dispose(Boolean) 또는 Close()가 호출된 경우)The package is not open (Dispose(Boolean) or Close() has been called).

패키지가 쓰기 전용인 경우The package is write-only.

예제

다음 예제에서는 패키지에 대해 정의 된 관계를 검색 하는 방법을 보여 줍니다.The following example shows how to retrieve the relationships that have been defined for the package. 전체 샘플을 참조 하세요 는 패키지 예제 추가 정보를 읽는합니다.For the complete sample, see Reading a Package Sample.

// Open the Package.
// ('using' statement insures that 'package' is
//  closed and disposed when it goes out of scope.)
using (Package package =
    Package.Open(packagePath, FileMode.Open, FileAccess.Read))
{
    PackagePart documentPart = null;
    PackagePart resourcePart = null;

    // Get the Package Relationships and look for
    //   the Document part based on the RelationshipType
    Uri uriDocumentTarget = null;
    foreach (PackageRelationship relationship in
        package.GetRelationshipsByType(PackageRelationshipType))
    {
        // Resolve the Relationship Target Uri
        //   so the Document Part can be retrieved.
        uriDocumentTarget = PackUriHelper.ResolvePartUri(
            new Uri("/", UriKind.Relative), relationship.TargetUri);

        // Open the Document Part, write the contents to a file.
        documentPart = package.GetPart(uriDocumentTarget);
        ExtractPart(documentPart, targetDirectory);
    }

    // Get the Document part's Relationships,
    //   and look for required resources.
    Uri uriResourceTarget = null;
    foreach (PackageRelationship relationship in
        documentPart.GetRelationshipsByType(
                                ResourceRelationshipType))
    {
        // Resolve the Relationship Target Uri
        //   so the Resource Part can be retrieved.
        uriResourceTarget = PackUriHelper.ResolvePartUri(
            documentPart.Uri, relationship.TargetUri);

        // Open the Resource Part and write the contents to a file.
        resourcePart = package.GetPart(uriResourceTarget);
        ExtractPart(resourcePart, targetDirectory);
    }

}// end:using(Package package) - Close & dispose package.
' Open the Package.
' ('using' statement insures that 'package' is
'  closed and disposed when it goes out of scope.)
Using package As Package = Package.Open(packagePath, FileMode.Open, FileAccess.Read)
	Dim documentPart As PackagePart = Nothing
	Dim resourcePart As PackagePart = Nothing

	' Get the Package Relationships and look for
	'   the Document part based on the RelationshipType
	Dim uriDocumentTarget As Uri = Nothing
	For Each relationship As PackageRelationship In package.GetRelationshipsByType(PackageRelationshipType)
		' Resolve the Relationship Target Uri
		'   so the Document Part can be retrieved.
		uriDocumentTarget = PackUriHelper.ResolvePartUri(New Uri("/", UriKind.Relative), relationship.TargetUri)

		' Open the Document Part, write the contents to a file.
		documentPart = package.GetPart(uriDocumentTarget)
		ExtractPart(documentPart, targetDirectory)
	Next relationship

	' Get the Document part's Relationships,
	'   and look for required resources.
	Dim uriResourceTarget As Uri = Nothing
	For Each relationship As PackageRelationship In documentPart.GetRelationshipsByType(ResourceRelationshipType)
		' Resolve the Relationship Target Uri
		'   so the Resource Part can be retrieved.
		uriResourceTarget = PackUriHelper.ResolvePartUri(documentPart.Uri, relationship.TargetUri)

		' Open the Resource Part and write the contents to a file.
		resourcePart = package.GetPart(uriResourceTarget)
		ExtractPart(resourcePart, targetDirectory)
	Next relationship

End Using ' end:using(Package package) - Close & dispose package.

설명

GetRelationships 반환 하지 것입니다 null그러나 반환 된 컬렉션에 지정 된 일치 하는 패키지 수준 관계가 없는 경우 요소가 포함 될 수 있습니다 relationshipType합니다.GetRelationships will never return null; however the returned collection may contain zero elements if there are no package-level relationships that match the specified relationshipType.

다음 표에서 패키지 수준 relationshipType OPC Open Packaging Conventions () 사양에 정의 된 Uri입니다.The following table shows the package-level relationshipType URIs defined by the Open Packaging Conventions (OPC) specification.

패키지 수준 관계Package-level Relationship 관계 유형 URIRelationship Type URI
핵심 속성Core Properties http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties
디지털 서명Digital Signature http://schemas.openxmlformats.org/package/2006/relationships/digital-signature/signature
디지털 서명 인증서Digital Signature Certificate http://schemas.openxmlformats.org/package/2006/relationships/digital-signature/certificate
디지털 서명 원본Digital Signature Origin http://schemas.openxmlformats.org/package/2006/relationships/digital-signature/origin
미리 보기Thumbnail http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail

자세한 내용은에서 다운로드할 수 있는 OPC Open Packaging Conventions () 사양을 참조 https://go.microsoft.com/fwlink/?LinkID=71255합니다.For additional information, see the Open Packaging Conventions (OPC) specification available for download at https://go.microsoft.com/fwlink/?LinkID=71255.

적용 대상

추가 정보