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


C# XmlElement.SetAttribute方法代码示例

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


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

示例1: SerializeElement

            public void SerializeElement(XmlElement parent, IUnitTestElement element)
            {
                parent.SetAttribute("type", element.GetType().Name);

                var writableUnitTestElement = (ISerializableUnitTestElement)element;
                writableUnitTestElement.WriteToXml(parent);
            }
开发者ID:briandonahue,项目名称:simple-testing,代码行数:7,代码来源:SimpleTestingElementSerializer.cs

示例2: checkValue

    void checkValue(string valueName, XmlElement ball)
    {
        float tempValue;
        float.TryParse(ball.Attributes[valueName].Value, out tempValue);

        if(tempValue%0.05!=0){
            Debug.Log("Old value were "+tempValue);
            tempValue = Mathf.Round(tempValue * 20) / 20;
            ball.SetAttribute(valueName,tempValue.ToString());
            Debug.Log("New value is "+tempValue);
        }
    }
开发者ID:ringstadjr,项目名称:BubbleShooter3D,代码行数:12,代码来源:LevelXmlSanitizer.cs

示例3: SetXmlNodeMD5

 private static void SetXmlNodeMD5(XmlElement node, string relativePath)
 {
     string md5 = GetFileMD5(Preferences.GetString("客户端资源导出路径") + "/" +
         ResourceManager.GetExportFileName(relativePath));
     node.SetAttribute("md5", md5);
 }
开发者ID:hitomi333,项目名称:eddyserver,代码行数:6,代码来源:BundleExporter.cs

示例4: SetXmlNodeFilePath

 private static void SetXmlNodeFilePath(XmlElement node, string relativePath)
 {
     node.SetAttribute("path", relativePath);
 }
开发者ID:hitomi333,项目名称:eddyserver,代码行数:4,代码来源:BundleExporter.cs

示例5: ApplyPropertiesToTableCellElement

    /// <summary>
    /// Applies properties to xamlTableCellElement based on the html td element it is converted from.
    /// </summary>
    /// <param name="htmlChildNode">
    /// Html td/th element to be converted to xaml
    /// </param>
    /// <param name="xamlTableCellElement">
    /// XmlElement representing Xaml element for which properties are to be processed
    /// </param>
    /// <remarks>
    /// TODO: Use the processed properties for htmlChildNode instead of using the node itself 
    /// </remarks>
    private static void ApplyPropertiesToTableCellElement(XmlElement htmlChildNode, XmlElement xamlTableCellElement)
    {
        // Parameter validation
        Debug.Assert(htmlChildNode.LocalName.ToLower() == "td" || htmlChildNode.LocalName.ToLower() == "th");
        Debug.Assert(xamlTableCellElement.LocalName == Xaml_TableCell);

        // set default border thickness for xamlTableCellElement to enable gridlines
        xamlTableCellElement.SetAttribute(Xaml_TableCell_BorderThickness, "1,1,1,1");
        xamlTableCellElement.SetAttribute(Xaml_TableCell_BorderBrush, Xaml_Brushes_Black);
        string rowSpanString = GetAttribute((XmlElement)htmlChildNode, "rowspan");
        if (rowSpanString != null)
        {
            xamlTableCellElement.SetAttribute(Xaml_TableCell_RowSpan, rowSpanString);
        }
    }
开发者ID:AbabeiAndrei,项目名称:WProject,代码行数:27,代码来源:HtmlToXamlConverter.cs

示例6: ComposeThicknessProperty

    // Create syntactically optimized four-value Thickness
    private static void ComposeThicknessProperty(XmlElement xamlElement, string propertyName, string left, string right, string top, string bottom)
    {
        // Xaml syntax:
        // We have a reasonable interpreation for one value (all four edges), two values (horizontal, vertical),
        // and four values (left, top, right, bottom).
        //  switch (i) {
        //    case 1: return new Thickness(lengths[0]);
        //    case 2: return new Thickness(lengths[0], lengths[1], lengths[0], lengths[1]);
        //    case 4: return new Thickness(lengths[0], lengths[1], lengths[2], lengths[3]);
        //  }
        string thickness;

        // We do not accept negative margins
        if (left[0] == '0' || left[0] == '-') left = "0";
        if (right[0] == '0' || right[0] == '-') right = "0";
        if (top[0] == '0' || top[0] == '-') top = "0";
        if (bottom[0] == '0' || bottom[0] == '-') bottom = "0";

        if (left == right && top == bottom)
        {
            if (left == top)
            {
                thickness = left;
            }
            else
            {
                thickness = left + "," + top;
            }
        }
        else
        {
            thickness = left + "," + top + "," + right + "," + bottom;
        }

        //  Need safer processing for a thickness value
        xamlElement.SetAttribute(propertyName, thickness);
    }
