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


C# this.Attribute方法代码示例

本文整理汇总了C#中this.Attribute方法的典型用法代码示例。如果您正苦于以下问题:C# this.Attribute方法的具体用法?C# this.Attribute怎么用?C# this.Attribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在this的用法示例。


在下文中一共展示了this.Attribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetAttr

 public static string GetAttr(this XElement el, string name)
 {
     if (el.Attribute(name) == null)
         return null;
     else
         return el.Attribute(name).Value;
 }
开发者ID:Zergatul,项目名称:l2calc,代码行数:7,代码来源:Program.cs

示例2: ToBsonDocument

        public static BsonDocument ToBsonDocument(this XElement xElement)
        {
            var bsonDocument = new BsonDocument();

            var type = xElement.Name.ToString();
            bsonDocument.Add(Constants._TYPE, type);
            var mainId = xElement.Attribute(Constants._ID) != null ? xElement.Attribute(Constants._ID).Value : null;

            foreach (XAttribute attribure in xElement.Attributes())
            {
                var key = attribure.Name.ToString();
                var value = attribure.Value;
                if (bsonDocument.Contains(key))
                    bsonDocument.Set(key, value);
                else
                    bsonDocument.Add(key, value);
            }
            foreach (XElement kid in xElement.Descendants())
            {
                var id = kid.Attribute(Constants._ID);
                if (id == null || mainId == null)
                {
                    bsonDocument.Add(kid.Name.ToString(), kid.ToBsonDocument());
                }
                else
                {
                    kid.SetAttributeValue(Constants.PARENT_ID, mainId);
                    DBFactory.GetData().Save(kid);
                }
            }
            return bsonDocument;
        }
开发者ID:bperreault,项目名称:autox,代码行数:32,代码来源:BsonDocumentExt.cs

示例3: UpdateXElement

 internal static void UpdateXElement(this XElement element, SettingsInfo settings, XNamespace ns)
 {
     element.Attribute("ID").Value = settings.Id.ToString();
     element.Attribute("processorRef").Value = settings.Processor.Id.ToString();
     element.Element(ns + "name").Value = settings.Name;
     element.Element(ns + "serialPortSettings").UpdateXElement(settings.SerialPortSettings, ns);
 }
开发者ID:KiselevKN,项目名称:BootMega,代码行数:7,代码来源:SettingsInfoExtensions.cs

示例4: ParseSeatGroup

 static SeatGroup ParseSeatGroup(this XElement cell)
 {
     return new HtmlSeatGroup(
         (string)cell.Attribute("data-person"),
         (int)cell.Attribute("data-count")
     );
 }
开发者ID:SyedArifulIslamEmon,项目名称:Billing,代码行数:7,代码来源:HtmlChartParser.cs

示例5: GetColor

 public static Color GetColor(this XElement element, string name, string defaultColor) {
     return
         ColorReflector.ToColorFromHex(element.Attribute(name) != null
             ? element.Attribute(name).Value
             : element.Attribute(defaultColor).Value);
     //return (Color) ColorConverter.ConvertFromString(element.Attribute(name).Value);
 }
开发者ID:TNOCS,项目名称:csTouch,代码行数:7,代码来源:XElementExt.cs

示例6: GetNullColor

 public static Color? GetNullColor(this XElement element, string name)
 {
     return element.Attribute(name) != null
         ? ColorReflector.ToColorFromHex(element.Attribute(name).Value)
         : new Color?();
     //return (Color) ColorConverter.ConvertFromString(element.Attribute(name).Value);
 }
开发者ID:TNOCS,项目名称:csTouch,代码行数:7,代码来源:XElementExt.cs

示例7: GetAttribute

 public static string GetAttribute(this XElement element, string attributeName)
 {
     if (!element.HasAttributes ||
         element.Attribute(attributeName) == null ||
         string.IsNullOrEmpty(element.Attribute(attributeName).Value))
         return string.Empty;
     return element.Attribute(attributeName).Value;
 }
开发者ID:Indomitable,项目名称:monodevelop-tfs-addin,代码行数:8,代码来源:Extender.cs

示例8: GetPortalSetting

 public static PortalSettings GetPortalSetting(this XElement element, string id)
 {
     var portalItem = new PortalSettings();
     portalItem.AlwaysShowEditButton = Convert.ToBoolean(element.Attribute("AlwaysShowEditButton").Value);
     portalItem.PortalName = element.Attribute("PortalName").Value;
     portalItem.PortalId = id;
     return portalItem;
 }
开发者ID:Raconeisteron,项目名称:bakopanos,代码行数:8,代码来源:XmlPortalCfgHelper.cs

