public void WriteTo(object entity, IHttpEntity response, string[] codecParameters) { // The default webforms renderer only associate the last parameter in the codecParameters // with a page that has been defined in the rendererParameters. var codecParameterList = new List <string>(codecParameters); if (!string.IsNullOrEmpty(_request.UriName)) { codecParameterList.Add(_request.UriName); } string templateAddress = GetViewVPath(_configuration, codecParameterList.ToArray(), _request.UriName); var type = _buildManager.GetCompiledType(templateAddress); var renderTarget = DependencyManager.GetService(type) as RazorViewBase; if (renderTarget == null) { throw new InvalidOperationException("View page doesn't inherit from RazorViewBase"); } renderTarget.SetResource(entity); renderTarget.Errors = response.Errors; RenderTarget(response, renderTarget); }
private Type GetAndCheckCompiledType <T> (string virtualPath) { var compiledType = _buildManager.GetCompiledType(virtualPath); if (compiledType == null) { throw new InvalidOperationException(string.Format("Web service '{0}' could not be compiled.", virtualPath)); } if (!typeof(T).IsAssignableFrom(compiledType)) { var message = typeof(T).IsInterface ? "Web service '{0}' does not implement mandatory interface '{1}'." : "Web service '{0}' is not based on type '{1}'."; throw new ArgumentException(string.Format(message, virtualPath, typeof(T).FullName)); } return(compiledType); }
public Type GetCompiledType(string virtualPath) { ArgumentUtility.CheckNotNullOrEmpty("virtualPath", virtualPath); return(_innerBuildManager.GetCompiledType(virtualPath)); }
public void GetCompiledType_ReturnsNull() { Assert.That(_buildManager.GetCompiledType("SomePath"), Is.Null); }