/// <summary> /// Initializes a new instance of the ViewComponent class. /// </summary> protected ViewComponent() { var attributes = GetType().GetCustomAttributes(typeof(ViewComponentDetailsAttribute), true); if (attributes.Length != 0) { detailsAtt = attributes[0] as ViewComponentDetailsAttribute; } }
public void CorrectSectionsCreated() { var grammar = new MarkupGrammar(ParserSettings.DefaultBehavior); var nodes = grammar.Nodes(new Position(new SourceContext( "<foo>1<tr>2<td>3</foo> <bar>4</td>5</tr>6</bar> stuff <baaz>yadda<baaz></baaz><quux><quux/></baaz>"))); var details = new ViewComponentDetailsAttribute("Testing") { Sections = "foo,baaz,bar,quux" }; var visitor = new ViewComponentVisitor(new ChunkBuilderVisitor(new VisitorContext{Paint=nodes.Rest.GetPaint()}), new ViewComponentInfo { Details = details }); visitor.Accept(nodes.Value); Assert.AreEqual(3, visitor.Sections.Count); Assert.AreEqual(1, visitor.Sections["foo"].Count); Assert.AreEqual("1<tr>2<td>3", ((SendLiteralChunk)visitor.Sections["foo"][0]).Text); }
/// <summary> /// Initializes a new instance of the ViewComponent class. /// </summary> protected ViewComponent() { var attributes = GetType().GetCustomAttributes(typeof (ViewComponentDetailsAttribute), true); if (attributes.Length != 0) { detailsAtt = attributes[0] as ViewComponentDetailsAttribute; } }