本文整理汇总了C#中FieldList.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# FieldList.Clone方法的具体用法?C# FieldList.Clone怎么用?C# FieldList.Clone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FieldList
的用法示例。
在下文中一共展示了FieldList.Clone方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VisitFieldList
public virtual Differences VisitFieldList(FieldList list1, FieldList list2,
out FieldList changes, out FieldList deletions, out FieldList insertions){
changes = list1 == null ? null : list1.Clone();
deletions = list1 == null ? null : list1.Clone();
insertions = list1 == null ? new FieldList() : list1.Clone();
//^ assert insertions != null;
Differences differences = new Differences();
//Compare definitions that have matching key attributes
TrivialHashtable matchingPosFor = new TrivialHashtable();
TrivialHashtable matchedNodes = new TrivialHashtable();
for (int j = 0, n = list2 == null ? 0 : list2.Count; j < n; j++){
//^ assert list2 != null;
Field nd2 = list2[j];
if (nd2 == null || nd2.Name == null) continue;
matchingPosFor[nd2.Name.UniqueIdKey] = j;
insertions.Add(null);
}
for (int i = 0, n = list1 == null ? 0 : list1.Count; i < n; i++){
//^ assert list1 != null && changes != null && deletions != null;
Field nd1 = list1[i];
if (nd1 == null || nd1.Name == null) continue;
object pos = matchingPosFor[nd1.Name.UniqueIdKey];
if (!(pos is int)) continue;
//^ assert pos != null;
//^ assume list2 != null; //since there was entry int matchingPosFor
int j = (int)pos;
Field nd2 = list2[j];
//^ assume nd2 != null;
//nd1 and nd2 have the same key attributes and are therefore treated as the same entity
matchedNodes[nd1.UniqueKey] = nd1;
matchedNodes[nd2.UniqueKey] = nd2;
//nd1 and nd2 may still be different, though, so find out how different
Differences diff = this.VisitField(nd1, nd2);
if (diff == null){Debug.Assert(false); continue;}
if (diff.NumberOfDifferences != 0){
changes[i] = diff.Changes as Field;
deletions[i] = diff.Deletions as Field;
insertions[i] = diff.Insertions as Field;
insertions[n+j] = nd1; //Records the position of nd2 in list2 in case the change involved a permutation
Debug.Assert(diff.Changes == changes[i] && diff.Deletions == deletions[i] && diff.Insertions == insertions[i]);
differences.NumberOfDifferences += diff.NumberOfDifferences;
differences.NumberOfSimilarities += diff.NumberOfSimilarities;
continue;
}
changes[i] = null;
deletions[i] = null;
insertions[i] = null;
insertions[n+j] = nd1; //Records the position of nd2 in list2 in case the change involved a permutation
}
//Find deletions
for (int i = 0, n = list1 == null ? 0 : list1.Count; i < n; i++){
//^ assert list1 != null && changes != null && deletions != null;
Field nd1 = list1[i];
if (nd1 == null) continue;
if (matchedNodes[nd1.UniqueKey] != null) continue;
changes[i] = null;
deletions[i] = nd1;
insertions[i] = null;
differences.NumberOfDifferences += 1;
}
//Find insertions
for (int j = 0, n = list1 == null ? 0 : list1.Count, m = list2 == null ? 0 : list2.Count; j < m; j++){
//^ assert list2 != null;
Field nd2 = list2[j];
if (nd2 == null) continue;
if (matchedNodes[nd2.UniqueKey] != null) continue;
insertions[n+j] = nd2; //Records nd2 as an insertion into list1, along with its position in list2
differences.NumberOfDifferences += 1; //REVIEW: put the size of the tree here?
}
if (differences.NumberOfDifferences == 0){
changes = null;
deletions = null;
insertions = null;
}
return differences;
}
示例2: VisitFieldList
public override FieldList VisitFieldList(FieldList fields)
{
if (fields == null) return null;
return base.VisitFieldList(fields.Clone());
}