本文整理汇总了C#中Novacode.List.Count方法的典型用法代码示例。如果您正苦于以下问题:C# List.Count方法的具体用法?C# List.Count怎么用?C# List.Count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Novacode.List
的用法示例。
在下文中一共展示了List.Count方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetFormattedTextRecursive
internal static void GetFormattedTextRecursive(XElement Xml, ref List<FormattedText> alist)
{
FormattedText ft = ToFormattedText(Xml);
FormattedText last = null;
if (ft != null)
{
if (alist.Count() > 0)
last = alist.Last();
if (last != null && last.CompareTo(ft) == 0)
{
// Update text of last entry.
last.text += ft.text;
}
else
{
if (last != null)
ft.index = last.index + last.text.Length;
alist.Add(ft);
}
}
if (Xml.HasElements)
foreach (XElement e in Xml.Elements())
GetFormattedTextRecursive(e, ref alist);
}
示例2: Remove
/// <summary>
/// Remove this Paragraph from the document.
/// </summary>
/// <param name="trackChanges">Should this remove be tracked as a change?</param>
/// <example>
/// Remove a Paragraph from a document and track it as a change.
/// <code>
/// // Create a document using a relative filename.
/// using (DocX document = DocX.Load(@"C:\Example\Test.docx"))
/// {
/// // Create and Insert a new Paragraph into this document.
/// Paragraph p = document.InsertParagraph("Hello", false);
///
/// // Remove the Paragraph and track this as a change.
/// p.Remove(true);
///
/// // Save all changes made to this document.
/// document.Save();
/// }// Release this document from memory.
/// </code>
/// </example>
public void Remove(bool trackChanges)
{
if (trackChanges)
{
DateTime now = DateTime.Now.ToUniversalTime();
List<XElement> elements = Xml.Elements().ToList();
List<XElement> temp = new List<XElement>();
for (int i = 0; i < elements.Count(); i++)
{
XElement e = elements[i];
if (e.Name.LocalName != "del")
{
temp.Add(e);
e.Remove();
}
else
{
if (temp.Count() > 0)
{
e.AddBeforeSelf(CreateEdit(EditType.del, now, temp.Elements()));
temp.Clear();
}
}
}
if (temp.Count() > 0)
Xml.Add(CreateEdit(EditType.del, now, temp));
}
else
{
// If this is the only Paragraph in the Cell then we cannot remove it.
if (Xml.Parent.Name.LocalName == "tc" && Xml.Parent.Elements(XName.Get("p", DocX.w.NamespaceName)).Count() == 1)
Xml.Value = string.Empty;
else
{
// Remove this paragraph from the document
Xml.Remove();
Xml = null;
}
}
}