本文整理汇总了C#中System.Xml.XmlWriter.CreateRow方法的典型用法代码示例。如果您正苦于以下问题:C# XmlWriter.CreateRow方法的具体用法?C# XmlWriter.CreateRow怎么用?C# XmlWriter.CreateRow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlWriter
的用法示例。
在下文中一共展示了XmlWriter.CreateRow方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateProductNetwork
private void GenerateProductNetwork(XmlWriter writer)
{
var items = categories.GroupBy(x => x.Project)
.Select(x => new
{
Project = x.Key,
Contributors = x.SelectMany(y => y.Contributions.Select(z => z.Contributor).Distinct()).ToList()
}).ToList();
// Setup reporting
var totalCount = items.Count * items.Count * 3 / 2;
var count = 0;
var progress = 0;
// Build grid
var grid = new int[items.Count, items.Count];
for (var row = 0; row < items.Count; row++)
{
for (var col = row + 1; col < items.Count; col++)
{
var intersectCount = items[row].Contributors.Intersect(items[col].Contributors).Count();
grid[row, col] = intersectCount;
// Report
count++;
progress = count * 100 / totalCount;
ReportProgress(progress);
}
}
// Setup header
writer.CreateRow()
.WriteCell(string.Empty);
foreach (var item in items)
writer.WriteCell(item.Project, true);
writer.CloseRow();
// populate data
for (var row = 0; row < items.Count; row++)
{
writer.CreateRow()
.WriteCell(items[row].Project, true);
for (var col = 0; col < items.Count; col++)
{
if (col == row)
writer.WriteCell(string.Empty);
else if (col < row)
writer.WriteCell(grid[col, row].ToString());
else
writer.WriteCell(grid[row, col].ToString());
// Report
count++;
progress = count * 100 / totalCount;
ReportProgress(progress);
}
writer.CloseRow();
}
}