Package.GetRelationshipsByType(String) 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
지정된 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
컬렉션에서 일치하고 반환할 RelationshipType입니다.
반환
지정된 relationshipType
에 일치하는 패키지 수준 관계의 컬렉션입니다.
예외
relationshipType
이(가) null
인 경우
relationshipType
이 빈 문자열인 경우
패키지가 열려 있지 않은 경우(Dispose(Boolean) 또는 Close()가 호출된 경우)
패키지가 쓰기 전용인 경우
예제
다음 예제에서는 패키지에 대해 정의된 관계를 검색하는 방법을 보여줍니다.
// 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
컬렉션에 요소가 0개 포함될 수 있습니다.
다음 표에서는 OPC(Open Packaging Conventions) 사양에 정의된 패키지 수준 relationshipType
URI를 보여 줍니다.
패키지 수준 관계 | 관계 유형 URI |
---|---|
핵심 속성 | http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties |
디지털 서명 | http://schemas.openxmlformats.org/package/2006/relationships/digital-signature/signature |
디지털 서명 인증서 | http://schemas.openxmlformats.org/package/2006/relationships/digital-signature/certificate |
디지털 서명 원본 | http://schemas.openxmlformats.org/package/2006/relationships/digital-signature/origin |
미리 보기 | http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail |
자세한 내용은 에서 https://www.ecma-international.org/publications-and-standards/standards/ecma-376/다운로드할 수 있는 OPC(Open Packaging Conventions) 사양을 참조하세요.
적용 대상
추가 정보
.NET