本文整理汇总了C#中this.AddAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# this.AddAttribute方法的具体用法?C# this.AddAttribute怎么用?C# this.AddAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类this
的用法示例。
在下文中一共展示了this.AddAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddTestHistory
public static HtmlTextWriter AddTestHistory(this HtmlTextWriter writer, NunitGoTest nunitGoTest, string id = "")
{
writer.AddAttribute(HtmlTextWriterAttribute.Id, id.Equals("") ? "table-cell" : id);
writer.AddStyleAttribute(HtmlTextWriterStyle.Padding, "20px");
writer.RenderBeginTag(HtmlTextWriterTag.Div);
writer.AddAttribute(HtmlTextWriterAttribute.Id, Output.GetHistoryChartId(nunitGoTest.Guid, nunitGoTest.DateTimeFinish));
writer.RenderBeginTag(HtmlTextWriterTag.Div);
writer.RenderEndTag();//DIV
writer.RenderEndTag();//DIV
return writer;
}
示例2: AddEnvironment
public static HtmlTextWriter AddEnvironment(this HtmlTextWriter writer, string id = "")
{
writer.AddAttribute(HtmlTextWriterAttribute.Id, id.Equals("") ? "table-cell" : id);
writer.AddStyleAttribute(HtmlTextWriterStyle.Padding, "20px");
writer.RenderBeginTag(HtmlTextWriterTag.Div);
writer.AddTag(HtmlTextWriterTag.B, "Environment information: ");
writer.RenderBeginTag(HtmlTextWriterTag.P);
writer.Write(Bullet.HtmlCode + "CLR version: " + Environment.Version);
writer.RenderEndTag();
writer.RenderBeginTag(HtmlTextWriterTag.P);
writer.Write(Bullet.HtmlCode + "OS version: " + Environment.OSVersion.VersionString);
writer.RenderEndTag();
writer.RenderBeginTag(HtmlTextWriterTag.P);
writer.Write(Bullet.HtmlCode + "Platform: " + Environment.OSVersion.Platform);
writer.RenderEndTag();
writer.RenderBeginTag(HtmlTextWriterTag.P);
writer.Write(Bullet.HtmlCode + "Machine name: " + Environment.MachineName);
writer.RenderEndTag();
writer.RenderBeginTag(HtmlTextWriterTag.P);
writer.Write(Bullet.HtmlCode + "User domain: " + Environment.UserDomainName);
writer.RenderEndTag();
writer.RenderBeginTag(HtmlTextWriterTag.P);
writer.Write(Bullet.HtmlCode + "User: " + Environment.UserName);
writer.RenderEndTag();
writer.RenderEndTag();//DIV
return writer;
}
示例3: AddTestEvents
public static HtmlTextWriter AddTestEvents(this HtmlTextWriter writer, NunitGoTest nunitGoTest, string id = "")
{
writer.AddAttribute(HtmlTextWriterAttribute.Id, id.Equals("") ? "table-cell" : id);
writer.AddStyleAttribute(HtmlTextWriterStyle.Padding, "20px");
writer.RenderBeginTag(HtmlTextWriterTag.Div);
var events = nunitGoTest.Events.OrderBy(x => x.Started);
foreach (var testEvent in events)
{
writer.RenderBeginTag(HtmlTextWriterTag.P);
writer.AddTag(HtmlTextWriterTag.B, "Test event: ");
writer.Write(testEvent.Name);
writer.RenderEndTag(); //P
writer.RenderBeginTag(HtmlTextWriterTag.P);
writer.Write(Bullet.HtmlCode + "Started: " + testEvent.Started.ToString("dd.MM.yy HH:mm:ss.fff"));
writer.RenderEndTag();
writer.RenderBeginTag(HtmlTextWriterTag.P);
writer.Write(Bullet.HtmlCode + "Finished: " + testEvent.Finished.ToString("dd.MM.yy HH:mm:ss.fff"));
writer.RenderEndTag();
writer.RenderBeginTag(HtmlTextWriterTag.P);
writer.Write(Bullet.HtmlCode + "Duration: " + testEvent.DurationString);
writer.RenderEndTag();
}
if (!events.Any())
writer.Write("There are no test events in this test");
writer.RenderEndTag();//DIV
return writer;
}
示例4: AddKnockoutDataBind
public static void AddKnockoutDataBind(this IHtmlWriter writer, string name, DotvvmControl control, DotvvmProperty property, Action nullBindingAction = null,
string valueUpdate = null, bool renderEvenInServerRenderingMode = false, bool setValueBack = false)
{
var expression = control.GetValueBinding(property);
if (expression != null && (!control.RenderOnServer || renderEvenInServerRenderingMode))
{
writer.AddAttribute("data-bind", name + ": " + expression.GetKnockoutBindingExpression(), true, ", ");
if (valueUpdate != null)
{
writer.AddAttribute("data-bind", "valueUpdate: '" + valueUpdate + "'", true, ", ");
}
}
else
{
if (nullBindingAction != null) nullBindingAction();
if (setValueBack && expression != null) control.SetValue(property, expression.Evaluate(control, property));
}
}
示例5: RenderFileFieldLink
/// <summary>
/// Renders a link to the file field as a hyperlink tag. Rendering directives in the Action parameter will construct the body of the link. You may add attributes to the link by adding them to the writer before invoking this method.
/// </summary>
public static void RenderFileFieldLink(this HtmlTextWriter writer, IFileField fileField, Action linkBody)
{
if (!fileField.HasValue) return;
writer.AddAttribute("href", fileField.Url);
writer.RenderBeginTag("a");
linkBody();
writer.RenderEndTag();
}
示例6: AddAttributes
public static void AddAttributes(this HtmlTextWriter writer, IDictionary<string, object> attributes)
{
if (attributes!=null && attributes.Any())
{
foreach (KeyValuePair<string, object> attribute in attributes)
{
writer.AddAttribute(attribute.Key, attribute.Value.ToString(), true);
}
}
}
示例7: BeginTable
internal static void BeginTable(this HtmlTextWriter writer, string border, string cellpadding, string cellspacing, string[] headings)
{
writer.AddAttribute(HtmlTextWriterAttribute.Border, border);
writer.AddAttribute(HtmlTextWriterAttribute.Cellpadding, cellpadding);
writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing, cellspacing);
writer.RenderBeginTag(HtmlTextWriterTag.Table);
writer.RenderBeginTag(HtmlTextWriterTag.Thead);
writer.RenderBeginTag(HtmlTextWriterTag.Tr);
foreach (var header in headings)
{
writer.RenderBeginTag(HtmlTextWriterTag.Td);
writer.Write(header);
writer.RenderEndTag(); // Td
}
writer.RenderEndTag(); // Tr
writer.RenderEndTag(); // Thead
}
示例8: OpenTreeItem
public static void OpenTreeItem(this HtmlTextWriter writer, string name, string id, string fontSize = "100%", bool isChecked = true)
{
writer.RenderBeginTag(HtmlTextWriterTag.Ul);
writer.RenderBeginTag(HtmlTextWriterTag.Li);
writer.AddAttribute(HtmlTextWriterAttribute.Type, "checkbox");
if (isChecked)
{
writer.AddAttribute(HtmlTextWriterAttribute.Checked, "checked");
}
writer.AddAttribute(HtmlTextWriterAttribute.Id, id);
writer.RenderBeginTag(HtmlTextWriterTag.Input);
writer.RenderEndTag(); //INPUT
writer.AddAttribute(HtmlTextWriterAttribute.For, id);
writer.AddStyleAttribute(HtmlTextWriterStyle.FontWeight, "bold");
writer.AddStyleAttribute(HtmlTextWriterStyle.FontSize, fontSize);
writer.RenderBeginTag(HtmlTextWriterTag.Label);
writer.Write(name);
writer.RenderEndTag(); //LABEL
}
示例9: AddPrevalueRow
/// <summary>
/// Adds a new row to the Prevalue Editor, (with an optional description).
/// </summary>
/// <param name="writer">The HtmlTextWriter.</param>
/// <param name="label">The label for the field.</param>
/// <param name="description">The description for the field.</param>
/// <param name="controls">The controls for the field.</param>
public static void AddPrevalueRow(this HtmlTextWriter writer, string label, string description, params Control[] controls)
{
writer.AddAttribute(HtmlTextWriterAttribute.Class, "row clearfix");
writer.RenderBeginTag(HtmlTextWriterTag.Div); // start 'row'
writer.AddAttribute(HtmlTextWriterAttribute.Class, "label");
writer.RenderBeginTag(HtmlTextWriterTag.Div); // start 'label'
var lbl = new HtmlGenericControl("label") { InnerText = label };
if (controls.Length > 0 && !string.IsNullOrEmpty(controls[0].ClientID))
{
lbl.Attributes.Add("for", controls[0].ClientID);
}
lbl.RenderControl(writer);
writer.RenderEndTag(); // end 'label'
writer.AddAttribute(HtmlTextWriterAttribute.Class, "field");
writer.RenderBeginTag(HtmlTextWriterTag.Div); // start 'field'
foreach (var control in controls)
{
control.RenderControl(writer);
}
writer.RenderEndTag(); // end 'field'
if (!string.IsNullOrEmpty(description))
{
writer.AddAttribute(HtmlTextWriterAttribute.Class, "description");
writer.RenderBeginTag(HtmlTextWriterTag.Div); // start 'description'
var desc = new Literal() { Text = description };
desc.RenderControl(writer);
writer.RenderEndTag(); // end 'description'
}
writer.RenderEndTag(); // end 'row'
}
示例10: AddAttributes
public static void AddAttributes(this HtmlTextWriter writer, IDictionary<string, object> attributes)
{
if (attributes.Any<KeyValuePair<string, object>>())
{
foreach (var pair in attributes)
{
if (pair.Value != null)
writer.AddAttribute(pair.Key, pair.Value.ToString(), true);
}
}
}
示例11: BeginDocument
internal static void BeginDocument(this HtmlTextWriter writer, string title, string inlineStyleSheet)
{
writer.AddAttribute("http-equiv", "Content-Type");
writer.AddAttribute("content", "text/html;charset=UTF-8");
writer.RenderBeginTag(HtmlTextWriterTag.Meta);
writer.RenderEndTag();
writer.RenderBeginTag(HtmlTextWriterTag.Html);
writer.RenderBeginTag(HtmlTextWriterTag.Style);
writer.Write(inlineStyleSheet);
writer.RenderEndTag(); // Style
writer.RenderBeginTag(HtmlTextWriterTag.Head);
writer.RenderBeginTag(HtmlTextWriterTag.Title);
writer.Write(title);
writer.RenderEndTag();
writer.RenderEndTag();
writer.RenderBeginTag(HtmlTextWriterTag.Body);
}
示例12: AddTag
public static void AddTag(this HtmlTextWriter writer, HtmlTextWriterTag tag,
Dictionary<string, string> attributes1,
Dictionary<HtmlTextWriterAttribute, string> attributes2,
string value = "")
{
foreach (var attribute in attributes1)
{
writer.AddAttribute(attribute.Key, attribute.Value);
}
foreach (var attribute in attributes2)
{
writer.AddAttribute(attribute.Key, attribute.Value);
}
writer.RenderBeginTag(tag);
if (value != "")
{
writer.Write(value);
}
writer.RenderEndTag();
}
示例13: AddAttributes
public static void AddAttributes(this HtmlTextWriter writer, IDictionary<string, object> attributes)
{
Guard.IsNotNull(writer, "writer");
if (!attributes.IsNullOrEmpty())
{
foreach (KeyValuePair<string, object> attribute in attributes)
{
writer.AddAttribute(attribute.Key, attribute.Value.ToString(), true);
}
}
}
示例14: AddPrevalueHeading
/// <summary>
/// Adds the prevalue row heading.
/// </summary>
/// <param name = "writer">The writer.</param>
/// <param name = "heading">The heading.</param>
public static void AddPrevalueHeading(this HtmlTextWriter writer, string heading)
{
writer.AddAttribute(HtmlTextWriterAttribute.Class, "row clearfix");
writer.RenderBeginTag(HtmlTextWriterTag.Div); // start 'row'
writer.RenderBeginTag(HtmlTextWriterTag.H3); // start 'h3'
writer.Write(heading);
writer.RenderEndTag(); // end 'h3'
writer.RenderEndTag(); // end 'row'
}
示例15: AddScreenshots
public static HtmlTextWriter AddScreenshots(this HtmlTextWriter writer, NunitGoTest nunitGoTest, string id = "")
{
writer.AddAttribute(HtmlTextWriterAttribute.Id, id.Equals("") ? "table-cell" : id);
writer.AddStyleAttribute(HtmlTextWriterStyle.Padding, "20px");
writer.RenderBeginTag(HtmlTextWriterTag.Div);
var screens = nunitGoTest.Screenshots.OrderBy(x => x.Date);
foreach (var screenshot in screens)
{
writer.Write("Screenshot (Date: " + screenshot.Date.ToString("dd.MM.yy HH:mm:ss.fff") + "):");
writer.AddAttribute(HtmlTextWriterAttribute.Href, @"./../../Screenshots/" + screenshot.Name);
writer.RenderBeginTag(HtmlTextWriterTag.A);
writer.AddStyleAttribute(HtmlTextWriterStyle.Width, "100%");
writer.AddAttribute(HtmlTextWriterAttribute.Src, @"./../../Screenshots/" + screenshot.Name);
writer.AddAttribute(HtmlTextWriterAttribute.Alt, screenshot.Name);
writer.RenderBeginTag(HtmlTextWriterTag.Img);
writer.RenderEndTag();//IMG
writer.RenderEndTag();//A
}
if(!screens.Any())
writer.Write("There are no screenshots in this test");
writer.RenderEndTag();//DIV
return writer;
}