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


C# XmlElement.SetAttribute方法代码示例

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


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

示例1: SaveNotificationToXml

 public override void SaveNotificationToXml(INotification notification, XmlElement notificationElement)
 {
     var n = notification as IconNotification;
     notificationElement.SetAttribute("notificationText", n.NotificationText);
     notificationElement.SetAttribute("flashIconPath", n.FlashIconPath);
     notificationElement.SetAttribute("flashCount", n.FlashCount.ToString());
 }
开发者ID:kristiandupont,项目名称:CherryTomato-classic,代码行数:7,代码来源:IconNotifier.cs

示例2: SaveXml

		/// <summary>
		/// Salva definições em um xml
		/// </summary>
		public override void SaveXml(XmlDocument doc, XmlElement element)
		{
			base.SaveXml (doc, element);

			element.SetAttribute("prefixo", prefixo);
			element.SetAttribute("sufixo", sufixo);
		}
开发者ID:andrepontesmelo,项目名称:imjoias,代码行数:10,代码来源:Peso.cs

示例3: SaveCecilXml

		internal void SaveCecilXml (XmlElement elem)
		{
			elem.SetAttribute ("name", name);
			elem.SetAttribute ("type", type.FullName);
			if (!canWrite)
				elem.SetAttribute ("canWrite", "false");
		}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:7,代码来源:CecilPropertyDescriptor.cs

示例4: MappingCondition

        internal MappingCondition(EDMXFile parentFile, EntitySetMapping entitySetMapping, XmlElement entitySetMappingElement, ModelEntityType modelEntityType, StoreMemberProperty discriminatorColumn, string discriminatorValue)
            : base(parentFile)
        {
            _entitySetMapping = entitySetMapping;
            _modelEntityType = modelEntityType;
            _discriminatorColumn = discriminatorColumn;

            string storeEntitySetName = discriminatorColumn.EntityType.EntitySet.Name;

            //get hold of the type mapping
            _entityTypeMapping = (XmlElement)entitySetMappingElement.SelectSingleNode("map:EntityTypeMapping[@TypeName=" + XmlHelpers.XPathLiteral(modelEntityType.FullName) + " or @TypeName=" + XmlHelpers.XPathLiteral("IsTypeOf(" + modelEntityType.FullName + ")") + " or @TypeName=" + XmlHelpers.XPathLiteral(modelEntityType.AliasName) + " or @TypeName=" + XmlHelpers.XPathLiteral("IsTypeOf(" + modelEntityType.AliasName + ")") + "]", NSM);
            if (_entityTypeMapping == null)
            {
                throw new ArgumentException("The entity type " + modelEntityType.Name + " is not a participant in this entity set mapping.");
            }

            _mappingFragment = (XmlElement)_entityTypeMapping.SelectSingleNode("map:MappingFragment[@StoreEntitySet=" + XmlHelpers.XPathLiteral(storeEntitySetName) + "]", NSM);
            if (_mappingFragment == null)
            {
                throw new ArgumentException("The store entityset " + storeEntitySetName + " is not a participant in this entity set mapping.");
            }

            _mappingCondition = EDMXDocument.CreateElement("Condition", NameSpaceURImap);
            _mappingCondition.SetAttribute("ColumnName", discriminatorColumn.Name);
            if (discriminatorValue != null)
            {
                _mappingCondition.SetAttribute("Value", discriminatorValue);
            }
            else
            {
                _mappingCondition.SetAttribute("IsNull", "true");
            }
            _mappingFragment.AppendChild(_mappingCondition);
        }
开发者ID:KristoferA,项目名称:HuagatiEDMXTools,代码行数:34,代码来源:MappingCondition.cs

