Wix:将分号设置为 CustomActionData
我在将包含分号的数据设置为 CustomActionData 属性时遇到问题。 默认情况下,CustomActionData 类使用分号作为 DataSeparator,当它包含分号时,它会破坏我的数据。 除了用 come 关键字替换它们之外,还有什么方法可以在 CustomActionData 中添加分号?
I have a problem with setting data that contains semicolons to CustomActionData property.
By default CustomActionData class uses semicolon as DataSeparator and it breaks my data, when it contains semicolons.
Is there any way to put semicolons to CustomActionData except of replacing them by come keyword?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
要在 CustomActionData 中传递分号,您应该再添加一个分号。
示例:
CustomActionData="key1=value1;key2=value2.1;;value2.2;;value2.3" - 这将传递 key1=value1 和 key2=value2.1;value2.2; value2.3
如果您不知道分号在哪里,那么我想您可以通过用两个分号替换每个分号来创建转义它们的方法。
如果有更多符号您不知道如何转义,您可以轻松找到创建一个简单的应用程序,该应用程序创建 CustomActionData 实例,添加键值对并使用 ToString() 输出 CustomActionData 字符串表示形式。
示例:
我希望这些信息对您有所帮助。
to pass a semicolon in your CustomActionData you should add one more semicolon.
Example:
CustomActionData="key1=value1;key2=value2.1;;value2.2;;value2.3" - this will pass key1=value1 and key2=value2.1;value2.2;value2.3
If you don't know where the semicolons are then I guess you can create method that escapes them by replacing each semicolon with two semicolon.
If there are more symbols that you don't know how to escape you easily find out creating a simple app that creates a CustomActionData instance, adds a key-value pair and outputs the CustomActionData string representation using ToString().
Example:
I hope the information is helpful.
早在 2006 年,我就写了一篇博客文章和示例项目:
InstallScript,满足 CustomActionData< /a>
基本上我使用了以下模式: /KEY1=VALUE1 /KEY2=VALUE2
该库通过调用查找函数并将其传递给“/KEY1=”来工作。然后它返回所有数据,直到下一个“/”为止。
不管怎样,自从我转向 C# DTF 以来,我已经不再使用它了,它有一个 CustomActionData 类为我处理序列化/反序列化。
Back in 2006 I wrote a blog article and sample project:
InstallScript, meet CustomActionData
Basically I used the pattern: /KEY1=VALUE1 /KEY2=VALUE2
The library worked by calling a lookup function passing it "/KEY1=". It then returned all data until the end of until the next " /".
Regardless I don't really use this much any more since I've moved onto C# DTF which has a CustomActionData class handles the derialization/deserialization for me.
JSON 字符串:Chris Painter - 他也用旧方法回答了这个问题 - 有一篇博客文章彻底改变了
CustomActionData
使用JSON 字符串
进行处理。现在只要使用正确的 JSON 库,就不需要进行字符串解析。内置序列化/反序列化: http ://blog.iswix.com/2011/10/beam-me-up-using-json-to-serialize.html。技术上:技术细节会因语言而异,但 JSON 字符串本身很简单:
您可以在延迟模式下复活对象! 只需调用
Serialize
和Deserialize
即可。JSON Strings: Chris Painter - who has also answered this question with an older approach - has a blog entry that revolutionizes
CustomActionData
handling by usingJSON strings
. Now there is no string parsing to do, so far as you use a proper JSON library. Built-in serialization / deserialization: http://blog.iswix.com/2011/10/beam-me-up-using-json-to-serialize.html.Technically: The technical nitty-gritties would be different depending on language, but JSON strings themselves are simple:
You can resurrect an object in deferred mode! Just by calling
Serialize
andDeserialize
.