本文整理汇总了C#中Event.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# Event.Clone方法的具体用法?C# Event.Clone怎么用?C# Event.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Event
的用法示例。
在下文中一共展示了Event.Clone方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VisitEvent
public virtual Differences VisitEvent(Event evnt1, Event evnt2){
Differences differences = this.GetMemberDifferences(evnt1, evnt2);
if (differences == null){Debug.Assert(false); differences = new Differences(evnt1, evnt2);}
if (differences.NumberOfDifferences > 0 || differences.NumberOfSimilarities > 0) return differences;
if (evnt1 == null || evnt2 == null){
if (evnt1 != evnt2) differences.NumberOfDifferences++; else differences.NumberOfSimilarities++;
return differences;
}
Event changes = (Event)evnt2.Clone();
Event deletions = (Event)evnt2.Clone();
Event insertions = (Event)evnt2.Clone();
AttributeList attrChanges, attrDeletions, attrInsertions;
Differences diff = this.VisitAttributeList(evnt1.Attributes, evnt2.Attributes, out attrChanges, out attrDeletions, out attrInsertions);
if (diff == null){Debug.Assert(false); return differences;}
changes.Attributes = attrChanges;
deletions.Attributes = attrDeletions;
insertions.Attributes = attrInsertions;
differences.NumberOfDifferences += diff.NumberOfDifferences;
differences.NumberOfSimilarities += diff.NumberOfSimilarities;
if (evnt1.Flags == evnt2.Flags) differences.NumberOfSimilarities++; else differences.NumberOfDifferences++;
diff = this.VisitMethod(evnt1.HandlerAdder, evnt2.HandlerAdder);
if (diff == null){Debug.Assert(false); return differences;}
changes.HandlerAdder = diff.Changes as Method;
deletions.HandlerAdder = diff.Deletions as Method;
insertions.HandlerAdder = diff.Insertions as Method;
Debug.Assert(diff.Changes == changes.HandlerAdder && diff.Deletions == deletions.HandlerAdder && diff.Insertions == insertions.HandlerAdder);
differences.NumberOfDifferences += diff.NumberOfDifferences;
differences.NumberOfSimilarities += diff.NumberOfSimilarities;
diff = this.VisitMethod(evnt1.HandlerCaller, evnt2.HandlerCaller);
if (diff == null){Debug.Assert(false); return differences;}
changes.HandlerCaller = diff.Changes as Method;
deletions.HandlerCaller = diff.Deletions as Method;
insertions.HandlerCaller = diff.Insertions as Method;
Debug.Assert(diff.Changes == changes.HandlerCaller && diff.Deletions == deletions.HandlerCaller && diff.Insertions == insertions.HandlerCaller);
differences.NumberOfDifferences += diff.NumberOfDifferences;
differences.NumberOfSimilarities += diff.NumberOfSimilarities;
if (evnt1.HandlerFlags == evnt2.HandlerFlags) differences.NumberOfSimilarities++; else differences.NumberOfDifferences++;
diff = this.VisitMethod(evnt1.HandlerRemover, evnt2.HandlerRemover);
if (diff == null){Debug.Assert(false); return differences;}
changes.HandlerRemover = diff.Changes as Method;
deletions.HandlerRemover = diff.Deletions as Method;
insertions.HandlerRemover = diff.Insertions as Method;
Debug.Assert(diff.Changes == changes.HandlerRemover && diff.Deletions == deletions.HandlerRemover && diff.Insertions == insertions.HandlerRemover);
differences.NumberOfDifferences += diff.NumberOfDifferences;
differences.NumberOfSimilarities += diff.NumberOfSimilarities;
diff = this.VisitTypeNode(evnt1.HandlerType, evnt2.HandlerType);
if (diff == null){Debug.Assert(false); return differences;}
changes.HandlerType = diff.Changes as TypeNode;
deletions.HandlerType = diff.Deletions as TypeNode;
insertions.HandlerType = diff.Insertions as TypeNode;
//Debug.Assert(diff.Changes == changes.HandlerType && diff.Deletions == deletions.HandlerType && diff.Insertions == insertions.HandlerType);
differences.NumberOfDifferences += diff.NumberOfDifferences;
differences.NumberOfSimilarities += diff.NumberOfSimilarities;
diff = this.VisitExpression(evnt1.InitialHandler, evnt2.InitialHandler);
if (diff == null){Debug.Assert(false); return differences;}
changes.InitialHandler = diff.Changes as Expression;
deletions.InitialHandler = diff.Deletions as Expression;
insertions.InitialHandler = diff.Insertions as Expression;
Debug.Assert(diff.Changes == changes.InitialHandler && diff.Deletions == deletions.InitialHandler && diff.Insertions == insertions.InitialHandler);
differences.NumberOfDifferences += diff.NumberOfDifferences;
differences.NumberOfSimilarities += diff.NumberOfSimilarities;
diff = this.VisitIdentifier(evnt1.Name, evnt2.Name);
if (diff == null){Debug.Assert(false); return differences;}
changes.Name = diff.Changes as Identifier;
deletions.Name = diff.Deletions as Identifier;
insertions.Name = diff.Insertions as Identifier;
Debug.Assert(diff.Changes == changes.Name && diff.Deletions == deletions.Name && diff.Insertions == insertions.Name);
differences.NumberOfDifferences += diff.NumberOfDifferences;
differences.NumberOfSimilarities += diff.NumberOfSimilarities;
MethodList methChanges, methDeletions, methInsertions;
diff = this.VisitMethodList(evnt1.OtherMethods, evnt2.OtherMethods, out methChanges, out methDeletions, out methInsertions);
if (diff == null){Debug.Assert(false); return differences;}
changes.OtherMethods = methChanges;
deletions.OtherMethods = methDeletions;
insertions.OtherMethods = methInsertions;
differences.NumberOfDifferences += diff.NumberOfDifferences;
differences.NumberOfSimilarities += diff.NumberOfSimilarities;
if (evnt1.OverridesBaseClassMember == evnt2.OverridesBaseClassMember) differences.NumberOfSimilarities++; else differences.NumberOfDifferences++;
if (differences.NumberOfDifferences == 0){
differences.Changes = null;
differences.Deletions = null;
differences.Insertions = null;
}else{
differences.Changes = changes;
differences.Deletions = deletions;
differences.Insertions = insertions;
}
return differences;
//.........这里部分代码省略.........
示例2: _paste
static Event _paste(Event source, Event dest, TPasteLocation location, ClipboardOperation operation)
{
if (operation == ClipboardOperation.Cut && source.Engine == dest.Engine)
{
source.Remove();
switch (location)
{
case TPasteLocation.After:
dest.InsertAfter(source);
break;
case TPasteLocation.Before:
dest.InsertBefore(source);
break;
case TPasteLocation.Under:
dest.InsertUnder(source);
break;
}
return source;
}
if (operation == ClipboardOperation.Copy && source.Engine == dest.Engine)
{
Event newEvent = source.Clone();
switch (location)
{
case TPasteLocation.After:
dest.InsertAfter(newEvent);
break;
case TPasteLocation.Before:
dest.InsertBefore(newEvent);
break;
case TPasteLocation.Under:
if (dest.EventType == TEventType.Container)
newEvent.ScheduledTime = DateTime.UtcNow;
dest.InsertUnder(newEvent);
break;
}
return newEvent;
}
throw new ArgumentException("Event engines are different");
}