示例9: GenerateXPathFromXElement

        public static string GenerateXPathFromXElement(this XElement xUi)
        {
            var original = xUi.GetAttributeValue("XPath");
            if (!String.IsNullOrEmpty(original))
                return original;
            var tag = "//*";
            var xTag = xUi.Attribute("tag");
            var xType = xUi.Attribute("type");
            if (xType != null)
            {
                if (xType.Value.Equals("a"))
                {
                    tag = "//a";
                    xType.Remove();
                }
                if(xType.Value.Equals("table")||xType.Value.Equals("div"))
                {
                    var textAttr = xUi.Attribute("text");
                    if(textAttr!=null) textAttr.Remove();
                }

            }
            if (xTag != null)
            {
                tag = "//" + xTag.Value;
                xTag.Remove();
            }
            var xpath = tag;
            if (xUi.Attributes().Any())
            {
                xpath = xpath + "[";
                var count = 0;
                foreach (XAttribute xa in xUi.Attributes())
                {
                    var key = xa.Name.ToString();
                    if (key.StartsWith("_"))
                        continue;
                    var value = xa.Value;
                    if (count > 0)
                        xpath = xpath + " and ";
                    if (key.Equals("text"))
                    {
                        if (value.Length < 32)
                            xpath = xpath + key + "()='" + value + "' ";
                        else
                        {
                            xpath = xpath + "contains(text(),'" + value.Substring(0, 16) + "') ";
                        }
                    }

                    else
                        xpath = xpath + "@" + key + "='" + value + "' ";
                    count++;
                }
                xpath = xpath + "]";
            }
            return xpath;
        }
开发者ID:bperreault,项目名称:autox,代码行数:58,代码来源:XElementExt.cs

示例10: ToProcessor

 internal static Processor ToProcessor(this XElement element, XNamespace ns)
 {
     return new Processor(Convert.ToInt32(element.Attribute("ID").Value, 10),
         element.Attribute("Name").Value,
         Convert.ToInt32(element.Element(ns + "eepromSize").Value, 16),
         Convert.ToInt32(element.Element(ns + "flashSize").Value, 16),
         Convert.ToInt32(element.Element(ns + "bootStartAddress").Value, 16),
         Convert.ToInt32(element.Element(ns + "bootEndAddress").Value, 16));
 }
开发者ID:KiselevKN,项目名称:BootMega,代码行数:9,代码来源:ProcessorExtensions.cs

示例11: ToField

        public static Field ToField(this XElement f)
        {
            if (f.Name != Constants.Field)
            {
                throw new ArgumentException("Invalid argument.", "f");
            }

            return new Field(f.Attribute(Constants.Name).Value, f.Attribute(Constants.Required).Value == Constants.True);
        }
开发者ID:unreadable,项目名称:QuickFixn.Wrapper,代码行数:9,代码来源:MessagesSectionParsers.cs

示例12: ParseXYZ

 public static Vector3 ParseXYZ(this XElement element, Vector3 defaultValue)
 {
     return new Vector3
     (
         element.Attribute("x").ToFloat(defaultValue.x),
         element.Attribute("y").ToFloat(defaultValue.y),
         element.Attribute("z").ToFloat(defaultValue.z)
     );
 }
开发者ID:nigelchanyk,项目名称:Archetype,代码行数:9,代码来源:XmlHelper.cs

示例13: IsNullOrNullContract

        /// <summary>
        /// Returns true if this XElement is null, or an obix:Null contract.
        /// </summary>
        /// <returns>true if this XElement is null or a null contract, false otherwise.</returns>
        public static bool IsNullOrNullContract(this XElement element) {
            if (element == null) {
                return true;
            }

            return element.HasAttributes 
                && element.Attribute("null") != null 
                && element.Attribute("null").Value == "true";
        }
开发者ID:minzdrav,项目名称:NetBIX,代码行数:13,代码来源:XElement.ObixExtensions.cs

示例14: GetValue

        public static string GetValue(this XElement self, string attributeName, bool toLower = true)
        {
            if (self.Attribute(attributeName) == null)
                return null;

            return toLower ?
                self.Attribute(attributeName).Value.ToLowerInvariant() :
                self.Attribute(attributeName).Value;
        }
开发者ID:vlad-zapp,项目名称:AssemblyChecker,代码行数:9,代码来源:Helpers.cs

示例15: IsAttributeSetToValue

 internal static bool IsAttributeSetToValue(this XElement element, string attributeName, string expectedValue)
 {
     return element.Attribute(attributeName) != null
         ? string.Equals(
             element.Attribute(attributeName).Value,
             expectedValue,
             StringComparison.InvariantCultureIgnoreCase)
         : false;
 }
开发者ID:picklesdoc,项目名称:pickles,代码行数:9,代码来源:NUnitXElementExtensions.cs


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