Svg.Web.SvgHandler.SvgAsyncRender.RenderSvg C# (CSharp) Method

RenderSvg() public method

public RenderSvg ( ) : void
return void
            public void RenderSvg()
            {
                this._state._context.Response.AddFileDependency(this._state._context.Request.PhysicalPath);
                this._state._context.Response.Cache.SetLastModifiedFromFileDependencies();
                this._state._context.Response.Cache.SetETagFromFileDependencies();
                this._state._context.Response.Buffer = false;

                // Allow crawlers to see the raw XML - they can get more information from it that way
                if (this._state._context.Request.Browser.Crawler || !string.IsNullOrEmpty(this._state._context.Request.QueryString["raw"]))
                {
                    this.RenderRawSvg();
                }
                else
                {
                    try
                    {
                        Dictionary<string, string> entities = new Dictionary<string, string>();
                        NameValueCollection queryString = this._state._context.Request.QueryString;

                        for (int i = 0; i < queryString.Count; i++)
                        {
                            entities.Add(queryString.Keys[i], queryString[i]);
                        }

                        SvgDocument document = SvgDocument.Open<SvgDocument>(this._state._context.Request.PhysicalPath, entities);

                        using (Bitmap bitmap = document.Draw())
                        {
                            using (MemoryStream ms = new MemoryStream())
                            {
                                bitmap.Save(ms, ImageFormat.Png);
                                this._state._context.Response.ContentType = "image/png";
                                ms.WriteTo(this._state._context.Response.OutputStream);
                            }
                        }
                    }
                    catch (Exception exc)
                    {
                        System.Diagnostics.Trace.TraceError("An error occured while attempting to render the SVG image '" + this._state._context.Request.PhysicalPath + "': " + exc.Message);
                    }
                    finally
                    {
                        this._state._context.Response.End();
                        this._state.CompleteRequest();
                    }
                }
            }
        }