1- // Copyright (C) 2008-2022 Xtensive LLC.
1+ // Copyright (C) 2008-2020 Xtensive LLC.
22// This code is distributed under MIT license terms.
33// See the License.txt file in the project root for more information.
44// Created by: Dmitri Maximov
@@ -16,14 +16,15 @@ namespace Xtensive.Orm.Internals
1616 /// </summary>
1717 public sealed class EntityChangeRegistry : SessionBound
1818 {
19- private readonly HashSet < EntityState > @new = new ( ) ;
20- private readonly HashSet < EntityState > modified = new ( ) ;
21- private readonly HashSet < EntityState > removed = new ( ) ;
19+ private readonly HashSet < EntityState > @new = new HashSet < EntityState > ( ) ;
20+ private readonly HashSet < EntityState > modified = new HashSet < EntityState > ( ) ;
21+ private readonly HashSet < EntityState > removed = new HashSet < EntityState > ( ) ;
22+ private int count ;
2223
2324 /// <summary>
2425 /// Gets the number of registered entities.
2526 /// </summary>
26- public int Count { get ; private set ; }
27+ public int Count { get { return count ; } }
2728
2829 /// <summary>
2930 /// Registers the specified item.
@@ -34,7 +35,7 @@ internal void Register(EntityState item)
3435 // Remove-create sequences fix for Issue 690
3536 if ( item . PersistenceState == PersistenceState . New && removed . Contains ( item ) ) {
3637 removed . Remove ( item ) ;
37- Count -- ;
38+ count -- ;
3839 if ( item . DifferentialTuple . Difference == null ) {
3940 item . SetPersistenceState ( PersistenceState . Synchronized ) ;
4041 return ;
@@ -43,17 +44,17 @@ internal void Register(EntityState item)
4344 }
4445 else if ( item . PersistenceState == PersistenceState . Removed && @new . Contains ( item ) ) {
4546 @new . Remove ( item ) ;
46- Count -- ;
47+ count -- ;
4748 return ;
4849 }
4950 else if ( item . PersistenceState == PersistenceState . Removed && modified . Contains ( item ) ) {
5051 modified . Remove ( item ) ;
51- Count -- ;
52+ count -- ;
5253 }
5354
5455 var container = GetContainer ( item . PersistenceState ) ;
5556 if ( container . Add ( item ) )
56- Count ++ ;
57+ count ++ ;
5758 }
5859
5960 /// <summary>
@@ -72,20 +73,26 @@ public IEnumerable<EntityState> GetItems(PersistenceState state)
7273 /// </summary>
7374 public void Clear ( )
7475 {
75- Count = 0 ;
76+ count = 0 ;
7677 @new . Clear ( ) ;
7778 modified . Clear ( ) ;
7879 removed . Clear ( ) ;
7980 }
8081
8182 /// <exception cref="ArgumentOutOfRangeException"><paramref name="state"/> is out of range.</exception>
82- internal HashSet < EntityState > GetContainer ( PersistenceState state ) =>
83- state switch {
84- PersistenceState . New => @new ,
85- PersistenceState . Modified => modified ,
86- PersistenceState . Removed => removed ,
87- _ => throw new ArgumentOutOfRangeException ( nameof ( state ) )
88- } ;
83+ private HashSet < EntityState > GetContainer ( PersistenceState state )
84+ {
85+ switch ( state ) {
86+ case PersistenceState . New :
87+ return @new ;
88+ case PersistenceState . Modified :
89+ return modified ;
90+ case PersistenceState . Removed :
91+ return removed ;
92+ default :
93+ throw new ArgumentOutOfRangeException ( "state" ) ;
94+ }
95+ }
8996
9097
9198 // Constructors
0 commit comments