Ejemplo n.º 1
0
        private void HandleException(string templateName, BrailBase view, Exception e)
        {
            var sb = new StringBuilder();

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

            sb.Append("Exception: ").AppendLine(e.ToString());
//			Log(msg);
            throw new Exception(msg, e);
        }
Ejemplo n.º 2
0
        public DslProvider(BrailBase view)
        {
            this.view = view;
            foreach (var 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());
            }
        }
Ejemplo n.º 3
0
        public DslProvider(BrailBase view)
        {
            this.view = view;
            foreach(var 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());
            }
        }
Ejemplo n.º 4
0
        // Check if a layout has been defined. If it was, then the layout would be created
        // and will take over the output, otherwise, the context.Reposne.Output is used,
        // and layout is null
        private BrailBase GetOutput(string masterName)
        {
            BrailBase layout = null;

            if (!string.IsNullOrEmpty(masterName))
            {
                string layoutTemplate = masterName;
                if (layoutTemplate.StartsWith("/") == false)
                {
                    layoutTemplate = "layouts\\" + layoutTemplate;
                }
                string layoutFilename = layoutTemplate + ViewFileExtension;
                layout = GetCompiledScriptInstance(layoutFilename);
            }
            return(layout);
        }
Ejemplo n.º 5
0
//		public override void Process(string templateName, string layoutName, TextWriter output,
//		                             IDictionary<string, object> parameters)
//		{
//			throw new NotImplementedException();
//		}

        public virtual BrailBase ProcessPartial(string viewName)
//		(string partialName, TextWriter output, IEngineContext context, IController controller, IControllerContext controllerContext)
        {
            Log("Generating partial for {0}", viewName);

            try
            {
                string    file = ResolveTemplateName(viewName, ViewFileExtension);
                BrailBase view = GetCompiledScriptInstance(file);
                return(view);
            }
            catch (Exception ex)
            {
//				if (Logger != null && Logger.IsErrorEnabled)
//				{
//					Logger.Error("Could not generate JS", ex);
//				}

                throw new Exception("Error generating partial: " + viewName, ex);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Outputs the sub view to the writer
        /// </summary>
        /// <param name="subviewName">Name of the subview.</param>
        /// <param name="writer">The writer.</param>
        /// <param name="parameters">The parameters.</param>
        public void OutputSubView(string subviewName, TextWriter writer, IDictionary parameters)
        {
            string    subViewFileName = GetSubViewFilename(subviewName);
            BrailBase subView         = viewEngine.GetCompiledScriptInstance(subViewFileName);

            subView.SetParent(this);
            foreach (DictionaryEntry entry in parameters)
            {
                subView.properties[entry.Key] = entry.Value;
            }
            subView.Render(__viewContext, writer);
            foreach (DictionaryEntry entry in subView.Properties)
            {
                if (subView.Properties.Contains(entry.Key + ".@bubbleUp") == false)
                {
                    continue;
                }
                properties[entry.Key] = entry.Value;
                properties[entry.Key + ".@bubbleUp"] = true;
            }
        }
Ejemplo n.º 7
0
        // Process a template name and output the results to the user
        // This may throw if an error occured and the user is not local (which would
        // cause the yellow screen of death)
        public virtual BrailBase Process(string viewName, string masterName)
//		(String templateName, TextWriter output, IEngineContext context, IController controller, IControllerContext controllerContext)
        {
            Log("Starting to process request for {0}", viewName);
            string file = viewName + ViewFileExtension;
            // Will compile on first time, then save the assembly on the cache.
            BrailBase view = GetCompiledScriptInstance(file);

            view.Layout = GetOutput(masterName);

            return(view);

//			controller.PreSendView(view);
//
//			Log("Executing view {0}", viewName);
//
//			try
//			{
//				view.Run();
//			}
//			catch(Exception e)
//			{
//				HandleException(viewName, view, e);
//			}
//
//			if (layoutViewOutput.Layout != null)
//			{
//				layoutViewOutput.Layout.SetParent(view);
//				try
//				{
//					layoutViewOutput.Layout.Run();
//				}
//				catch(Exception e)
//				{
//					HandleException(masterName, layoutViewOutput.Layout, e);
//				}
//			}
//			Log("Finished executing view {0}", viewName);
//			controller.PostSendView(view);
        }
Ejemplo n.º 8
0
 public void SetUp()
 {
     _mocks = new MockRepository();
     _viewEngine = _mocks.DynamicMock<BooViewEngine>();
     _view = _mocks.StrictMock<BrailBase>(_viewEngine);
 }
Ejemplo n.º 9
0
 public LayoutViewOutput(TextWriter output, BrailBase layout)
 {
     this.layout = layout;
     this.output = output;
 }
Ejemplo n.º 10
0
 public LayoutViewOutput(TextWriter output, BrailBase layout)
 {
     this.layout = layout;
     this.output = output;
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Sets the parent.
 /// </summary>
 /// <param name="myParent">My parent.</param>
 public void SetParent(BrailBase myParent)
 {
     parent = myParent;
 }
Ejemplo n.º 12
0
 private void HandleException(string templateName, BrailBase view, Exception e)
 {
     var sb = new StringBuilder();
     sb.Append("Exception on RenderView: ").AppendLine(templateName);
     sb.Append("Last accessed variable: ").Append(view.LastVariableAccessed);
     string msg = sb.ToString();
     sb.Append("Exception: ").AppendLine(e.ToString());
     //			Log(msg);
     throw new Exception(msg, e);
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Sets the parent.
 /// </summary>
 /// <param name="myParent">My parent.</param>
 public void SetParent(BrailBase myParent)
 {
     parent = myParent;
 }