简体   繁体   English

如何使用powerShell保存c#应用程序的状态?

[英]how to Save the State of an c# App with powerShell?

I have a C# program in which the user adds multiple objects an editing Panel. 我有一个C#程序,其中用户在编辑面板中添加了多个对象。 These objects are all represented as a classes. 这些对象都表示为一个类。 Now I want the user to be able to save the scenario, so it can be loaded again. 现在,我希望用户能够保存场景,以便可以再次加载它。

for that I want to generate a Powershell script of each scénario , but my probléme is how to save diferent objects on Powershell , i tried to use serialization with XMLSerializer but I fail ,because i use a lot of dependant object who has Dictionaries and ListBoxs . 为此,我想生成每个场景的Powershell脚本,但是我的问题是如何在Powershell上保存不同的对象,我尝试将XMLSerializer与序列化一起使用,但是由于我使用了很多具有Dictionary和ListBoxs的依赖对象而失败了。

Is there some genereic save method I can use? 我可以使用一些通用的保存方法吗? Can you help me? 你能帮助我吗?

Finally, I stored on a PowerShell Script at each time the right properties of the GUI object. 最后,我每次都在PowerShell脚本中存储GUI对象的正确属性。 When I want to load my stored object, I replay the last sequence directly on PowerShell. 当我想加载存储的对象时,可以直接在PowerShell上重播最后一个序列。

PowerShell has its own object serializer in the cmdlets Export-Clixml and Import-Clixml . PowerShell在cmdlet Export-ClixmlImport-Clixml中具有自己的对象序列化程序

Get-Help Export-Clixml -Full | more Get-Help Export-Clixml -Full | more for details... Get-Help Export-Clixml -Full | more详细信息...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM