Windows Workflow 4.0 中特定于文化的 XAML 工作流
我创建了一个简单的 XAML 工作流程,其中包含一个默认值为 1.234 的 InArgument。如果我随后在“区域和语言选项”中将计算机切换为法语(法国)并尝试将工作流程加载到 VS 设计视图中,则会收到错误:
“无法从文本“1.234”创建“InArgument”。”
查看 XAML,我可以看到属性 this:Activity1.arg1="1.234",这导致了问题。然后,我尝试使用 VS 从头开始创建等效的 XAML 工作流程,同时仍在法语设置下运行,并且生成的 XAML 不同 - 属性是这样的:Activity1.arg1="[1.234]"。
这给我带来了两个问题:
1)我们的最终用户将无法将 XAML 文件发送给在不同区域设置下运行的其他用户
2)这两个 XAML 文件反序列化为不同的对象图 - 在第一种情况下,我最终得到了一个 Literal在第二种情况下,我得到一个 VisualBasicValue。然后,当我以编程方式操作工作流程时,我需要围绕差异进行编码。
是否有一些简单的方法可以通过确保 XAML 始终在中立文化中写入/读取来避免这种情况?
I've created a simple XAML workflow with a single InArgument with a default value of 1.234. If I then switch my machine to French(France) in Regional and Lanaguage Options and try to load the workflow into the VS design view, I get the error:
'Failed to create a 'InArgument' from the text '1.234'.'
Looking at the XAML I can see that the attribute this:Activity1.arg1="1.234", which is causing the problem. I then tried creating an equivalent XAML workflow from scratch using VS whilst still running under French settings, and the resulting XAML is different - the attribute is this:Activity1.arg1="[1.234]".
This is causing me two problems:
1) Our end users will not be able to send XAML files to other users running under different regional settings
2) The two XAML files deserialise to different object graphs - in the first case I end up with a Literal and in the second case I get a VisualBasicValue. I then need to code around the differences when I am manipulating the workflow programmatically.
Is there some simple way to avoid this by ensuring that the XAML is always written/read in a neutral culture?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以通过编程方式将 Thread.CurrentCulture 更改为不变的文化。这可以在加载工作流程时临时完成。
You can programatically change the Thread.CurrentCulture to the invariant culture. This can be done temporarily, while the workflow is being loaded.