//.NET Core 2.2
        //private readonly MvcJsonOptions _options;
        //public NewtonsoftNdjsonWriterFactory(IHttpResponseStreamWriterFactory httpResponseStreamWriterFactory, IOptions<MvcJsonOptions> options, ArrayPool<char> innerJsonArrayPool)
        //{
        //    _httpResponseStreamWriterFactory = httpResponseStreamWriterFactory ?? throw new ArgumentNullException(nameof(httpResponseStreamWriterFactory));
        //    _options = options?.Value ?? throw new ArgumentNullException(nameof(options));

        //    if (innerJsonArrayPool == null)
        //    {
        //        throw new ArgumentNullException(nameof(innerJsonArrayPool));
        //    }

        //    _jsonArrayPool = new NewtonsoftNdjsonArrayPool(innerJsonArrayPool);
        //}
        public INdjsonWriter CreateWriter(ActionContext context, NdjsonStreamResult result)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            if (result == null)
            {
                throw new ArgumentNullException(nameof(result));
            }

            HttpResponse response = context.HttpContext.Response;

            response.ContentType = CONTENT_TYPE;

            if (result.StatusCode != null)
            {
                response.StatusCode = result.StatusCode.Value;
            }

            DisableResponseBuffering(context.HttpContext);

            return(new NewtonsoftNdjsonWriter(_httpResponseStreamWriterFactory.CreateWriter(response.Body, Encoding.UTF8), _options.SerializerSettings, _jsonArrayPool));
        }
        public INdjsonWriter CreateWriter(ActionContext context, NdjsonStreamResult result)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            if (result == null)
            {
                throw new ArgumentNullException(nameof(result));
            }

            HttpResponse response = context.HttpContext.Response;

            response.ContentType = CONTENT_TYPE;

            if (result.StatusCode != null)
            {
                response.StatusCode = result.StatusCode.Value;
            }

            DisableResponseBuffering(context.HttpContext);

            return(new NdjsonWriter(response.Body, null));
        }