/// <summary> /// Executa o filtro. /// </summary> public bool Perform(ExecuteEnum exec, IRailsEngineContext context, Controller controller) { if (!Enabled) return true; UserAgent ua = null; var uaString = context.UnderlyingContext.Request.UserAgent; if (uaString != null) { ua = (UserAgent) cache[uaString]; if (ua == null) cache[uaString] = ua = new UserAgent(uaString); } if (IsValid(ua)) return true; if (!logged) { Log.Error("Tentativa de acesso através de browser não suportado: {0}", uaString); logged = true; } controller.PropertyBag["invalidGecko"] = true; if (!Redirect) return true; throw new Exception("redir: " + Redirect); //RedirectToNotice(controller); //return false; }
public AspViewBase CreateView(Type type, TextWriter output, IRailsEngineContext context, Controller controller) { ConstructorInfo constructor = (ConstructorInfo)constructors[type]; AspViewBase self = (AspViewBase)FormatterServices.GetUninitializedObject(type); constructor.Invoke(self, new object[] { this, output, context, controller }); return self; }
public bool Perform(ExecuteEnum exec, IRailsEngineContext context, Controller controller) { // Read previous authenticated principal from session // (could be from cookie although with more work) User user = (User) context.Session["user"]; // Sets the principal as the current user context.CurrentUser = user; // Checks if it is OK if (context.CurrentUser == null || !context.CurrentUser.Identity.IsAuthenticated) { // Not authenticated, redirect to login NameValueCollection parameters = new NameValueCollection(); parameters.Add("ReturnUrl", context.Url); controller.Redirect("login", "index", parameters); // Prevent request from continue return false; } // Everything is ok return true; }
/// <summary> /// Renders the mail message. /// </summary> /// <param name="templateName">Name of the template.</param> /// <param name="engineContext">The engine context.</param> /// <param name="controller">The controller.</param> /// <param name="doNotApplyLayout">if set to <c>true</c> [do not apply layout].</param> /// <returns></returns> public Message RenderMailMessage(string templateName, IRailsEngineContext engineContext, Controller controller, bool doNotApplyLayout) { context.AddMailTemplateRendered(templateName, controller.PropertyBag); return new Message("from", "to", "subject", "body"); }
/// <summary> /// Invokes the next handler. /// </summary> /// <param name="context">The context.</param> protected void InvokeNext(IRailsEngineContext context) { if (nextHandler != null) { nextHandler.Process(context); } }
public void RenderViewFor(Presentation presentation, IRailsEngineContext context) { TabularPresentation tabularPresentation = presentation as TabularPresentation; Controller controller = context.CurrentController; // configuration as json output = { baseParams: {...}, tables: [...] } Hashtable configuration = new Hashtable(2); configuration["filters"] = CollectFilterParameters(controller.Params); configuration["tables"] = new ArrayList(); foreach (TabularQuery table in tabularPresentation.GetQueries()) { Hashtable tableConfig = new Hashtable(); tableConfig["url"] = controller.UrlBuilder.BuildUrl( context.UrlInfo, controller.Name, "table", DictHelper.Create("table=" + table.Id.ToString()) ); tableConfig["download"] = controller.UrlBuilder.BuildUrl( context.UrlInfo, controller.Name, "download", DictHelper.Create("table=" + table.Id.ToString()) ); tableConfig["title"] = table.Title; tableConfig["columns"] = table.ColumnNames(); ((ArrayList)configuration["tables"]).Add(tableConfig); } controller.PropertyBag["presentation"] = tabularPresentation; controller.PropertyBag["configuration"] = JavaScriptConvert.SerializeObject(configuration); controller.RenderSharedView("presentation/tables"); }
public ItemToProcess(WebResourceProcessor proc, string contents, IRailsEngineContext ctx, IDictionary parameters) { this.proc = proc; this.contents = contents; this.ctx = ctx; this.parameters = parameters; }
/// <summary> /// Implementors should perform the action /// on the exception. Note that the exception /// is available in <see cref="IRailsEngineContext.LastException"/> /// </summary> /// <param name="context"></param> public override void Process(IRailsEngineContext context) { ILoggerFactory factory = (ILoggerFactory) context.GetService(typeof (ILoggerFactory)); ILogger logger = factory.Create(context.CurrentController.GetType()); logger.Error(BuildStandardMessage(context)); InvokeNext(context); }
/// <summary> /// Initializes a new instance of the <see cref="BrailBase"/> class. /// </summary> /// <param name="viewEngine">The view engine.</param> /// <param name="output">The output.</param> /// <param name="context">The context.</param> /// <param name="__controller">The controller.</param> public BrailBase(BooViewEngine viewEngine, TextWriter output, IRailsEngineContext context, Controller __controller) { this.viewEngine = viewEngine; this.outputStream = output; this.context = context; this.__controller = __controller; InitProperties(context, __controller); }
public bool Perform(ExecuteEnum exec, IRailsEngineContext ctx, Controller c) { if (!controllersToSkip.IsMatch(GetControllerName(c))) if (ctx.CurrentUser == null || !ctx.CurrentUser.Identity.IsAuthenticated) return TryAutoLogin(); return true; }
public bool Perform(ExecuteEnum exec, IRailsEngineContext context, Controller controller) { if (context.Request.Headers["mybadheader"] != null) { context.Response.Write("Denied!"); return false; } return true; }
public bool Perform(ExecuteEnum exec, IRailsEngineContext context, Controller controller) { if (context.Params["printable"] != null) { controller.LayoutName = "printabletheme"; } return true; }
public bool Perform(ExecuteEnum exec, IRailsEngineContext context, Controller controller) { User user = (User)context.Session["logonUser"]; if (user == null) { return false; } return true; }
/// <summary> /// Implementors should perform the action /// on the exception. Note that the exception /// is available in <see cref="IRailsEngineContext.LastException"/> /// </summary> /// <param name="context"></param> public override void Process(IRailsEngineContext context) { Exception ex = context.LastException is TargetInvocationException ? context.LastException.InnerException : context.LastException; if (!excludedTypes.Contains(ex.GetType())) { InvokeNext(context); } }
public WizardStepPage[] GetSteps(IRailsEngineContext context) { return new WizardStepPage[] { (WizardStepPage) kernel[typeof(Page1)], (WizardStepPage) kernel[typeof(Page2)], (WizardStepPage) kernel[typeof(Page3)], (WizardStepPage) kernel[typeof(Page4)], }; }
public virtual bool Perform(ExecuteEnum exec, IRailsEngineContext context, Controller controller) { if (!PerformAuthentication(context)) { context.Response.Redirect("account", "authentication"); return false; } return true; }
public bool Perform(ExecuteEnum exec, IRailsEngineContext context, Controller controller) { _userAddFilter.Perform(exec,context,controller); if (Thread.CurrentPrincipal!=null && Thread.CurrentPrincipal.Identity.IsAuthenticated){ log.Debug("authenticated"); return true; } log.Debug("not authenticated"); controller.Redirect("intro","index"); return false; }
public bool Perform(ExecuteEnum exec, IRailsEngineContext context, Controller controller) { if (context.CurrentUser == null || !context.CurrentUser.Identity.IsAuthenticated) { context.Response.Redirect("admin", "login"); return false; } return true; }
public WizardStepPage[] GetSteps(IRailsEngineContext context) { return new WizardStepPage[] { new IntroductionStep(), new MainInfoStep(), new SubscribeStep(), new ConfirmationStep(), new ResultStep() }; }
protected override bool IsPreConditionSatisfied(IRailsEngineContext context) { bool isOk = Query["id"] == "1"; if (!isOk) { Redirect("TestWizardConditions", "Index"); } return isOk; }
/// <summary> /// Creates an executor instance /// </summary> /// <returns>An <see cref="IControllerLifecycleExecutor"/> /// implementation</returns> public IControllerLifecycleExecutor CreateExecutor(Controller controller, IRailsEngineContext context) { if (controller == null) throw new ArgumentNullException("controller"); if (context == null) throw new ArgumentNullException("context"); ControllerLifecycleExecutor executor = new ControllerLifecycleExecutor(controller, context); executor.Service(serviceProvider); return executor; }
/// <summary> /// Implementors should perform they filter logic and /// return <c>true</c> if the action should be processed. /// </summary> /// <param name="exec">When this filter is being invoked</param> /// <param name="context">Current context</param> /// <param name="controller">The controller instance</param> /// <returns> /// <c>true</c> if the action /// should be invoked, otherwise <c>false</c> /// </returns> public bool Perform(ExecuteEnum exec, IRailsEngineContext context, Controller controller) { if (context.Request.Headers["HTTP_X_MOZ"].Equals("prefetch")) { Trace.Write("prefetch detected: sending 403 Forbidden"); context.Response.StatusCode = 403; return false; } return true; }
public bool Perform(ExecuteEnum exec,IRailsEngineContext context,Castle.MonoRail.Framework.Controller controller) { U_UserInfo u = context.Session["logonUser"] as U_UserInfo; if (u == null) { Hashtable p = new Hashtable(); p.Add("backUrl",context.Request.Uri.AbsoluteUri); controller.Redirect("/login",p); return false; } return true; }
public override bool Perform(ExecuteEnum exec, IRailsEngineContext context, Controller controller) { if (context.CurrentUser.Identity.IsAuthenticated) { return true; } base.PerformAuthentication(context); return true; }
public bool Perform(ExecuteEnum exec, IRailsEngineContext context, Controller controller) { if (exec == ExecuteEnum.BeforeAction) { context.Response.Write("(before)"); } else if (exec == ExecuteEnum.AfterRendering) { context.Response.Write("(after)"); } return true; // Continue execution }
public bool Perform(ExecuteEnum exec, IRailsEngineContext context, Controller controller) { String className = controller.GetType().FullName.Replace('.', '/'); if (className.StartsWith("SampleSite")) { className = className.Substring( "SampleSite/".Length ); } controller.PropertyBag.Add("controllerfile", className + ".cs"); return true; }
public bool Perform(ExecuteEnum when, IRailsEngineContext context, Controller controller) { context.CurrentUser = context.Session["user"] as IPrincipal; if (context.CurrentUser == null || context.CurrentUser.Identity == null || !context.CurrentUser.Identity.IsAuthenticated) { context.Session["FromUrl"] = context.Url; context.Response.Redirect("home", "authentication"); return false; } return true; }
/// <summary> /// Processes the view - using the templateName to obtain the correct template, /// and using the context to output the result. /// </summary> public override void Process(IRailsEngineContext context, IController controller, String templateName) { try { AdjustContentType(context); //Todo: make configurable so this can be turned off //Dump all arguments in XML to the ResponseStream if (context.Request.Params["debugxml"] != null) { XsltTransformationArguments arguments = CreateArguments(context, controller); XmlDocument doc = new XmlDocument(); foreach (XsltTransformationParameter thing in arguments.Parameters) { XmlElement elem = doc.CreateElement(thing.Name, thing.NameSpace); if (thing.Value is IXPathNavigable) elem.InnerXml = (thing.Value as IXPathNavigable).CreateNavigator().OuterXml; else elem.Value = thing.Value.ToString(); } context.Response.ContentType = "text/xml"; doc.WriteTo(new XmlTextWriter(context.Response.Output)); } else { //Run the transformations. RunStylesheets(context, controller, templateName); } } catch (Exception ex) { if (context.Request.IsLocal) { SendErrorDetails(ex, context.Response.Output); } else { //TODO: possibly incorrect message throw new RailsException("Could not obtain view: " + templateName, ex); } } }
public bool Perform(ExecuteEnum exec, IRailsEngineContext context, Controller controller) { if ((appContext.CurrentProject == null) && !((controller is ProjectsController) && (controller.Action.Equals("new") || controller.Action.Equals("create")))) // Avoid infinite loop when redirecting { if (Project.Exists()) { appContext.CurrentProject = Project.FindFirst(); } else { context.Response.Redirect("projects", "new"); return false; } } controller.PropertyBag["currentproject"] = appContext.CurrentProject; return true; }
public override void Process(IRailsEngineContext context, IServiceProvider serviceProvider) { IEmailSender emailSender = (IEmailSender)serviceProvider.GetService(typeof(IEmailSender)); String message = BuildStandardMessage(context); try { emailSender.Send(mailFrom, mailTo, "MonoRail Exception: " + context.LastException.GetType().Name, message); } catch (Exception) { // We ignore errors during send } InvokeNext(context, serviceProvider); }
public static void RegisterCurrentStepInfo(Controller controller, String actionName) { IRailsEngineContext context = controller.Context; IList stepList = (IList)context.UnderlyingContext.Items["wizard.step.list"]; for (int i = 0; i < stepList.Count; i++) { String stepName = (String)stepList[i]; if (actionName == stepName) { RegisterCurrentStepInfo(controller, i, stepName); break; } } }
private void InitProperties(IRailsEngineContext context, Controller controller) { _properties = new Dictionary <string, object>(CaseInsensitiveStringComparer.Default); _properties.Add("context", _context); _properties.Add("request", _context.Request); _properties.Add("response", _context.Response); _properties.Add("session", _context.Session); _properties.Add("controller", _controller); if (_controller.Resources != null) { foreach (string key in _controller.Resources.Keys) { if (key != null) { _properties[key] = _controller.Resources[key]; } } } foreach (string key in _controller.Helpers.Keys) { if (key != null) { _properties[key] = _controller.Helpers[key]; } } foreach (string key in _context.Params.Keys) { if (key != null) { _properties[key] = _context.Params[key]; } } foreach (DictionaryEntry entry in _context.Flash) { _properties[entry.Key.ToString()] = entry.Value; } foreach (DictionaryEntry entry in _controller.PropertyBag) { _properties[entry.Key.ToString()] = entry.Value; } _properties["siteRoot"] = _context.ApplicationPath; _properties["fullSiteRoot"] = _context.Request.Uri.GetLeftPart(UriPartial.Authority) + _context.ApplicationPath; _extentedPropertiesList = new List <IDictionary>(); }
/// <summary> /// Processes the view - using the templateName to obtain the correct template /// and writes the results to the System.TextWriter. No layout is applied! /// </summary> public override void Process(TextWriter output, IRailsEngineContext context, Controller controller, String viewName) { IContext ctx = CreateContext(context, controller); AdjustContentType(context); String view = ResolveTemplateName(viewName); try { Template template = velocity.GetTemplate(view); template.Merge(ctx, output); } catch (Exception ex) { throw new RailsException("Could not obtain view: " + view, ex); } }
/// <summary> /// Executa o filtro. /// </summary> public bool Perform(ExecuteEnum exec, IRailsEngineContext context, Controller controller) { if (!Enabled) { return(true); } UserAgent ua = null; var uaString = context.UnderlyingContext.Request.UserAgent; if (uaString != null) { ua = (UserAgent)cache[uaString]; if (ua == null) { cache[uaString] = ua = new UserAgent(uaString); } } if (IsValid(ua)) { return(true); } if (!logged) { Log.Error("Tentativa de acesso através de browser não suportado: {0}", uaString); logged = true; } controller.PropertyBag["invalidGecko"] = true; if (!Redirect) { return(true); } throw new Exception("redir: " + Redirect); //RedirectToNotice(controller); //return false; }
public void RenderViewFor(Presentation presentation, IRailsEngineContext context) { PublicationPresentation publicationPresentation = presentation as SummaryReportPresentation; Publication publication = publicationPresentation.Publication; Controller controller = context.CurrentController; Uri resource = new Uri(publication.Uri); if (resource.IsFile) { controller.CancelLayout(); controller.CancelView(); controller.Response.ContentType = !String.IsNullOrEmpty(publication.MimeType) ? publication.MimeType : "application/octet-stream"; controller.Response.WriteFile(resource.LocalPath); } else { controller.Redirect(publication.Uri); } }
public override void Process(IRailsEngineContext context, Controller controller, String viewName) { bool aspxProcessed, vmProcessed; aspxProcessed = vmProcessed = false; if (_aspxViewEngine.HasTemplate(viewName)) { aspxProcessed = ProcessAspx(context, controller, viewName); } if (!aspxProcessed && _nvelocityViewEngine.HasTemplate(viewName)) { vmProcessed = ProcessVm(context, controller, viewName); } if (!aspxProcessed && !vmProcessed) { String message = String.Format("No view file (aspx or vm) found for {0}", viewName); throw new RailsException(message); } }
private static void AddFlash(IRailsEngineContext context, XsltTransformationArguments arguments) { if (context.Flash.Keys.Count == 0) { return; } ObjectXPathContext ocontext = new ObjectXPathContext(); //For each object in the flash build an ObjectXPathNavigator to //create an XPath-able represenation of that object foreach (String key in context.Flash.Keys) { object value = context.Flash[key]; if (value != null) { arguments.AddParam(key, string.Empty, ocontext.CreateNavigator(value)); } } }
/// <summary> /// Adds the necessary helper objects to the specified /// XsltTransformationArguments instance. /// </summary> /// <param name="context">The context</param> /// <param name="controller">The controller to get the Helpers from</param> /// <param name="arguments">The XsltTransformationArguments instance to add the Helpers to.</param> private static void AddExtensionObjects(IRailsEngineContext context, IController controller, XsltTransformationArguments arguments) { List <string> extensions = new List <string>(); foreach (object helper in controller.Helpers.Values) { //TODO: get_Name is an expensive reflection operation string name = helper.GetType().Name; //Make sure every helper is only added once if (extensions.Contains(name)) { continue; } arguments.AddExtensionObject(helper); extensions.Add(name); } arguments.AddExtensionObject(new XsltReflectionHelper()); }
/// <summary> /// Adds XPathNavigable representations of the items in the propertybag /// of the controller. /// </summary> /// <param name="controller">The controller.</param> /// <param name="arguments">The arguments.</param> private static void AddPropertyBag(IRailsEngineContext railscontext, IController controller, XsltTransformationArguments arguments) { ObjectXPathContext context = new ObjectXPathContext(); //For each object in the property bag build an ObjectXPathNavigator to //create an XPath-able represenation of that object foreach (String key in controller.PropertyBag.Keys) { object value = controller.PropertyBag[key]; if (value != null) { arguments.AddParam(key, string.Empty, context.CreateNavigator(value)); } } arguments.AddParam("context", string.Empty, context.CreateNavigator(railscontext)); //arguments.AddExtensionObject("urn:request", context.Request); //arguments.AddExtensionObject("urn:response", context.Response); //arguments.AddExtensionObject("urn:server", context.Server); //arguments.AddExtensionObject("urn:session", context.Session); }
protected string BuildStandardMessage(IRailsEngineContext context) { StringBuilder sbMessage = new StringBuilder(); sbMessage.Append("Controller details\r\n"); sbMessage.Append("==================\r\n\r\n"); sbMessage.AppendFormat("Url {0}\r\n", context.Url); sbMessage.AppendFormat("Area {0}\r\n", context.UrlInfo.Area); sbMessage.AppendFormat("Controller {0}\r\n", context.UrlInfo.Controller); sbMessage.AppendFormat("Action {0}\r\n", context.UrlInfo.Action); sbMessage.AppendFormat("Extension {0}\r\n\r\n", context.UrlInfo.Extension); sbMessage.Append("Exception details\r\n"); sbMessage.Append("=================\r\n\r\n"); sbMessage.AppendFormat("Exception occured at {0}\r\n", DateTime.Now); RecursiveDumpException(context.LastException, sbMessage, 0); sbMessage.Append("\r\nEnvironment and params"); sbMessage.Append("\r\n======================\r\n\r\n"); sbMessage.AppendFormat("ApplicationPath {0}\r\n", context.ApplicationPath); sbMessage.AppendFormat("ApplicationPhysicalPath {0}\r\n", context.ApplicationPhysicalPath); sbMessage.AppendFormat("RequestType {0}\r\n", context.RequestType); sbMessage.AppendFormat("UrlReferrer {0}\r\n", context.UrlReferrer); if (context.CurrentUser != null) { sbMessage.AppendFormat("CurrentUser.Name {0}\r\n", context.CurrentUser.Identity.Name); sbMessage.AppendFormat("CurrentUser.AuthenticationType {0}\r\n", context.CurrentUser.Identity.AuthenticationType); sbMessage.AppendFormat("CurrentUser.IsAuthenticated {0}\r\n", context.CurrentUser.Identity.IsAuthenticated); } DumpDictionary(context.Flash, "Flash", sbMessage); DumpDictionary(context.Params, "Params", sbMessage); DumpDictionary(context.Session, "Session", sbMessage); return(sbMessage.ToString()); }
private String GetLocaleId(IRailsEngineContext context) { switch (setup.Store) { case RequestStore.Session: return(context.Session[setup.Key] as String); case RequestStore.Cookie: return(context.Request.ReadCookie(setup.Key)); case RequestStore.QueryString: return(context.Request.QueryString[setup.Key]); case RequestStore.Form: return(context.Request.Form[setup.Key]); case RequestStore.Params: return(context.Request.Params[setup.Key]); } return(null); }
protected bool PerformAuthentication(IRailsEngineContext context) { String contents = context.Request.ReadCookie("authenticationticket"); if (contents == null) { return false; } String login = _encryptionService.Decrypt(contents); Author author = _accountService.ObtainAuthor(login); if (author == null) { return false; } context.CurrentUser = new PrincipalAuthorAdapter(author); return true; }
/// <summary> /// Obtains the aspx Page from the view name dispatch /// its execution using the standard ASP.Net API. /// </summary> /// <param name="context"></param> /// <param name="controller"></param> /// <param name="viewName"></param> public override void Process(IRailsEngineContext context, Controller controller, String viewName) { AdjustContentType(context); HttpContext httpContext = context.UnderlyingContext as HttpContext; //TODO: document this hack for the sake of our users if (httpContext != null) { if (!httpContext.Items.Contains(ProcessedBeforeKey)) { httpContext.Items[ProcessedBeforeKey] = true; } else { if (IsTheSameView(httpContext, viewName)) { return; } } } Page masterHandler = null; if (HasLayout(controller)) { StartFiltering(httpContext.Response); masterHandler = ObtainMasterPage(httpContext, controller); } IHttpHandler childPage = GetCompiledPageInstace(viewName, httpContext); ProcessPropertyBag(controller.PropertyBag, childPage); ProcessPage(controller, childPage, httpContext); ProcessLayoutIfNeeded(controller, httpContext, childPage, masterHandler); }
/// <summary> /// Invoked when a step is accessed on the url, /// i.e. http://host/mywizard/firststep.rails and /// when an inner action is invoked like http://host/mywizard/firststep-save.rails /// </summary> /// <param name="controller"></param> private void OnStepActionRequested(Controller controller) { controller.CancelView(); IRailsEngineContext context = controller.Context; IWizardController wizController = (IWizardController)controller; String wizardName = WizardUtils.ConstructWizardNamespace(controller); String currentStep = (String)context.Session[wizardName + "currentstep"]; // The step will inherit the controller property bag, // this way filters can pass values to the step property without having to know it currentStepInstance.PropertyBag = controller.PropertyBag; if (!wizController.OnBeforeStep(wizardName, currentStep, currentStepInstance)) { return; } WizardUtils.RegisterCurrentStepInfo(controller, currentStepInstance.ActionName); if (innerAction == null || innerAction == String.Empty) { currentStepInstance.Process( controller.Context, controller.ServiceProvider, urlInfo.Area, urlInfo.Controller, "RenderWizardView"); } else { currentStepInstance.Process( controller.Context, controller.ServiceProvider, urlInfo.Area, urlInfo.Controller, innerAction); } wizController.OnAfterStep(wizardName, currentStep, currentStepInstance); }
internal static void SetContextAsTemplateAttributes(IRailsEngineContext context, Controller controller, ref StringTemplate st) { st.SetAttribute(ConfigConstants.CONTROLLER_ATTRIB_KEY, controller); st.SetAttribute(ConfigConstants.CONTEXT_ATTRIB_KEY, context); st.SetAttribute(ConfigConstants.REQUEST_ATTRIB_KEY, context.Request); st.SetAttribute(ConfigConstants.RESPONSE_ATTRIB_KEY, context.Response); st.SetAttribute(ConfigConstants.SESSION_ATTRIB_KEY, context.Session); LoadResources(controller, st); // foreach(object helper in controller.Helpers.Values) // { // st.SetAttribute(helper.GetType().Name, helper); // } LoadParams(context, st); LoadFlash(context, st); LoadPropertyBag(controller, st); st.SetAttribute(ConfigConstants.SITEROOT_ATTRIB_KEY, context.ApplicationPath); }
protected void ProcessLayout(IRailsEngineContext context, Controller controller, string contents) { try { StringTemplate template = GetLayoutTemplate(controller); SetContextAsTemplateAttributes(context, controller, ref template); template.SetAttribute(ConfigConstants.CHILD_CONTENT_ATTRIB_KEY, contents); context.Response.Output.Write(template.ToString()); } catch (Exception ex) { if (context.Request.IsLocal) { SendErrorDetails(ex, context.Response.Output, "n/a"); return; } else { throw new RailsException("Could not obtain layout", ex); } } }
override public int Write(IStringTemplateWriter output) { SetPredefinedAttributes(); SetDefaultArgumentValues(); //IRailsEngineContext context = (IRailsEngineContext) GetAttribute(ConfigConstants.CONTEXT_ATTRIB_KEY); IRailsEngineContext context = MonoRailHttpHandler.CurrentContext; StringWriter writer = new StringWriter(); StringTemplateViewContextAdapter viewComponentContext = new StringTemplateViewContextAdapter(viewComponentName, this); viewComponentContext.TextWriter = writer; viewComponent.Init(context, viewComponentContext); viewComponent.Render(); if (viewComponentContext.ViewToRender != null) { StringTemplate viewST = group.GetEmbeddedInstanceOf(this, viewComponentContext.ViewToRender); writer.Write(viewST.ToString()); } if (viewComponentName.Equals("CaptureFor")) { string keyToSet = (string)GetAttribute("id"); object valToSet = GetAttribute(keyToSet); OutermostEnclosingInstance.RemoveAttribute(keyToSet); OutermostEnclosingInstance.SetAttribute(keyToSet, valToSet); } output.Write(writer.ToString()); // if (LintMode) // { // CheckForTrouble(); // } return(0); }
protected void StartWizard(Controller controller, bool redirect) { ResetSteps(controller); IWizardController wizardController = controller as IWizardController; IRailsEngineContext context = controller.Context; IList stepList = (IList)context.UnderlyingContext.Items["wizard.step.list"]; String firstStep = (String)stepList[0]; String wizardName = WizardUtils.ConstructWizardNamespace(controller); context.Session[wizardName + "currentstepindex"] = 0; context.Session[wizardName + "currentstep"] = firstStep; wizardController.OnWizardStart(); if (redirect) { context.Response.Redirect(controller.Name, firstStep); } }
public override void GenerateJS(TextWriter output, IRailsEngineContext context, Controller controller, string templateName) { throw new RailsException("This version of AspView does not implements NJS."); }
public override void ProcessPartial(TextWriter output, IRailsEngineContext context, Controller controller, string partialName) { throw new RailsException("This version of AspView does not implements NJS."); }
public override object CreateJSGenerator(IRailsEngineContext context) { throw new RailsException("This version of AspView does not implements NJS."); }
public override void Process(IRailsEngineContext context, Controller controller, string templateName) { Process(context.Response.Output, context, controller, templateName); }
private void ProcessLayout(XmlDocument contents, Controller controller, XsltArgumentList args, IRailsEngineContext context) { String layout = "layouts/" + controller.LayoutName; try { XslTransform transform = LoadXslt(context, layout); transform.Transform(contents, args, context.Response.Output); } catch (Exception ex) { if (context.Request.IsLocal) { SendErrorDetails(ex, context.Response.Output); return; } else { throw new RailsException("Could not obtain layout: " + layout, ex); } } }
public override void ProcessPartial(TextWriter output, IRailsEngineContext context, IController controller, string partialName) { //TODO: implement me throw new NotImplementedException(); }
protected virtual String ResolveTemplatePath(IRailsEngineContext context, String templateName) { return(Path.Combine(context.ApplicationPath, Path.Combine(ViewRootDir, ResolveTemplateName(templateName)))); }
public override void GenerateJS(TextWriter output, IRailsEngineContext context, IController controller, string templateName) { //TODO: implement me throw new NotImplementedException(); }
public override object CreateJSGenerator(IRailsEngineContext context) { throw new NotImplementedException(); }
protected virtual Stream LoadTemplateFile(IRailsEngineContext context, String templateName) { return(File.OpenRead(ResolveTemplatePath(context, templateName))); }
public WizardStepPage[] GetSteps(IRailsEngineContext context) { return(new WizardStepPage[] { new Page1(), new Page2(), new Page3(), new Page4() }); }
/// <summary> /// Wraps the specified content in the layout using the context to output the result. /// </summary> public override void ProcessContents(IRailsEngineContext context, IController controller, String contents) { //TODO: implement me! throw new NotImplementedException(); }