整理代码

This commit is contained in:
GG Z
2026-02-20 15:31:44 +08:00
parent 94cf3f3266
commit 9f121cfc7f
149 changed files with 4063 additions and 6964 deletions

View File

@@ -0,0 +1,37 @@
using System.Windows;
using ShrlAlgoToolkit.Core.Assists;
using ShrlAlgoToolkit;
using ShrlAlgoToolkit.Core;
namespace ShrlAlgoToolkit.RevitAddins.Assists;
public sealed record SingletonViewAssist<T>
where T : Window, new()
{
private static T _instance;
private static readonly object Padlock = new();
private SingletonViewAssist() { }
public static T GetInstance(out bool isNewCreate)
{
isNewCreate = false;
//double-check locking
if (_instance == null)
{
isNewCreate = true;
lock (Padlock)
{
_instance ??= new T();
_instance.Closed += OnWindowClosed;
}
}
return _instance;
}
private static void OnWindowClosed(object sender, EventArgs e)
{
_instance = null;
}
}