15.11.08

Chain of responsibility

This chain of resposibility is from a system that handles a variety of reporting requests. The inheriting handlers are Russian dolled(each handler knows its successor).

namespace Components.Reports.QueryHandlers
{
public abstract class ReportQueryHandler
{
protected ReportQueryHandler _reportHandlerSuccessor;
protected ReportType _reportRequest;

public ReportQueryHandler(ReportType reportType)
{
_reportRequest = reportType;
}

protected string LoadQuery(string queryFilePath)
{
if (!string.IsNullOrEmpty(queryFilePath))
return File.ReadAllText(queryFilePath);
else
throw new ArgumentNullException(queryFilePath);
}

public virtual void HandleReportRequest()
{
if (_reportHandlerSuccessor != null)
_reportHandlerSuccessor.HandleReportRequest();
}
}
}

No comments: