@@ -14,24 +14,24 @@ public abstract class BaseReferenceNode : BaseNode
1414 /// <summary>Gets signaled if the inner node was changed.</summary>
1515 public event NodeEventHandler InnerNodeChanged ;
1616
17- /// <summary>Constructor.</summary>
18- /// <param name="performCycleCheck">True to perform class cycle checks when changing the inner node.</param>
19- public BaseReferenceNode ( bool performCycleCheck )
20- {
21- this . performCycleCheck = performCycleCheck ;
22- }
17+ /// <summary>True to perform class cycle checks when changing the inner node.</summary>
18+ public abstract bool PerformCycleCheck { get ; }
2319
2420 /// <summary>Changes the inner node.</summary>
21+ /// <exception cref="ClassCycleException">Thrown when a class cycle is present.</exception>
2522 /// <param name="node">The new node.</param>
2623 public void ChangeInnerNode ( ClassNode node )
2724 {
2825 Contract . Requires ( node != null ) ;
2926
3027 if ( InnerNode != node )
3128 {
32- if ( performCycleCheck )
29+ if ( PerformCycleCheck && ParentNode != null )
3330 {
34- PerformCycleCheck ( node ) ;
31+ if ( ! ClassManager . IsCycleFree ( ParentNode as ClassNode , node ) )
32+ {
33+ throw new ClassCycleException ( ) ;
34+ }
3535 }
3636
3737 InnerNode = node ;
@@ -41,23 +41,10 @@ public void ChangeInnerNode(ClassNode node)
4141 ParentNode ? . ChildHasChanged ( this ) ;
4242 }
4343 }
44-
45- /// <summary>Performs a class cycle check for the given class.</summary>
46- /// <exception cref="ClassCycleException">Thrown when a class cycle is present.</exception>
47- /// <param name="node">The class to check.</param>
48- public void PerformCycleCheck ( ClassNode node )
49- {
50- Contract . Requires ( node != null ) ;
51-
52- if ( ! ClassManager . IsCycleFree ( ParentNode as ClassNode , node ) )
53- {
54- throw new ClassCycleException ( ) ;
55- }
56- }
5744 }
5845
5946
60- /// <summary>Exception for signalling class cycle errors.</summary>
47+ /// <summary>Exception for signaling class cycle errors.</summary>
6148 public class ClassCycleException : Exception
6249 {
6350
0 commit comments