Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the purpose of Package Relationships in .NET?

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?

like image 252
Andreas Zita Avatar asked Dec 12 '10 15:12

Andreas Zita


1 Answers

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.

like image 161
Oded Avatar answered Oct 08 '22 03:10

Oded