Asp.net web api 将RestSharp格式化程序与Web API结合使用

Asp.net web api 将RestSharp格式化程序与Web API结合使用,asp.net-web-api,restsharp,Asp.net Web Api,Restsharp,关于堆栈溢出问题,建议使用RestSharp XML序列化程序将数据序列化为从ASP.NET Web API输出的XML: GlobalConfiguration.Configuration.Formatters.XmlFormatter = //RestSharp XML serializer here 这个表达式的右边应该是什么 我还尝试了GlobalConfiguration.Configuration.Formatters.XmlFormatter.SetSerializer,但1)它

关于堆栈溢出问题,建议使用RestSharp XML序列化程序将数据序列化为从ASP.NET Web API输出的XML:

GlobalConfiguration.Configuration.Formatters.XmlFormatter = //RestSharp XML serializer here
这个表达式的右边应该是什么

我还尝试了
GlobalConfiguration.Configuration.Formatters.XmlFormatter.SetSerializer
,但1)它需要一个泛型参数,我希望它适用于所有情况,2)它无法从“RestSharp.Serializers.XmlSerializer”转换为“System.Xml.Serialization.XmlSerializer”

我正在尝试将一个具有IList作为参数的对象序列化为XML,我知道ASP.NET附带的XML序列化程序无法处理此问题,所以我想我应该尝试RestSharp序列化程序

编辑:

我要序列化的类如下所示:

        public class Bar
        {
        }

        public class Foo
        {
            public virtual IList<Bar> Bars { get; set; }
        }
公共类栏
{
}
公开课Foo
{
公共虚拟IList条{get;set;}
}

谢谢

你能和我分享一下你的类型吗?@Kiran Challa:抱歉,等了这么久。我已经发布了一个例子。