本文整理汇总了C#中System.Xml.XmlAttributeCollection.InsertBefore方法的典型用法代码示例。如果您正苦于以下问题:C# XmlAttributeCollection.InsertBefore方法的具体用法?C# XmlAttributeCollection.InsertBefore怎么用?C# XmlAttributeCollection.InsertBefore使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlAttributeCollection
的用法示例。
在下文中一共展示了XmlAttributeCollection.InsertBefore方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SortAttributes
/// <summary>
/// Sorts an attributes collection alphabeticlly.
/// Uses bubble sort.
/// </summary>
/// <param name="a_toSort">The attribute collection to sort.</param>
public static void SortAttributes(XmlAttributeCollection a_toSort)
{
if (a_toSort == null)
{
return;
}
bool l_change = true;
while (l_change)
{
l_change = false;
for (int i=1; i<a_toSort.Count; i++)
{
if (String.Compare(a_toSort[i].Name, a_toSort[i-1].Name, true) < 0)
{
//Replace
a_toSort.InsertBefore(a_toSort[i], a_toSort[i-1]);
l_change = true;
}
}
}
}
示例2: SortAttributes
/// -----------------------------------------------------------
/// <summary>
/// Sorts an attributes collection alphabetically.
/// It uses the bubble sort algorithm.
/// </summary>
/// <param name="attribCol">The attribute collection to be sorted.</param>
/// -----------------------------------------------------------
public static void SortAttributes(XmlAttributeCollection attribCol)
{
if (attribCol == null)
return;
bool hasChanged = true;
while (hasChanged)
{
hasChanged = false;
for (int i = 1; i < attribCol.Count; i++)
{
if (String.Compare(attribCol[i].Name, attribCol[i - 1].Name, true) < 0)
{
//Replace
attribCol.InsertBefore(attribCol[i], attribCol[i - 1]);
hasChanged = true;
}
}
}
}