void IHttpHandler.ProcessRequest(HttpContext context)
{
int bufferSize = 256;
byte[] buffer = new byte[bufferSize];
Stream imageStream;
if (context.Request.QueryString["NodeProperty"] != null)
{
string propertyName = context.Request.QueryString["NodeProperty"].Replace("$", "#");
var property = this.PropertyTypes[propertyName];
if (property != null && property.DataType == DataType.Binary)
imageStream = this.GetBinary(property).GetStream();
else
imageStream = this.Binary.GetStream();
}
else if (context.Request.QueryString["dynamicThumbnail"] != null && context.Request.QueryString["width"] != null && context.Request.QueryString["height"] != null)
{
int width;
int height;
if (!int.TryParse(context.Request.QueryString["width"], out width))
width = 200;
if (!int.TryParse(context.Request.QueryString["height"], out height))
height = 200;
imageStream = this.GetDynamicThumbnailStream(width, height, this.ContentType);
}
else
{
imageStream = Binary.GetStream();
}
imageStream.Position = 0;
context.Response.ContentType = this.ContentType;
int bytesRead = imageStream.Read(buffer, 0, bufferSize);
while (bytesRead > 0)
{
context.Response.OutputStream.Write(buffer, 0, bytesRead);
bytesRead = imageStream.Read(buffer, 0, bufferSize);
}
context.Response.OutputStream.Flush();
}
}