fix: 收敛旧模块资源释放与诊断
This commit is contained in:
@@ -29,6 +29,65 @@ namespace Lskj.Control.Model
|
||||
public class BandedGridDragGrid : IDisposable
|
||||
{
|
||||
private bool _disposed;
|
||||
|
||||
internal static void DisposeRegistrations(
|
||||
Dictionary<BandedGridView, List<BandedGridDragGrid>> sourceRegistrations,
|
||||
Dictionary<GridView, List<BandedGridDragGrid>> targetRegistrations,
|
||||
BandedGridView sourceGridView,
|
||||
GridView targetGridView)
|
||||
{
|
||||
DisposeSourceRegistrations(sourceRegistrations, sourceGridView);
|
||||
DisposeTargetRegistrations(targetRegistrations, targetGridView);
|
||||
}
|
||||
|
||||
private static void DisposeSourceRegistrations(
|
||||
Dictionary<BandedGridView, List<BandedGridDragGrid>> registrations,
|
||||
BandedGridView gridView)
|
||||
{
|
||||
foreach (KeyValuePair<BandedGridView, List<BandedGridDragGrid>> entry in registrations.ToList())
|
||||
{
|
||||
bool removeKey = ReferenceEquals(entry.Key, gridView);
|
||||
foreach (BandedGridDragGrid registration in entry.Value.ToList())
|
||||
{
|
||||
if (removeKey || registration == null || registration._disposed || registration.References(gridView))
|
||||
{
|
||||
if (registration != null)
|
||||
registration.Dispose();
|
||||
entry.Value.Remove(registration);
|
||||
}
|
||||
}
|
||||
if (removeKey || entry.Value.Count == 0)
|
||||
registrations.Remove(entry.Key);
|
||||
}
|
||||
}
|
||||
|
||||
private static void DisposeTargetRegistrations(
|
||||
Dictionary<GridView, List<BandedGridDragGrid>> registrations,
|
||||
GridView gridView)
|
||||
{
|
||||
foreach (KeyValuePair<GridView, List<BandedGridDragGrid>> entry in registrations.ToList())
|
||||
{
|
||||
bool removeKey = ReferenceEquals(entry.Key, gridView);
|
||||
foreach (BandedGridDragGrid registration in entry.Value.ToList())
|
||||
{
|
||||
if (removeKey || registration == null || registration._disposed || registration.References(gridView))
|
||||
{
|
||||
if (registration != null)
|
||||
registration.Dispose();
|
||||
entry.Value.Remove(registration);
|
||||
}
|
||||
}
|
||||
if (removeKey || entry.Value.Count == 0)
|
||||
registrations.Remove(entry.Key);
|
||||
}
|
||||
}
|
||||
|
||||
internal bool References(GridView gridView)
|
||||
{
|
||||
return gridView != null &&
|
||||
(ReferenceEquals(_sourceGridView, gridView) ||
|
||||
ReferenceEquals(_targetGridView, gridView));
|
||||
}
|
||||
/// <summary>
|
||||
/// 是否正在拖拽
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user