タイプ T の JSON シリアライズ/デシリアライズをサポートする Web API 呼び出しを行う便利なクラスを見つけました。ここでクラス/記事全体を表示できます。このクラスは大いに活用できると思うので、試してみたいと思います。処理方法がわからないエラーが 1 つ残っています。次のルーチンにあります。
protected HttpRequestMessage GetHttpRequestMessage<T>(T data)
{
MediaTypeHeaderValue mediaType = new MediaTypeHeaderValue("application/json");
JsonSerializerSettings jsonSerializerSettings = new JsonSerializerSettings();
jsonSerializerSettings.Converters.Add(new IsoDateTimeConverter());
JsonNetFormatter jsonFormatter = new JsonNetFormatter(jsonSerializerSettings);
HttpRequestMessage requestMessage = new HttpRequestMessage<T>(data, mediaType, new MediaTypeFormatter[] { jsonFormatter });
return requestMessage;
}
私が得ているエラーは次のとおりです。
Error 3 The non-generic type 'System.Net.Http.HttpRequestMessage'
cannot be used with type arguments.
HttpRequestMessage<T>
赤い波線で下線が引かれているところ。
このクラスの一般的な有用性を損なわないように、このルーチン/コード行をどのように書き直せばよいでしょうか?