本文整理汇总了C#中IFrame.GetCopy方法的典型用法代码示例。如果您正苦于以下问题:C# IFrame.GetCopy方法的具体用法?C# IFrame.GetCopy怎么用?C# IFrame.GetCopy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IFrame
的用法示例。
在下文中一共展示了IFrame.GetCopy方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Merge
public IFrame Merge(IFrame frame0, IFrame frame1, Guid newFrameId)
{
BasicFrame merged = null;
if (frame0.RowCount != frame1.RowCount)
{
throw new ArgumentException(string.Format("The input frames must have the same number of rows before being merged."));
}
if (!(frame0 is BasicFrame))
throw new ArgumentException(string.Format("Invalid type: must be of type {0}.", typeof(BasicFrame).Name), "frame0");
if (!(frame1 is BasicFrame))
throw new ArgumentException(string.Format("Invalid type: must be of type {0}.", typeof(BasicFrame).Name), "frame1");
if (frame0 == frame1)
{
throw new ArgumentException(string.Format("Both input frame parameters represent the same instance. A frame cannot be merged with itself."));
}
BasicFrame baseFrame0 = frame0 as BasicFrame;
BasicFrame baseFrame1 = frame1 as BasicFrame;
merged = frame0.GetCopy(newFrameId) as BasicFrame;
int[] colIndices = new int[baseFrame1.Columns.Count];
for (int i = 0; i < baseFrame1.Columns.Count; i++)
{
string [] existingColNames = merged.ColumnNames;
DataColumn column = new DataColumn(
NamingHelper.MakeUnique(existingColNames, baseFrame1.Columns[i].ColumnName),
baseFrame1.Columns[i].DataType);
colIndices[i] = merged.Columns.Count;
merged.Columns.Add(column);
}
for (int i = 0; i < merged.Rows.Count; i++)
{
for (int j = 0; j < colIndices.Length; j++)
{
merged.Rows[i][colIndices[j]] = baseFrame1.Rows[i][j];
}
}
merged.AcceptChanges();
return merged;
}