Base class for all the view scripts, this is the class that is responsible for support all the behind the scenes magic such as variable to PropertyBag trasnlation, resources usage, etc.
		/// <summary>
		/// Initializes a new instance of the <see cref="BrailViewComponentContext"/> class.
		/// </summary>
		/// <param name="parent">The parent.</param>
		/// <param name="body">The body.</param>
		/// <param name="name">The name.</param>
		/// <param name="text">The text.</param>
		/// <param name="parameters">The parameters.</param>
		public BrailViewComponentContext(BrailBase parent, ICallable body,
										 string name, TextWriter text, IDictionary parameters)
		{
			this.parent = parent;
			this.body = body;
			componentName = name;
			default_writer = text;
			componentParameters = parameters;
		}
		/// <summary>
		/// Initializes a new instance of the <see cref="BrailViewComponentContext"/> class.
		/// </summary>
		/// <param name="parent">The parent.</param>
		/// <param name="body">The body.</param>
		/// <param name="name">The name.</param>
		/// <param name="text">The text.</param>
		/// <param name="parameters">The parameters.</param>
		public BrailViewComponentContext(BrailBase parent, ICallable body,
		                                 string name, TextWriter text, IDictionary parameters)
		{
			this.parent = parent;
			this.body = body;
			componentName = name;
			default_writer = text;
			componentParameters = IgnoreNull.ReplaceIgnoreNullsWithTargets(parameters);
		}
 /// <summary>
 /// Initializes a new instance of the <see cref="BrailViewComponentContext"/> class.
 /// </summary>
 /// <param name="parent">The parent.</param>
 /// <param name="body">The body.</param>
 /// <param name="name">The name.</param>
 /// <param name="text">The text.</param>
 /// <param name="parameters">The parameters.</param>
 public BrailViewComponentContext(BrailBase parent, ICallable body,
                                  string name, TextWriter text, IDictionary parameters)
 {
     this.parent         = parent;
     this.body           = body;
     componentName       = name;
     default_writer      = text;
     componentParameters = IgnoreNull.ReplaceIgnoreNullsWithTargets(parameters);
 }
Example #4
0
 private void RenderView(string templateName, BrailBase view)
 {
     try
     {
         view.Run();
     }
     catch (Exception e)
     {
         HandleException(templateName, view, e);
     }
 }
Example #5
0
        public DslProvider(BrailBase view)
        {
            this.view = view;
            foreach (PropertyInfo prop in typeof(BrailBase).GetProperties(BindingFlags.Public | BindingFlags.Instance))
            {
                if (prop.Name == "Dsl" || prop.Name == "ViewEngine" || prop.Name == "Properties" || prop.CanRead == false)
                {
                    continue;
                }

                viewProperties.Add(prop.Name, prop.GetGetMethod());
            }
        }
Example #6
0
        private void HandleException(string templateName, BrailBase view, Exception e)
        {
            var sb = new StringBuilder();

            sb.Append("Exception on process view: ").AppendLine(templateName);
            sb.Append("Last accessed variable: ").Append(view.LastVariableAccessed);
            var msg = sb.ToString();

            sb.Append("Exception: ").AppendLine(e.ToString());
            if (logger != null && logger.IsErrorEnabled)
            {
                logger.Error(msg, e);
            }
            throw new MonoRailException(msg, e);
        }
Example #7
0
 public void RenderLayouts(BooViewEngine booViewEngine, BrailBase view)
 {
     foreach (var layout in layouts)
     {
         try
         {
             layout.SetParent(view);
             layout.Run();
             view = layout;
         }
         catch (Exception e)
         {
             booViewEngine.HandleException(layout.ViewFileName, layout, e);
         }
     }
 }
Example #8
0
			public ReturnOutputStreamToInitialWriter(TextWriter initialWriter, BrailBase parent)
			{
				this.initialWriter = initialWriter;
				this.parent = parent;
			}
