.NET 中包关系的目的是什么?
.NET 中的包关系 (ZipPackage) 到底是什么?我知道什么是包,但我无法理解关系的目的。您能否举例说明我何时想要使用它们以及它们的用途?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
来自 MSDN (包类):
和:
因此,在创建
Package
时,如果您想表明一个对象与该对象的另一部分之间存在关系,对于包,您应该使用PackageRelationship
来指示它是什么类型的关系。ZipPackage
还可用于处理 Open Office XML 文件 - 在此用例中,有时指示对象之间的关系很有用。请参阅此处。From MSDN (Package Class):
And:
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 aPackageRelationship
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.基本上,它是将事物连接在一起,以便部署它们,更重要的是同时取消部署。
举例来说,您有一个程序,并且有一个它使用的 GIF 包。然后,您希望 GIF 在安装程序时可用,并且希望在卸载程序时清理它们。
Basically it is to connect things together so that they are deployed, and more importantly un-deployed at the same time.
Say for example you have a program and you have a package of GIFs that it uses. Then you want the GIFs to be available when your program is installed, and you want them to be cleaned up when the program is uninstalled.
在我看来,好的例子都是 使用 OPC 的文件格式
以及用于 opc 容器的 C# 示例带有预览图像的功能将被实现 fe:
并且要将您的 png 转换为字节数组,您可以执行 this
因此,好处是,您可以随后使用定义的关系 ID (="preview") 来访问您的预览图像一个opc容器
In my opinion good examples are all file formats using OPC
And an example in c# for an opc container with an preview image would be implemented f.e.:
And to convert your png to an byte array you could do this
So the benefit would be, you could afterwards use your defined Relationship-Id (="preview") to access your previewImage in an opc container