开发者ID:AbabeiAndrei,项目名称:WProject,代码行数:38,代码来源:HtmlToXamlConverter.cs

示例7: SetPropertyValue

 private static void SetPropertyValue(XmlElement xamlElement, DependencyProperty property, string stringValue)
 {
     System.ComponentModel.TypeConverter typeConverter = System.ComponentModel.TypeDescriptor.GetConverter(property.PropertyType);
     try
     {
         object convertedValue = typeConverter.ConvertFromInvariantString(stringValue);
         if (convertedValue != null)
         {
             xamlElement.SetAttribute(property.Name, stringValue);
         }
     }
     catch(Exception)
     {
     }
 }
开发者ID:AbabeiAndrei,项目名称:WProject,代码行数:15,代码来源:HtmlToXamlConverter.cs

示例8: ApplyLocalProperties

    // .............................................................
    //
    // Attributes and Properties
    //
    // .............................................................

    /// <summary>
    /// Analyzes local properties of Html element, converts them into Xaml equivalents, and applies them to xamlElement
    /// </summary>
    /// <param name="xamlElement">
    /// XmlElement representing Xaml element to which properties are to be applied
    /// </param>
    /// <param name="localProperties">
    /// Hashtable representing local properties of Html element that is converted into xamlElement
    /// </param>
    private static void ApplyLocalProperties(XmlElement xamlElement, Hashtable localProperties, bool isBlock)
    {
        bool marginSet = false;
        string marginTop = "0";
        string marginBottom = "0";
        string marginLeft = "0";
        string marginRight = "0";

        bool paddingSet = false;
        string paddingTop = "0";
        string paddingBottom = "0";
        string paddingLeft = "0";
        string paddingRight = "0";

        string borderColor = null;

        bool borderThicknessSet = false;
        string borderThicknessTop = "0";
        string borderThicknessBottom = "0";
        string borderThicknessLeft = "0";
        string borderThicknessRight = "0";

        IDictionaryEnumerator propertyEnumerator = localProperties.GetEnumerator();
        while (propertyEnumerator.MoveNext())
        {
            switch ((string)propertyEnumerator.Key)
            {
                case "font-family":
                    //  Convert from font-family value list into xaml FontFamily value
                    xamlElement.SetAttribute(Xaml_FontFamily, (string)propertyEnumerator.Value);
                    break;
                case "font-style":
                    xamlElement.SetAttribute(Xaml_FontStyle, (string)propertyEnumerator.Value);
                    break;
                case "font-variant":
                    //  Convert from font-variant into xaml property
                    break;
                case "font-weight":
                    xamlElement.SetAttribute(Xaml_FontWeight, (string)propertyEnumerator.Value);
                    break;
                case "font-size":
                    //  Convert from css size into FontSize
                    xamlElement.SetAttribute(Xaml_FontSize, (string)propertyEnumerator.Value);
                    break;
                case "color":
                    SetPropertyValue(xamlElement, TextElement.ForegroundProperty, (string)propertyEnumerator.Value);
                    break;
                case "background-color":
                    SetPropertyValue(xamlElement, TextElement.BackgroundProperty, (string)propertyEnumerator.Value);
                    break;
                case "text-decoration-underline":
                    if (!isBlock)
                    {
                        if ((string)propertyEnumerator.Value == "true")
                        {
                            xamlElement.SetAttribute(Xaml_TextDecorations, Xaml_TextDecorations_Underline);
                        }
                    }
                    break;
                case "text-decoration-none":
                case "text-decoration-overline":
                case "text-decoration-line-through":
                case "text-decoration-blink":
                    //  Convert from all other text-decorations values
                    if (!isBlock)
                    {
                    }
                    break;
                case "text-transform":
                    //  Convert from text-transform into xaml property
                    break;

                case "text-indent":
                    if (isBlock)
                    {
                        xamlElement.SetAttribute(Xaml_TextIndent, (string)propertyEnumerator.Value);
                    }
                    break;

                case "text-align":
                    if (isBlock)
                    {
                        xamlElement.SetAttribute(Xaml_TextAlignment, (string)propertyEnumerator.Value);
                    }
                    break;
//.........这里部分代码省略.........
开发者ID:AbabeiAndrei,项目名称:WProject,代码行数:101,代码来源:HtmlToXamlConverter.cs

示例9: WriteToXMLElement

 //! Writes values to passed-in xml element, <someelement r="..." g="..." b="..."/>
 public void WriteToXMLElement( XmlElement xmlelement )
 {
     xmlelement.SetAttribute( "r", r.ToString() );
         xmlelement.SetAttribute( "g", g.ToString() );
         xmlelement.SetAttribute( "b", b.ToString() );
         xmlelement.SetAttribute( "a", a.ToString() );
 }
开发者ID:hughperkins,项目名称:SpringMapDesigner,代码行数:8,代码来源:Color.cs

示例10: SetXmlNodeMD5

    //private static void SetXmlNodeMD5(XmlElement node, string relativePath)
    //{
    //    SetXmlNodeMD5(node, Preferences.GetString("客户端资源导出路径"), relativePath);
    //}

    private static void SetXmlNodeMD5(XmlElement node, string rootPath, string relativePath, bool needSuffix = true)
    {
        string md5 = GetFileMD5(String.Concat(rootPath, "/", needSuffix ? ResourceManager.WithSuffix(relativePath) : relativePath));
        node.SetAttribute("md5", md5);
    }
开发者ID:lbddk,项目名称:ahzs-client,代码行数:10,代码来源:BundleExporter.cs

示例11: WriteToXMLElement

 public void WriteToXMLElement( XmlElement xmlelement )
 {
     xmlelement.SetAttribute( "x", x.ToString() );
         xmlelement.SetAttribute( "y", y.ToString() );
         xmlelement.SetAttribute( "z", z.ToString() );
 }
开发者ID:hughperkins,项目名称:SpringMapDesigner,代码行数:6,代码来源:Vector3.cs

示例12: ParseAttributes

    private void ParseAttributes(XmlElement xmlElement)
    {
        while (_htmlLexicalAnalyzer.NextTokenType != HtmlTokenType.EOF && //
               _htmlLexicalAnalyzer.NextTokenType != HtmlTokenType.TagEnd && //
               _htmlLexicalAnalyzer.NextTokenType != HtmlTokenType.EmptyTagEnd)
        {
            // read next attribute (name=value)
            if (_htmlLexicalAnalyzer.NextTokenType == HtmlTokenType.Name)
            {
                string attributeName = _htmlLexicalAnalyzer.NextToken;
                _htmlLexicalAnalyzer.GetNextEqualSignToken();

                _htmlLexicalAnalyzer.GetNextAtomToken();

                string attributeValue = _htmlLexicalAnalyzer.NextToken;
                xmlElement.SetAttribute(attributeName, attributeValue);
            }
            _htmlLexicalAnalyzer.GetNextTagToken();
        }
    }
开发者ID:AbabeiAndrei,项目名称:WProject,代码行数:20,代码来源:HtmlParser.cs

示例13: MakeEntityElement

	private void MakeEntityElement(UnityEngine.GameObject obj, XmlElement entityElement)
	{

		if(obj == null)
		{
			entityElement.SetAttribute(OCEmbodimentXMLTags.ID_ATTRIBUTE, "null");
			entityElement.SetAttribute(OCEmbodimentXMLTags.TYPE_ATTRIBUTE, OCEmbodimentXMLTags.UNKNOWN_OBJECT_TYPE);
		} else
		{
			string targetType = obj.tag;
			if(targetType == "OCA" || targetType == "Player")// it's an avatar
			{
				entityElement.SetAttribute(OCEmbodimentXMLTags.ID_ATTRIBUTE, obj.GetInstanceID().ToString());
				entityElement.SetAttribute(OCEmbodimentXMLTags.TYPE_ATTRIBUTE, OCEmbodimentXMLTags.AVATAR_OBJECT_TYPE);
			} else // it's an object
			{
				entityElement.SetAttribute(OCEmbodimentXMLTags.ID_ATTRIBUTE, obj.GetInstanceID().ToString());
				entityElement.SetAttribute(OCEmbodimentXMLTags.TYPE_ATTRIBUTE, OCEmbodimentXMLTags.ORDINARY_OBJECT_TYPE);
			}
		}
	}
开发者ID:Nemquae,项目名称:unity3d-opencog-game,代码行数:21,代码来源:OCConnectorSingleton.cs

示例14: writeLoadLevel

		static void writeLoadLevel(XmlElement gameObject, string [] names)
		{
			gameObject.SetAttribute("loadPri", names[2]);
			
			string cmd = names[0];
			string loadlevel = "0";
			string unloadlevel = "0";
			
			if(cmd.IndexOf("*") != -1)
			{
				loadlevel = "2";
			}
			
			if(cmd.IndexOf("!") != -1)
			{
				loadlevel = "1";
			}
	
			if(cmd.IndexOf("-") != -1)
			{
				loadlevel = "3";
			}

			if(cmd.IndexOf("#") != -1)
			{
				loadlevel = "4";
			}
			
			if(cmd.IndexOf("+") != -1)
			{
				unloadlevel = "1";
			}

			if(cmd.IndexOf("&") != -1)
			{
				unloadlevel = "2";
			}
			
			gameObject.SetAttribute("load", loadlevel);
			gameObject.SetAttribute("unload", unloadlevel);
		}
开发者ID:GamesDesignArt,项目名称:kbengine_unity3d_warring,代码行数:41,代码来源:ExprotAssetBundles.cs

示例15: AddTrends

    private XmlElement AddTrends(XmlDocument xmlDoc, XmlElement player1, XmlElement player2, XmlElement xmlElement)
    {
        XmlElement trendline = xmlDoc.CreateElement("trendLines");
        XmlElement tmpElement;
        double gpPlayer1 = player1.ChildNodes.Count;
        double gpPlayer2 = player2.ChildNodes.Count;
        int player1MaxValue = Convert.ToInt32(player1.LastChild.Attributes.GetNamedItem("value").Value);
        int player2MaxValue = Convert.ToInt32(player2.LastChild.Attributes.GetNamedItem("value").Value);
        if(gpPlayer1 >= gpPlayer2)
        {
            tmpElement = xmlDoc.CreateElement("line");
            tmpElement.SetAttribute("startValue", "0");
            tmpElement.SetAttribute("endValue", Convert.ToString(player1MaxValue));
            tmpElement.SetAttribute("color", "#660000");
            trendline.AppendChild(tmpElement);

            double player2FinalValue = Convert.ToInt32(player2.LastChild.Attributes.GetNamedItem("value").Value);
            int player2ProjectedFinal = Convert.ToInt32((gpPlayer1 / gpPlayer2) * player2FinalValue);

            if (player2ProjectedFinal > player1MaxValue)
            {
                xmlElement.SetAttribute("yAxisMaxValue", player2ProjectedFinal.ToString());
            }

            tmpElement = xmlDoc.CreateElement("line");
            tmpElement.SetAttribute("startValue", "0");
            tmpElement.SetAttribute("color", "#000066");
            tmpElement.SetAttribute("endValue", Convert.ToString(player2ProjectedFinal));
            trendline.AppendChild(tmpElement);
        }
        else if (gpPlayer1 < gpPlayer2)
        {
            tmpElement = xmlDoc.CreateElement("line");
            tmpElement.SetAttribute("startValue", "0");
            tmpElement.SetAttribute("endValue", Convert.ToString(player2MaxValue));
            tmpElement.SetAttribute("color", "#000066");
            trendline.AppendChild(tmpElement);

            double player1FinalValue = Convert.ToInt32(player1.LastChild.Attributes.GetNamedItem("value").Value);
            int player1ProjectedFinal = Convert.ToInt32((gpPlayer2/gpPlayer1)*player1FinalValue);
            if(player1ProjectedFinal > player2MaxValue)
            {
                xmlElement.SetAttribute("yAxisMaxValue", player1ProjectedFinal.ToString());
            }
            tmpElement = xmlDoc.CreateElement("line");
            tmpElement.SetAttribute("startValue", "0");
            tmpElement.SetAttribute("color", "#660000");
            tmpElement.SetAttribute("endValue", Convert.ToString(player1ProjectedFinal));
            trendline.AppendChild(tmpElement);
        }

        return trendline;
    }
开发者ID:Aphramzo,项目名称:AnAvalancheOfStats,代码行数:53,代码来源:PlayerCompareChart.aspx.cs


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