当前位置: 首页>>代码示例>>C#>>正文


C# IElement.SetAttribute方法代码示例

本文整理汇总了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);
		}
开发者ID:CodeAnimal,项目名称:PreMailer.Net,代码行数:16,代码来源:StyleClassApplier.cs

示例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);
 }
开发者ID:hackerzpf,项目名称:ghost-crawler-1,代码行数:18,代码来源:ScriptingParser.cs

示例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;
        }
开发者ID:hackerzpf,项目名称:ghost-crawler-1,代码行数:19,代码来源:AngleSharpProvider.cs

示例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;
        }
开发者ID:yuang1516,项目名称:open-twebst,代码行数:24,代码来源:Recorder.cs


注:本文中的IElement.SetAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。