2015-02-09 91 views
0

我正在使用Refit庫來訪問我的API。這是工作相當不錯,但我有一些問題使用我的網址中的枚舉列表。使用Refit轉換url參數

[Get("/track/")] 
Task<IList<Track>> GetAll(int size = 20, int from = 0, [AliasAs("content-types")] IEnumerable<TrackSubType> contentTypes = null, IEnumerable<string> tags = null, string language = null); 

了IEnumerable CONTENTTYPES目前轉換爲:

https://website.com/track/?content-type=System.Collections.Generic.List`1[Api.Implementation.Models.TrackSubType] 

我想擁有它的格式爲:

https://website.com/track/?content-type[]=sometype 

我怎樣才能做到這一點?

回答

1

我相信默認情況下Refit會在您的列表中使用ToString來創建查詢參數值。您可以創建自己的繼承自列表的類並重寫ToString方法以實現等號右側的所需。我不確定爲什麼你不能使用aliasas屬性添加方括號。