为JsonOutputFormatter构造函数提供ArrayPool对象从.netRC2升级到RTM后,发现需要为派生自ArrayPool的JsonOutputFormatter的构造函数提供参数。我如何获得这个对象?我正在手动创建JsonOutputFormatter,因为我需要配置ReferenceLoopHandling。我能找到的其他相关信息是:https://github.com/aspnet/Mvc/issues/4562publicIServiceProviderConfigureServices(IServiceCollectionservices){//添加框架services.services.AddMemoryCache();服务.AddSession();服务.AddMvc();varformatterSettings=JsonSerializerSettingsProvider.CreateSerializerSettings();formatterSettings.ReferenceLoopHandling=Newtonsoft.Json.ReferenceLoopHandling.Ignore;JsonOutputFormatterformatter=newJsonOutputFormatter(formatterSettings,???);options.OutputFormatters.RemoveType();options.OutputFormatters.Insert(0,格式化程序);});//等等...}varformatter=newJsonOutputFormatter(formatterSettings,ArrayPool.Shared);源码在注释:JsonOutputFormatteriscreated当需要ArrayPool时,可以传入ArrayPool.Shared。我还注意到ArrayPool上有一个.Create()方法。以上就是C#学习教程:提供ArrayPool对象给JsonOutputFormatter构造函数,分享全部内容。如果对大家有用,需要进一步了解C#学习教程,希望大家多多关注——varformatter=newJsonOutputFormatter(formatterSettings,ArrayPool.Create());本文收集自网络,不代表立场。如涉及侵权,请点击右侧联系管理员删除。如需转载请注明出处:
