How do I ignore properties when using RestSharp serialization

∥☆過路亽.° 提交于 2019-12-08 11:09:28

问题


I was looking for something like this:

...
public string FirstName { get; set; }
public string LastName { get; set; }

[Ignore]
public string FullName { get { return FirstName + " " + LastName; } }
...

But, can't seem to dig anything up.

Environment: Xamarin Studio, C#, Android Project running on Mac


回答1:


This is dependant on which serializer you are using:

  • For the JsonSerializer, use [ScriptIgnore].
  • For the DotNetXmlSerializer, use [System.Xml.Serialization.XmlIgnore].

I can't answer with certainty what attribute should be used when you use XmlSerializer but I would suspect it should be either [NonSerialized], [ScriptIgnore] or [XmlIgnore].

Documentation:

  • ScriptIgnore.
  • NonSerialized.
  • XmlIgnore.


来源:https://stackoverflow.com/questions/19802479/how-do-i-ignore-properties-when-using-restsharp-serialization

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!