本文整理汇总了C#中IElement.SetAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# IElement.SetAttribute方法的具体用法?C# IElement.SetAttribute怎么用?C# IElement.SetAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IElement
的用法示例。
在下文中一共展示了IElement.SetAttribute方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PrepareAttribute
private static void PrepareAttribute(IElement domElement, AttributeToCss attributeToCss)
{
string name = attributeToCss.AttributeName;
string value = attributeToCss.CssValue;
//When rendering images, we need to prevent breaking the WIDTH and HEIGHT attributes. See PreMailerTests.MoveCssInline_HasStyle_DoesNotBreakImageWidthAttribute().
//The old code could end up writing an image tag like <img width="206px"> which violates the HTML spec. It should render <img width="206">.
if (domElement.NodeName == @"IMG"
&& (name == "width" || name == "height")
&& value.EndsWith("px"))
{
value = value.Replace("px", string.Empty);
}
domElement.SetAttribute(name, value);
}
示例2: ResolveUrls
public static void ResolveUrls(Uri currentPage, IElement item, string attribute)
{
var url = item.Attributes.FirstOrDefault(x => x.Name == attribute).Value;
if (!(url.StartsWith("http:") | url.StartsWith("https:")))
{
if (url.StartsWith("/"))
{
var part = currentPage.PathAndQuery == "/" ? "" : currentPage.PathAndQuery;
if (!string.IsNullOrWhiteSpace(part))
url = String.Concat(currentPage.AbsoluteUri.Replace(part, "").TrimEnd('/'), url);
else
url = String.Concat(currentPage.AbsoluteUri.TrimEnd('/'), url);
}
else
url = String.Concat(currentPage.AbsoluteUri, "/../", url);
}
item.SetAttribute(attribute, url);
}
示例3: FormMap
private static FormElement FormMap(IElement node)
{
if (node == null)
return null;
var el = new FormElement(value => node.SetAttribute("value", value))
{
Attributes = node.Attributes.ToDictionary(x => x.Name, y => y.Value),
TagName = node.TagName,
Text = node.TextContent,
InnerHtml = node.InnerHtml,
OuterHtml = node.OuterHtml
};
el.OnQuerySelector(query => Map(node.QuerySelector(query)));
el.OnQuerySelectorAll(query => node.QuerySelectorAll(query).Select(Map));
return el;
}
示例4: PutHighlight
private void PutHighlight(IElement elem)
{
Debug.Assert(this.lastSelectingElem == null);
// Set the background.
IHTMLElement2 elem2 = (IHTMLElement2)(elem.nativeElement);
IHTMLCurrentStyle crntStyle = elem2.currentStyle;
this.savedSelectBackground = crntStyle.backgroundColor;
elem.nativeElement.style.backgroundColor = CatStudioConstants.TWEBST_SELECT_BCKG;
// outline style is available starting with IE8.
if (ie8orLater)
{
IHTMLStyle6 style = (IHTMLStyle6)(elem.nativeElement.style);
IHTMLCurrentStyle5 crntStyle5 = (IHTMLCurrentStyle5)crntStyle;
this.savedSelectOutline = crntStyle5.outline;
style.outline = CatStudioConstants.TWEBST_SELECT_OUTLINE;
}
elem.SetAttribute(CatStudioConstants.CRNT_SELECTION_ATTR, "1");
this.lastSelectingElem = elem;
}