private void context_BeginRequest(object sender, EventArgs e) { if (Config.Enabled) { _validExtension = IsValidExtenstion(); if (_validExtension) { _decoratorStream = new CaptureStream(_application.Response.Filter); _application.Response.Filter = _decoratorStream; // setup the specified implementation of renderer, default to // HTML so it is clearly seen and not left on by accident. switch (Config.Mode) { case Mode.Custom: SetupCustomRenderer(); break; case Mode.Comments: _renderer = new InlineCommentRenderer(); break; case Mode.HtmlFloat: _renderer = new FloatingHtmlRenderer(); break; default: // default to HTML _renderer = new InlineHtmlRenderer(); break; } } } }
private void SetupCustomRenderer() { if (String.IsNullOrEmpty(Config.CustomRenderer)) { throw new ArgumentException("In Custom mode a customRenderer type must be specified"); } Type rendererType = Type.GetType(Config.CustomRenderer, true); _renderer = Activator.CreateInstance(rendererType) as IValidationRenderer; // If the renderer is null then it's not of the correct type if (_renderer == null) { throw new ArgumentException(string.Format( "The specified custom renderer type '{0}' must implement the '{1}' interface", Config.CustomRenderer, typeof(IValidationRenderer).FullName)); } }