diff --git a/Orm/Xtensive.Orm/Orm/Internals/PairIntegrity/SyncManager.cs b/Orm/Xtensive.Orm/Orm/Internals/PairIntegrity/SyncManager.cs index 9b72b3612a..404f383bac 100644 --- a/Orm/Xtensive.Orm/Orm/Internals/PairIntegrity/SyncManager.cs +++ b/Orm/Xtensive.Orm/Orm/Internals/PairIntegrity/SyncManager.cs @@ -4,15 +4,13 @@ // Created by: Dmitri Maximov // Created: 2008.10.08 -using System; -using Xtensive.Core; using Xtensive.Orm.Internals; using Xtensive.Orm.Model; using Xtensive.Orm.ReferentialIntegrity; namespace Xtensive.Orm.PairIntegrity { - internal class SyncManager : SessionBound + internal readonly struct SyncManager(Session session) { public void ProcessRecursively(SyncContext context, RemovalContext removalContext, OperationType type, AssociationInfo association, Entity owner, Entity target, @@ -62,7 +60,7 @@ private SyncContext CreateContext(RemovalContext removalContext, context.Enqueue(new SyncAction(slaveActions.Break, association.Reversed, slave1, master1)); break; case OperationType.Remove: - var currentRemovalContext = Session.RemovalProcessor.Context; + var currentRemovalContext = session.RemovalProcessor.Context; var isNotYetRemoved = currentRemovalContext==null || !currentRemovalContext.Contains(slave2); if ((!(association.IsLoop && master1==slave2)) && isNotYetRemoved) context.Enqueue(new SyncAction(slaveActions.Break, association.Reversed, slave2, master1)); @@ -92,13 +90,5 @@ private static SyncActionSet GetSyncActions(AssociationInfo association) throw new ArgumentOutOfRangeException("association"); } } - - - // Constructors - - public SyncManager(Session session) - : base(session) - { - } } } diff --git a/Orm/Xtensive.Orm/Orm/Internals/Pinner.cs b/Orm/Xtensive.Orm/Orm/Internals/Pinner.cs index 6ce6699a9d..2868760301 100644 --- a/Orm/Xtensive.Orm/Orm/Internals/Pinner.cs +++ b/Orm/Xtensive.Orm/Orm/Internals/Pinner.cs @@ -4,9 +4,6 @@ // Created by: Denis Krjuchkov // Created: 2009.12.11 -using System; -using System.Collections.Generic; -using System.Linq; using Xtensive.Orm.Model; namespace Xtensive.Orm.Internals @@ -16,7 +13,7 @@ public readonly struct PinnerDisposableRemover(HashSet roots, Entit public void Dispose() => roots?.Remove(state); } - internal sealed class Pinner : SessionBound + internal struct Pinner(Session session) { private readonly HashSet roots = new(); @@ -38,8 +35,8 @@ public void Process(EntityChangeRegistry registry) activeRegistry = registry; PinAll(); - PinnedItems = new EntityChangeRegistry(Session); - PersistableItems = new EntityChangeRegistry(Session); + PinnedItems = new EntityChangeRegistry(session); + PersistableItems = new EntityChangeRegistry(session); ProcessRegistry(PersistenceState.New); ProcessRegistry(PersistenceState.Modified); @@ -130,18 +127,5 @@ private IEnumerable QueryRegistry(TypeInfo type) } #endregion - - - // Constructors - - /// - /// Initializes a new instance of this class. - /// - /// , to which current instance - /// is bound. - public Pinner(Session session) - : base(session) - { - } } -} \ No newline at end of file +} diff --git a/Orm/Xtensive.Orm/Orm/Session.cs b/Orm/Xtensive.Orm/Orm/Session.cs index 4ffd89da43..2339da3e5a 100644 --- a/Orm/Xtensive.Orm/Orm/Session.cs +++ b/Orm/Xtensive.Orm/Orm/Session.cs @@ -85,7 +85,7 @@ private static readonly Type private readonly bool allowSwitching; private readonly long identifier; - private readonly Pinner pinner; + private Pinner pinner; private int? commandTimeout; private volatile int isDisposing; // To prevent double-disposing @@ -237,7 +237,7 @@ public static Func Resolver internal HandlerAccessor Handlers { get; private set; } - internal SyncManager PairSyncManager { get; private set; } + internal SyncManager PairSyncManager { get; } internal RemovalProcessor RemovalProcessor { get; private set; } @@ -559,9 +559,9 @@ internal Session(Domain domain, StorageNode selectedStorageNode, SessionConfigur SystemEvents = new SessionEventAccessor(this, true); // Etc. - PairSyncManager = new SyncManager(this); + PairSyncManager = new(this); RemovalProcessor = new RemovalProcessor(this); - pinner = new Pinner(this); + pinner = new(this); Operations = new OperationRegistry(this); NonPairedReferencesRegistry = new(this);