示例5: PropsToXmlAttr

        /// <summary>
        /// Assigns each property of a class to an XML attribute for a given Element
        /// </summary>
        /// <param name="doc">XmlDocument used to create elements</param>
        /// <param name="obj">Class whose properties are to be serialized</param>
        /// <param name="elem">Element to add attributes to</param>
        /// <returns>The same XmlElement, for brevity of code</returns>
        static XmlElement PropsToXmlAttr(XmlDocument doc, object obj, XmlElement elem)
        {
            foreach (PropertyInfo pi in obj.GetType().GetProperties(BindingFlags.Public | BindingFlags.DeclaredOnly | BindingFlags.Instance))
            {
                if (pi.GetValue(obj) != null && pi.GetValue(obj).ToString() != "")
                {
                    DefaultValueAttribute dvAttr = (DefaultValueAttribute)Attribute.GetCustomAttribute(pi, typeof(DefaultValueAttribute));

                    if (dvAttr == null)
                    {
                        elem.SetAttribute(pi.Name, pi.GetValue(obj).ToString());
                    }
                    else
                    {
                        if(dvAttr.Value.ToLower() == pi.GetValue(obj).ToString().ToLower()) {
                            Console.WriteLine("Default value of {0} skipped for {1}", dvAttr.Value, pi.Name);
                        }
                        else 
                        {
                            Console.WriteLine("Default value of {0} overwritten by {1} for {2}", dvAttr.Value, pi.GetValue(obj).ToString(), pi.Name);
                            elem.SetAttribute(pi.Name, pi.GetValue(obj).ToString());
                        }
                    }
                }
            }
            return elem;
        }
开发者ID:Strongc,项目名称:WinObjC,代码行数:34,代码来源:Program.cs

示例6: putIntoElement

 public virtual void putIntoElement(XmlElement cur)
 {
     cur.SetAttribute("name", Name);
     cur.SetAttribute("owner", Owner);
     cur.SetAttribute("borrower", Borrower);
     cur.SetAttribute("category", Category);
 }
开发者ID:regalcat,项目名称:LoanShark,代码行数:7,代码来源:ItemBaseClass.cs

示例7: ApplyHashIfApplicable

        private static void ApplyHashIfApplicable(XmlElement linkElement, Localization localization)
        {
            string target = linkElement.GetAttribute("target").ToLower();
            if (target != "anchored")
            {
                return;
            }

            string href = linkElement.GetAttribute("href");

            bool samePage = string.Equals(href,
                    HttpContext.Current.Request.Url.AbsolutePath, // TODO: should not be using HttpContext at this level
                    StringComparison.OrdinalIgnoreCase
                    );

            string linkTitle = GetLinkTitle(linkElement, localization);

            string fragmentId = string.Empty;
            if (!string.IsNullOrEmpty(linkTitle))
            {
                fragmentId = '#' + linkTitle.Replace(" ", "_").ToLower();
            }

            linkElement.SetAttribute("href", (!samePage ? href : string.Empty) + fragmentId);
            linkElement.SetAttribute("target", !samePage ? "_top" : string.Empty);
        }
开发者ID:ginortoro,项目名称:dxa-web-application-dotnet,代码行数:26,代码来源:DefaultRichTextProcessor.cs

示例8: HandleAttributes

 void HandleAttributes(XmlElement gapi_elem)
 {
     bool needs_array = true;
     foreach (XmlAttribute attr in elem.Attributes) {
         switch (attr.Name) {
         case "c:type":
             gapi_elem.SetAttribute ("type", attr.Value);
             break;
         case "fixed-size":
             gapi_elem.SetAttribute ("array_len", attr.Value);
             break;
         case "length":
             gapi_elem.SetAttribute ("length_param", attr.Value);
             break;
         case "name":
             if (!elem.HasAttribute ("c:type"))
                 gapi_elem.SetAttribute ("type", SymbolTable.Lookup (attr.Value));
             needs_array = false;
             break;
         default:
             Console.WriteLine ("Unexpected attribute on array element: " + attr.Name);
             break;
         }
     }
     if (needs_array)
         gapi_elem.SetAttribute ("array", "1");
 }
开发者ID:mkestner,项目名称:gir2gapi,代码行数:27,代码来源:Array.cs

示例9: SaveNotificationToXml

 public override void SaveNotificationToXml(INotification notification, XmlElement notificationElement)
 {
     var n = notification as PopupNotification;
     notificationElement.SetAttribute("notificationText", n.NotificationText);
     notificationElement.SetAttribute("caption", n.Caption);
     notificationElement.SetAttribute("icon", n.Icon.ToString());
 }
开发者ID:kristiandupont,项目名称:CherryTomato-classic,代码行数:7,代码来源:PopupNotifier.cs

示例10: SaveConditionToXml

 public override void SaveConditionToXml(ICondition condition, XmlElement conditionElement)
 {
     var c = condition as TimeOfDayCondition;
     conditionElement.SetAttribute("start", c.StartTime.ToString());
     conditionElement.SetAttribute("end", c.EndTime.ToString());
     conditionElement.SetAttribute("shouldBeWithin", c.ShouldBeWithin.ToString());
 }