Example #9
0
		/// <summary>
		/// Sets the parent.
		/// </summary>
		/// <param name="myParent">My parent.</param>
		public void SetParent(BrailBase myParent)
		{
			parent = myParent;
		}
Example #10
0
 public ReturnOutputStreamToInitialWriter(TextWriter initialWriter, BrailBase parent)
 {
     this.initialWriter = initialWriter;
     this.parent        = parent;
 }
Example #11
0
		public DslProvider(BrailBase view)
		{
			this.view = view;
		}
Example #12
0
 public DslProvider(BrailBase view)
 {
     this.view = view;
 }
Example #13
0
 /// <summary>
 /// Sets the parent.
 /// </summary>
 /// <param name="myParent">My parent.</param>
 public void SetParent(BrailBase myParent)
 {
     parent = myParent;
 }
Example #14
0
		private void HandleException(string templateName, BrailBase view, Exception e)
		{
			StringBuilder sb = new StringBuilder();
			sb.Append("Exception on process view: ").AppendLine(templateName);
			sb.Append("Last accessed variable: ").Append(view.LastVariableAccessed);
			string msg = sb.ToString();
			sb.Append("Exception: ").AppendLine(e.ToString());
			Log(msg);
			throw new MonoRailException(msg, e);
		}
		public void Clear() {
			this.componentParameters.Clear();
			this.componentParameters = null;
			this.parent = null;
			this.body = null;
		}
Example #16
0
	    private void _renderp(string partialName, BrailBase view) {
	        Log("Executing partial view {0}", partialName);
	        view.Run();
	        Log("Finished executing partial view {0}", partialName);
	    }
Example #17
0
	    private void _render(string templateName, LayoutViewOutput layoutViewOutput, BrailBase view) {
	        Log("Executing view {0}", templateName);

	        RenderView(templateName, view);

	        layoutViewOutput.RenderLayouts(this, view);

	        Log("Finished executing view {0}", templateName);
	    }
Example #18
0
 public checkbox(BrailBase view, params string[] id_and_classes) : base(view, id_and_classes) {}
Example #19
0
 protected void Render(BrailBase view){
     lock (sync){
         if (UseCollapseBlock){
             view.OutputSubView("partStart",
                                new Dictionary<string, object>
                                {{"this", this}, {"wiki", myapp.files.ReadXml("route.xml?$wiki")}});
         }
         if (ViewName.hasContent()){
             view.OutputSubView(ViewName);
         }
         else if (null != RenderObject){
             RenderObject.Render(view);
         }
         else{
             InternalRender(view);
         }
         if (UseCollapseBlock){
             view.OutputSubView("partEnd", new Dictionary<string, object>{{"this", this}});
         }
     }
 }
Example #20
0
 protected virtual void InternalRender(BrailBase view) {}
Example #21
0
		private void RenderView(string templateName, BrailBase view)
		{
			try
			{
				view.Run();
			}
			catch (Exception e)
			{
				HandleException(templateName, view, e);
			}
		}
Example #22
0
		private void HandleException(string templateName, BrailBase view, Exception e)
		{
			var sb = new StringBuilder();
			sb.Append("Exception on process view: ").AppendLine(templateName);
			sb.Append("Last accessed variable: ").Append(view.LastVariableAccessed);
			var msg = sb.ToString();
			sb.Append("Exception: ").AppendLine(e.ToString());
			if (logger != null && logger.IsErrorEnabled)
			{
				logger.Error(msg, e);
			}
			throw new MonoRailException(msg, e);
		}
Example #23
0
			public void RenderLayouts(BooViewEngine booViewEngine, BrailBase view)
			{
				foreach(BrailBase layout in layouts)
				{
					try
					{
						layout.SetParent(view);
						layout.Run();
						view = layout;
					}
					catch(Exception e)
					{
						booViewEngine.HandleException(layout.ViewFileName, layout, e);
					}
				}
			}
Example #24
0
			public LayoutViewOutput(TextWriter output, BrailBase layout)
			{
				this.layout = layout;
				this.output = output;
			}