static void Main(string[] args) { Tag html = new HtmlTag(); Tag body = new BodyTag(); Tag head = new HeadTag(); Tag title = new TitleTag(); Tag div = new DivTag(); Element elem1 = new Element(); Element elem2 = new Element(); Element elem3 = new Element(); Tag brr = new BrTag(); Tag h1 = new H1Tag(); elem1.SetContent("titlu"); elem2.SetContent("giele"); elem3.SetContent("gielesss"); html.AddTag(head); html.AddTag(body); head.AddElement(elem1); head.AddTag(brr); head.AddTag(title); head.AddElement(elem2); head.AddTag(title); head.AddElement(elem3); body.AddTag(div); div.AddTag(h1); div.AddAttribute("color", "blue"); div.AddAttribute("color1", "red"); //title.SetContent("Gigi 4 the WIN!!"); //head.SetContent("gigel"); //html.Render(); Parser.ParseFile("index.html"); }
public BodyTag CreateAssertionFailure() { BodyTag bodyTag = new BodyTag(); bodyTag.Contents.Add(CreateAssertionFailureMarkerTag()); return(bodyTag); }
public void BodyCanBeSetToNonNull() { BodyTag newBody = new BodyTag(); StructuredStream stream = new StructuredStream("name"); stream.Body = newBody; Assert.AreSame(newBody, stream.Body); }
/// <summary> /// Creates a simple structured text object over a plain text string. /// </summary> /// <param name="text">The text string.</param> /// <exception cref="ArgumentNullException">Thrown if <paramref name="text"/> is null.</exception> public StructuredText(string text) { if (text == null) { throw new ArgumentNullException("text"); } bodyTag = new BodyTag(); bodyTag.Contents.Add(new TextTag(text)); attachments = EmptyArray <Attachment> .Instance; }
/// <summary> /// Creates a structured text object that wraps the body tag of a structured markup document stream /// and a list of attachments. /// </summary> /// <param name="bodyTag">The body tag to wrap.</param> /// <param name="attachments">The list of attachments.</param> /// <exception cref="ArgumentNullException">Thrown if <paramref name="bodyTag"/>, /// or <paramref name="attachments"/> is null.</exception> public StructuredText(BodyTag bodyTag, IList <Attachment> attachments) { if (bodyTag == null) { throw new ArgumentNullException("bodyTag"); } if (attachments == null) { throw new ArgumentNullException("attachments"); } this.bodyTag = bodyTag; this.attachments = attachments; }
public void Init() { GallioBodyTagFactory factory = new GallioBodyTagFactory(); structuredStream = factory.CreateAssertionFailureStructuredStream(); bodyTag = structuredStream.Body; assertionFailureMarkerTag = GetFirstChildMarkerTag(bodyTag); expectedValueToBeTrueSectionTag = GetFirstChildSectionTag(assertionFailureMarkerTag); expectedValueToBeTrueTextTag = GetFirstChildTextTag(expectedValueToBeTrueSectionTag); monoSpaceMarkerTag = GetSecondChildMarkerTag(expectedValueToBeTrueSectionTag); textTagAfterMonoSpaceMarkerTag = GetThirdChildTextTag(expectedValueToBeTrueSectionTag); stackTraceMarkerTag = GetFourthChildMarkerTag(expectedValueToBeTrueSectionTag); stackTraceTextTag = GetFirstChildTextTag(stackTraceMarkerTag); codeLocationMarkerTag = GetSecondChildMarkerTag(stackTraceMarkerTag); codeLocationTextTag = GetFirstChildTextTag(codeLocationMarkerTag); }
/// <inheritdoc /> public override Func <ITag, CompileContext, MethodInfo> BuildCompileMethod() { return((tag, c) => { var t = tag as LayoutTag; var type = c.GuessType(t); var mb = c.CreateReutrnMethod <LayoutTag>(type); var il = mb.GetILGenerator(); var strTag = t.Path as StringTag; if (strTag == null) { throw new Exception.CompileException($"[LayoutTag] : path must be a string."); } var res = c.Load(strTag.Value); if (res == null) { throw new Exception.CompileException($"[LayoutTag] : \"{strTag.Value}\" cannot be found."); } var lexer = c.CreateTemplateLexer(res.Content); var ts = lexer.Execute(); var parser = c.CreateTemplateParser(ts); var tags = parser.Execute(); for (int i = 0; i < tags.Length; i++) { if (tags[i] is BodyTag) { BodyTag body = (BodyTag)tags[i]; for (int j = 0; j < t.Children.Count; j++) { body.AddChild(t.Children[j]); } } } c.BlockCompile(il, tags); il.Emit(OpCodes.Ret); return mb.GetBaseDefinition(); }); }
/// <inheritdoc /> public override Func <ITag, TemplateContext, object> BuildExcuteMethod() { return((tag, context) => { var t = tag as LayoutTag; object path = TagExecutor.Execute(t.Path, context); if (path == null) { return null; } var res = context.Load(path.ToString()); if (res != null) { var render = new TemplateRender(); render.Context = context; //render.TemplateContent = res.Content; var tags = render.ReadAll(res.Content); for (int i = 0; i < tags.Length; i++) { if (tags[i] is BodyTag) { BodyTag body = (BodyTag)tags[i]; for (int j = 0; j < t.Children.Count; j++) { body.AddChild(t.Children[j]); } tags[i] = body; } } using (System.IO.StringWriter writer = new StringWriter()) { render.Render(writer, tags); return writer.ToString(); } } return null; }); }
/// <inheritdoc /> public virtual void VisitBodyTag(BodyTag tag) { RequestMinimumSpacing(2); tag.AcceptContents(this); RequestMinimumSpacing(2); }
/// <summary> /// Creates a structured text object that wraps the body tag of a structured markup document stream /// and no attachments. /// </summary> /// <param name="bodyTag">The body tag to wrap.</param> /// <exception cref="ArgumentNullException">Thrown if <paramref name="bodyTag"/> is null.</exception> public StructuredText(BodyTag bodyTag) : this(bodyTag, EmptyArray <Attachment> .Instance) { }
public void VisitBodyTag(BodyTag tag) { tag.AcceptContents(this); }
public void VisitBodyTag(BodyTag tag) { foreach (Tag childTag in tag.Contents) { childTag.Accept(this); } }