What exactly is a Package Relationship (ZipPackage) in .NET? I know what a Package is but I'm having trouble understanding the purpose of relationships. Could you give examples of when I would want to use them and what they are good for?
From MSDN (Package Class):
Package is an abstract class that can be used to organize objects into a single entity of a defined physical format for portability and efficient access.
And:
A PackageRelationship ("relationship") defines an association between a source Package or PackagePart and a target object. A PackageRelationship can be one of two types, each of which can be one of two forms:
* A package-level relationship (created by the Package.CreateRelationship method) relates a Package to either:
o A target part in the package.
o A target resource outside the package.
* A part-level relationship (created by the PackagePart.CreateRelationship method) relates a source PackagePart to either:
o Another target part in the package.
o A target resource outside the package.
So, when creating a Package
, if you want to indicate that there is a relationship between an object to another part of the package, you should use a PackageRelationship
to indicate what kind of relationship it is.
A ZipPackage
can also be used to work with Open Office XML files - in this use case, it is sometime useful to indicate relationships of objects to each other. See here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With