如何使用RestSharp系列化,当我忽略的属性 [英] How do I ignore properties when using RestSharp serialization

查看:423
本文介绍了如何使用RestSharp系列化,当我忽略的属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找这样的事情:

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.

环境:Xamarin Studio中,C#,Android项目上的Mac上运行

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

推荐答案

这是依赖于该序列化器使用的是:

This is dependant on which serializer you are using:


  • 对于 JsonSerializer ,使用 [ScriptIgnore]

  • 对于<一个href=\"https://github.com/restsharp/RestSharp/blob/master/RestSharp/Serializers/DotNetXmlSerializer.cs\"相对=nofollow> DotNetXmlSerializer ,使用 [System.Xml.Serialization.XmlIgnore]

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

我不能肯定,当你使用的 XmlSerializer的但我怀疑它应该是 [非序列化] [ScriptIgnore] [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].

文件:

  • ScriptIgnore.
  • NonSerialized.
  • XmlIgnore.

这篇关于如何使用RestSharp系列化,当我忽略的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