52 lines
1.8 KiB
C#
52 lines
1.8 KiB
C#
/*
|
|
* Copyright (c) 2025 LG Electronics Inc.
|
|
* SPDX-License-Identifier: LicenseRef-LGE-Proprietary
|
|
*/
|
|
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace VisionCommon {
|
|
/// <summary>
|
|
/// Disposable 그룹 키
|
|
/// </summary>
|
|
public enum eDpsGroupKey {
|
|
SubMenu_Align,
|
|
SubMenu_AutoFocus,
|
|
SubMenu_Calibration,
|
|
SubMenu_CenterTuning,
|
|
SubMenu_VisionRepeat,
|
|
SubMenu_AttachInsp,
|
|
}
|
|
|
|
/// <summary>
|
|
/// Disposalbe을 그룹 키로 묶어서 등록하고, 향후 그룹 키에 해당하는 Disposalbe을 한 번에 Dispose하기 위한 매니저
|
|
/// </summary>
|
|
public class DisposableManager {
|
|
private static Dictionary<eDpsGroupKey, List<IDisposable>> _Disposables = new Dictionary<eDpsGroupKey, List<IDisposable>>();
|
|
|
|
/// <summary>
|
|
/// 특정 그룹 키에 해당하는 Disposalbe 객체 추가
|
|
/// </summary>
|
|
/// <param name="dpsGroupKey">Disposalbe 그룹 키</param>
|
|
/// <param name="disposable">Disposalbe 객체</param>
|
|
public static void AddDisposable(eDpsGroupKey dpsGroupKey, IDisposable disposable) {
|
|
if (!_Disposables.ContainsKey(dpsGroupKey)) {
|
|
_Disposables.Add(dpsGroupKey, new List<IDisposable>());
|
|
}
|
|
_Disposables[dpsGroupKey].Add(disposable);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 특정 그룹 키에 해당하는 Disposalbe 객체 모두 클리어
|
|
/// </summary>
|
|
/// <param name="dpsGroupKey">Disposalbe 그룹 키</param>
|
|
public static void ClearDisposable(eDpsGroupKey dpsGroupKey) {
|
|
if (_Disposables.ContainsKey(dpsGroupKey)) {
|
|
foreach (IDisposable disposable in _Disposables[dpsGroupKey]) {
|
|
disposable?.Dispose();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|