private void SetStyle(JbstContainerControl target, string name, string value) { if (String.IsNullOrEmpty(name) && String.IsNullOrEmpty(value)) { return; } if (target == null) { throw new NullReferenceException("target is null"); } string style = target.Attributes.ContainsKey("style") ? target.Attributes["style"] as String : null; if (style != null && !style.EndsWith(";")) { style += ";"; } if (String.IsNullOrEmpty(name)) { style += value; } else { style += name + ':' + value; } target.Attributes["style"] = style; }
private void SetAttribute(JbstContainerControl target, string name, string value) { value = HtmlDistiller.DecodeHtmlEntities(value); if ("style".Equals(name, StringComparison.OrdinalIgnoreCase)) { this.SetStyle(target, null, value); } else { target.Attributes[name] = value; } }
private void AppendChild(JbstControl child) { if (child == null) { return; } if (this.current == null) { this.current = this.document; } this.current.ChildControls.Add(child); }
private void AppendChild(string text) { if (String.IsNullOrEmpty(text)) { return; } if (this.current == null) { this.current = this.document; } // this allows HTML entities to be encoded as unicode text = HtmlDistiller.DecodeHtmlEntities(text); JbstLiteral literal = new JbstLiteral(text, true); this.current.ChildControls.Add(literal); }
private void PopTag(string tagName) { if (tagName == null) { tagName = String.Empty; } if (this.current == null) { throw new InvalidOperationException("Push/Pop mismatch? (current tag is null)"); } if (!String.IsNullOrEmpty(tagName) && !tagName.Equals(this.current.RawName, StringComparison.OrdinalIgnoreCase)) { //throw new InvalidOperationException("Push/Pop mismatch? (tag names do not match)"); return; } if (JbstWriter.ScriptTagName.Equals(this.current.RawName, StringComparison.OrdinalIgnoreCase)) { // script tags get converted once fully parsed this.Declarations.Append(this.current); } JbstInline inline = this.current as JbstInline; this.current = this.current.Parent; if (inline != null && inline.IsAnonymous) { // consolidate anonymous inline templates directly into body this.current.ChildControls.Remove(inline); if (inline.ChildControlsSpecified) { this.current.ChildControls.AddRange(inline.ChildControls); } } }
private void PushTag(string rawName) { string tagName; string prefix = JbstWriter.SplitPrefix(rawName, out tagName); JbstContainerControl control; if (JbstCommandBase.JbstPrefix.Equals(prefix, StringComparison.OrdinalIgnoreCase)) { if (StringComparer.OrdinalIgnoreCase.Equals(JbstControlReference.ControlCommand, tagName)) { control = new JbstControlReference(); } else if (StringComparer.OrdinalIgnoreCase.Equals(JbstPlaceholder.PlaceholderCommand, tagName)) { control = new JbstPlaceholder(); } else if (StringComparer.OrdinalIgnoreCase.Equals(JbstInline.InlineCommand, tagName)) { control = new JbstInline(); } else { throw new InvalidOperationException("Unknown JBST command ('" + rawName + "')"); } } else { control = new JbstContainerControl(prefix, tagName); } if (this.current == null) { this.current = this.document; } this.current.ChildControls.Add(control); this.current = control; }
/// <summary> /// Append another code block onto declaration block /// </summary> /// <param name="control"></param> public void Append(JbstControl control) { if (control is JbstCodeBlock) { this.Content.Append(((JbstCodeBlock)control).Code); } else if (control is JbstLiteral) { this.Content.Append(((JbstLiteral)control).Text); } else if (control is JbstContainerControl) { JbstContainerControl parent = (JbstContainerControl)control; while (parent.ChildControlsSpecified) { // this will remove it from the collection this.Append(parent.ChildControls[0]); } } // remove from the parse tree since is pre-aggregated control.Parent.ChildControls.Remove(control); }
private void SetStyle(JbstContainerControl target, string name, string value) { if (String.IsNullOrEmpty(name) && String.IsNullOrEmpty(value)) { return; } if (target == null) { throw new NullReferenceException("target is null"); } string style = target.Attributes.ContainsKey("style") ? target.Attributes["style"] as String : null; if (style != null && !style.EndsWith(";")) { style += ";"; } if (String.IsNullOrEmpty(name)) { style += value; } else { style += name+':'+value; } target.Attributes["style"] = style; }
private void PushTag(string rawName) { string tagName; string prefix = JbstWriter.SplitPrefix(rawName, out tagName); JbstContainerControl control; if (JbstCommandBase.JbstPrefix.Equals(prefix, StringComparison.OrdinalIgnoreCase)) { if (StringComparer.OrdinalIgnoreCase.Equals(JbstControlReference.ControlCommand, tagName)) { control = new JbstControlReference(); } else if (StringComparer.OrdinalIgnoreCase.Equals(JbstPlaceholder.PlaceholderCommand, tagName)) { control = new JbstPlaceholder(); } else if (StringComparer.OrdinalIgnoreCase.Equals(JbstInline.InlineCommand, tagName)) { control = new JbstInline(); } else { throw new InvalidOperationException("Unknown JBST command ('"+rawName+"')"); } } else { control = new JbstContainerControl(prefix, tagName); } if (this.current == null) { this.current = this.document; } this.current.ChildControls.Add(control); this.current = control; }
/// <summary> /// Ctor /// </summary> /// <param name="owner"></param> public JbstControlCollection(JbstContainerControl owner) { this.owner = owner; }