public static Renderer GetRenderer(ProcessURI uri, IProcessResponse response) { RenderingSection config = RenderingSection.Current; if (renderer == null) { Type rendererType = Type.GetType(config.Type); Assembly asm = rendererType.Assembly; renderer = asm.CreateInstance(rendererType.FullName) as Renderer; renderer.Path = ParseRendererPath(config); //foreach (CustomHelper helper in config.CustomHelpers) // renderer.Helpers.Add(CreateHelperInstance(helper)); renderer.UrlHelper = new UrlHelper("url"); renderer.AppHelper = new AppHelper("app"); renderer.StateHelper = new StateHelper("state"); renderer.AjaxHelper = new AjaxHelper("ajax"); renderer.TypeHelper = new TypeHelper("type"); } renderer.URI = uri; Configuration.Template template = renderer.GetTemplate(response); renderer.LayoutFileName = template != null ? ((string.IsNullOrEmpty(template.LayoutFileName)) ? config.LayoutFileName : template.LayoutFileName) : config.LayoutFileName; return renderer; }
public Template Find(IProcessResponse response) { foreach (Template tpl in this) if (tpl.IsResponseTemplate(response)) return tpl; return null; }
protected Control LoadControl(string templateName, Page page, IProcessResponse response, Domain domain) { string templatePath = string.Format("~/{0}/{1}", RenderingSection.Current.Path, templateName); WebFormsControl control = null; try { control = page.LoadControl(templatePath) as WebFormsControl; } catch (Exception ex) { #if DEBUG throw ex; #endif } if (control != null) { control.URI = URI; control.Response = response; control.Domain = domain; control.Renderer = this; } return control; }
public string ProcessResponse(IProcessResponse response) { StringWriter writer = new StringWriter(); Configuration.Template template = GetTemplate(response); if (template != null) ProcessTemplate(writer, template.FileName, response, null); return writer.ToString(); }
public override void ProcessTemplate(TextWriter writer, string templateName, IProcessResponse response, Domain domain) { if (!string.IsNullOrEmpty(templateName)) { Template template = Engine.GetTemplate(templateName); template.Merge(CreateTemplateContext(URI, response, domain), writer); } }
public void LoadDomainTemplate(IProcessResponse response, Domain domain, Control container) { string templateName = GetTemplateName(response, domain); if (!string.IsNullOrEmpty(templateName)) { var control = LoadControl(templateName, container.Page, response, domain); if (control != null) container.Controls.Add(control); } }
public void LoadTemplate(IProcessResponse response, Domain domain, Control container) { Configuration.Template template = GetTemplate(response); if (template != null) { var control = LoadControl(template.FileName, container.Page, response, domain); if (control != null) container.Controls.Add(control); } }
public override void ProcessTemplate(TextWriter writer, string templateName, IProcessResponse response, Domain domain) { if (!string.IsNullOrEmpty(templateName)) { Page page = new Page(); page.Controls.Add(LoadControl(templateName, page, response, domain)); page.RenderControl(new HtmlTextWriter(writer)); } }
public override void Process(IProcessResponse response, TextWriter writer) { if (UrlHelper.CurrentExtension.Equals(UrlHelper.ExcelInteropExtension) || UrlHelper.CurrentExtension.Equals(UrlHelper.PdfExtension)) { Template template = GetTemplate(response); if (template != null) ProcessTemplate(writer, template.FileName, response, null); } else base.Process(response, writer); }
private VelocityContext CreateTemplateContext(ProcessURI uri, IProcessResponse response, Domain domain) { VelocityContext context = new VelocityContext(); context.Put("uri", uri); context.Put("renderer", this); if (response != null) context.Put("response", response); if (domain != null) context.Put("domain", domain); foreach (RendererHelper helper in Helpers) context.Put(helper.Name, helper); return context; }
public static IProcessResponse Evaluate(ProcessURI uri, IProcessResponse response) { if (IsAuthorized(uri)) { Expression expression = GetRuleResponseExpression(uri) ?? Expression.Empty; if (expression != Expression.Empty) { var expressionURI = ProcessURI.Parse(expression.ToString()); foreach (AuthorizationKeyEvaluator evaluator in Evaluators) expressionURI = evaluator.Evaluate(expression, expressionURI); //TODO: Apply new URI to the response subset } } return response; }
public override void ProcessTemplate(TextWriter writer, string templateName, IProcessResponse response, Domain domain) { if ((UrlHelper.CurrentExtension.Equals(UrlHelper.ExcelInteropExtension) || UrlHelper.CurrentExtension.Equals(UrlHelper.PdfExtension)) && response is QueryProcessResponse) { if (templateName.EndsWith(ExcelExtension)) { SetFileName(response); var filePath = CreateExcelFile(templateName); if (UrlHelper.CurrentExtension.Equals(UrlHelper.ExcelInteropExtension)) { LoadExcelData(filePath, (QueryProcessResponse)response); HttpContext.Current.Response.WriteFile(filePath); } else { LoadPdfData(filePath, (QueryProcessResponse)response); HttpContext.Current.Response.WriteFile(filePath.Replace(ExcelExtension, PdfExtension)); } } } else base.ProcessTemplate(writer, templateName, response, domain); }
protected string GetTemplateName(IProcessResponse response, Domain domain) { return GetTemplate(response).TemplateDomains.Find(domain).FileName; }
public abstract void ProcessTemplate(TextWriter writer, string templateName, IProcessResponse response, Domain domain);
public void Process(IProcessResponse response, Domain domain, TextWriter writer) { ProcessTemplate(writer, GetTemplateName(response, domain), response, domain); }
public virtual void Process(IProcessResponse response, TextWriter writer) { if (!string.IsNullOrEmpty(LayoutFileName)) ProcessTemplate(writer, LayoutFileName, response, null); else { Template template = GetTemplate(response); if (template != null) ProcessTemplate(writer, template.FileName, response, null); } }
public static IProcessResponse Evaluate(ProcessURI uri, IProcessResponse response) { return AuthorizationManager.Evaluate(uri, response); }
public Template GetTemplate(IProcessResponse response) { var config = RenderingSection.Current; if (!Templates.ContainsKey(response)) { var template = config.Templates.Find(string.Concat(response.URI, UrlHelper.CurrentExtension), UrlHelper.CurrentExtension) ?? config.Templates.Find(response.URI) ?? config.Templates.Find(response); Templates.Add(response, template); } return Templates[response]; }
private void SetFileName(IProcessResponse response) { FileName = response.URI.Entity; var timeStamp = DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss.fff"); if (FileName.Length > (FileNameLength - timeStamp.Length - 1)) FileName = FileName.Substring(0, (FileNameLength - timeStamp.Length - 1)); FileName = string.Concat(FileName, " ", timeStamp); }
public string ProcessDomain(IProcessResponse response, Domain domain) { StringWriter writer = new StringWriter(); ProcessTemplate(writer, GetTemplateName(response, domain), response, domain); return writer.ToString(); }
internal bool IsResponseTemplate(IProcessResponse response) { if (response != null) { string name = response.GetType().Name; const string filterKey = ResponseFilterKey + FilterKeySeparator; return name.Contains(Filter.Replace(filterKey, string.Empty)); } return false; }