本文整理汇总了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);
}
示例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);
}
}
示例3: SetXmlNodeMD5
private static void SetXmlNodeMD5(XmlElement node, string relativePath)
{
string md5 = GetFileMD5(Preferences.GetString("客户端资源导出路径") + "/" +
ResourceManager.GetExportFileName(relativePath));
node.SetAttribute("md5", md5);
}
示例4: SetXmlNodeFilePath
private static void SetXmlNodeFilePath(XmlElement node, string relativePath)
{
node.SetAttribute("path", relativePath);
}
示例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);
}
}
示例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);
}
示例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)
{
}
}
示例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;
//.........这里部分代码省略.........
示例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() );
}
示例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);
}
示例11: WriteToXMLElement
public void WriteToXMLElement( XmlElement xmlelement )
{
xmlelement.SetAttribute( "x", x.ToString() );
xmlelement.SetAttribute( "y", y.ToString() );
xmlelement.SetAttribute( "z", z.ToString() );
}
示例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();
}
}
示例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);
}
}
}
示例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);
}
示例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;
}