简体   繁体   English

在Noesis Javascript.net中保存上下文状态

[英]Save context state in Noesis Javascript.net

I'm using the noesis javascript.net library in my C# MVC3 application. 我在我的C#MVC3应用程序中使用noesis javascript.net库

Is it possible to save a snapshot of a javascript context object and then reload that snapshot into a new javascript context instance? 是否可以保存javascript上下文对象的快照,然后将该快照重新加载到新的javascript上下文实例中?

Not sure if the original user will find this useful but I achieved this by adding a object to my context that let me write to disk (simple wrapper around TextWriter), then serialized this where this was the global scope so it captured all objects. 不知道如果原来的用户会发现这个有用的,但我通过添加对象到我的背景下,让我写磁盘(约TextWriter的简单包装)来实现这一点,那么连载this地方this是全球范围内,因此拍摄的所有对象。 The obvious pitfall is that not all objects are serialized proper (I used JSON.stringify for serialization). 明显的缺陷是并非所有对象都是正确序列化的(我使用JSON.stringify进行序列化)。 When I need to reload the context I loaded up the string from the file into a variable in my context and set the objects back. 当我需要重新加载上下文时,我将文件中的字符串加载到我的上下文中的变量中并将对象设置回来。

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

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