[英]Does GenerateScriptType support NonSerialized?
I have an object that's used both on the client and server side. 我有一个在客户端和服务器端都使用的对象。
GenerateScriptType(typeof(MyClass))
However, there are some fields that I don't need on the client, so my question is there any way to prevent those fields being serialized? 但是,客户端上不需要一些字段,所以我的问题是有什么办法防止这些字段被序列化? (For example, Field2 and Field3 in MyClass)
(例如,MyClass中的Field2和Field3)
I tried marking the fields with [NonSerialized] but they still get serialized... 我尝试用[NonSerialized]标记字段,但它们仍然被序列化...
public class MyClass
{
public string Field1;
public string Field2
{
get;
set;
}
private string _field3;
public string Field3
{
get
{
return _field3 ?? (_field3 = "lala");
}
}
}
Regards, 问候,
尝试添加ScriptIgnore属性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.