7
從.net RC2升級到RTM後,我發現需要爲從ArrayPool派生的JsonOutputFormatter構造函數提供參數。我如何獲得這個對象?我手動新建JsonOutputFormatter,因爲我需要配置ReferenceLoopHandling。將ArrayPool對象提供給JsonOutputFormatter構造函數
只有等相關信息,我能找到的是這樣的: https://github.com/aspnet/Mvc/issues/4562
public IServiceProvider ConfigureServices(IServiceCollection services)
{
// Add framework services.
services.AddMemoryCache();
services.AddSession();
services.AddMvc();
var formatterSettings = JsonSerializerSettingsProvider.CreateSerializerSettings();
formatterSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;
JsonOutputFormatter formatter = new JsonOutputFormatter(formatterSettings, ???);
services.Configure<MvcOptions>(options =>
{
options.OutputFormatters.RemoveType<JsonOutputFormatter>();
options.OutputFormatters.Insert(0, formatter);
});
//etc...
}