开发者ID:kristiandupont,项目名称:CherryTomato-classic,代码行数:7,代码来源:TimeOfDayConditionChecker.cs

示例11: WriteToXml

 public virtual void WriteToXml(XmlElement parent)
 {
   parent.SetAttribute("projectId", GetProject().GetPersistentID());
   parent.SetAttribute("typeName", TypeName);
   parent.SetAttribute("methodName", FieldName);
   parent.SetAttribute("isIgnored", Explicit.ToString());
 }
开发者ID:jhollingworth,项目名称:machine.specifications,代码行数:7,代码来源:FieldElement.cs

示例12: SaveReminderInternal

        protected override void SaveReminderInternal(IReminder reminder, XmlElement reminderElement)
        {
            var ir = (IntervalReminder)reminder;

            reminderElement.SetAttribute("fromInterval", ir.FromInterval.ToString());
            reminderElement.SetAttribute("toInterval", ir.ToInterval.ToString());
        }
开发者ID:kristiandupont,项目名称:CherryTomato-classic,代码行数:7,代码来源:IntervalReminderPlugin.cs

示例13: TraceToXML

        public TraceToXML(Point beginPoint, String penColor, String penWidth)
        {
            this.beginPoint = beginPoint;
            //创建 XML 对象
            xmlDocument = new XmlDocument();
            //声明 XML
            xmlDeclare = xmlDocument.CreateXmlDeclaration("1.0", "utf-8", null);
            //创建根节点
            elementRoot = xmlDocument.CreateElement("Trace");
            xmlDocument.AppendChild(elementRoot);

            //创建第一个节点
            //创建节点 Section
            elementSection = xmlDocument.CreateElement("Section");
            elementSection.SetAttribute("penColor", penColor);
            elementSection.SetAttribute("penWidth", penWidth);
            elementRoot.AppendChild(elementSection);
            //创建 Section 的子节点 Point
            XmlElement elementPoint = xmlDocument.CreateElement("Point");
            elementPoint.SetAttribute("time", "0");
            XmlElement elementX = xmlDocument.CreateElement("X");
            elementX.InnerText = beginPoint.X.ToString();
            elementPoint.AppendChild(elementX);
            XmlElement elementY = xmlDocument.CreateElement("Y");
            elementY.InnerText = beginPoint.Y.ToString();
            elementPoint.AppendChild(elementY);
            elementSection.AppendChild(elementPoint);
        }
开发者ID:zlmoment,项目名称:DrawSthCSharp,代码行数:28,代码来源:TraceToXML.cs

示例14: NavigationProperty

        internal NavigationProperty(EDMXFile parentFile, ModelEntityType modelEntityType, string name, ModelAssociationSet modelAssociationSet, XmlElement entityTypeElement, string fromRoleName, string toRoleName)
            : base(parentFile)
        {
            _modelEntityType = modelEntityType;

            _propertyElement = EDMXDocument.CreateElement("NavigationProperty", NameSpaceURIcsdl);
            _propertyElement.SetAttribute("Relationship", modelAssociationSet.FullName);

            if (string.IsNullOrEmpty(fromRoleName) || string.IsNullOrEmpty(toRoleName))
            {
                if (modelAssociationSet.FromEntityType == _modelEntityType)
                {
                    fromRoleName = modelAssociationSet.FromRoleName;
                    toRoleName = modelAssociationSet.ToRoleName;
                }
                else
                {
                    fromRoleName = modelAssociationSet.ToRoleName;
                    toRoleName = modelAssociationSet.FromRoleName;
                }
            }

            _propertyElement.SetAttribute("FromRole", fromRoleName);
            _propertyElement.SetAttribute("ToRole", toRoleName);

            entityTypeElement.AppendChild(_propertyElement);

            Name = name;
        }
开发者ID:KristoferA,项目名称:HuagatiEDMXTools,代码行数:29,代码来源:NavigationProperty.cs

示例15: StoryStarting

 public void StoryStarting(Story story)
 {
     _currentStoryElement = _doc.CreateElement(XmlNames.Story);
     _currentStoryElement.SetAttribute(XmlNames.Id, story.Id);
     _currentStoryElement.SetAttribute(XmlNames.Summary, story.Summary);
     SetStatus(_currentStoryElement, StatusNames.Success);
     _doc.DocumentElement.AppendChild(_currentStoryElement);
 }
开发者ID:codereflection,项目名称:storevil,代码行数:8,代码来源:XmlReportListener.cs


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