方法は簡単で、HogeOperation<TResult> クラスが行っていた戻り値をフィールドに保持する処理を、各処理クラスが直接行えば良いだけ。
GetFugasOperation クラス
internal sealed class GetFugasOperation : HogeOperation
{
public GetFugasOperation(HogeService service)
: base(service)
{
}
private IList<Fuga> _result;
public IList<Fuga> Execute()
{
this.Processing();
return this._result;
}
protected override void MainProcessing()
{
this._result = this._service.GetFugas();
}
}
GetFugaOperation クラス
internal sealed class GetFugaOperation : HogeOperation
{
public GetFugaOperation(HogeService service)
: base(service)
{
}
private int _id;
private Fuga _result;
public Fuga Execute(int id)
{
this._id = id;
this.Processing();
return this._result;
}
protected override void MainProcessing()
{
var findFugaById =
from fuga in this._service.GetFugas()
where (fuga.Id == this._id)
select fuga;
this._result = findFugaById.Single();
}
}
どうせ引数は各処理クラスでフィールド化しなきゃいけないのだから、戻り値も各処理クラスでフィールド化した方が自然な気がする。
トラックバックURL↓
http://csharper.blog57.fc2.com/tb.php/231-aa123409