chore: use file-scoped namespace

This commit is contained in:
NaBian committed 2022-03-13 20:28:58 +08:00
1 parent 99d2fafb72
commit bbf1b7d4c6
748 files changed
+57929 -58678

No files matched your search

@@ -3,40 +3,39 @@ using System.Linq;
using System.Windows.Media;
using HandyControl.Controls;
namespace HandyControl.Tools
namespace HandyControl.Tools;
/// <summary>
/// 该类可以为可视化元素提供单开的功能
/// </summary>
public class SingleOpenHelper
{
private static readonly Dictionary<string, ISingleOpen> OpenDic = new();
/// <summary>
/// 该类可以为可视化元素提供单开的功能
/// 根据指定的类型创建实例
/// </summary>
public class SingleOpenHelper
/// <typeparam name="T"></typeparam>
/// <returns></returns>
public static T CreateControl<T>() where T : Visual, ISingleOpen, new()
{
private static readonly Dictionary<string, ISingleOpen> OpenDic = new();
var typeStr = typeof(T).FullName;
/// <summary>
/// 根据指定的类型创建实例
/// </summary>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
public static T CreateControl<T>() where T : Visual, ISingleOpen, new()
if (string.IsNullOrEmpty(typeStr)) return default;
var temp = new T();
if (!OpenDic.Keys.Contains(typeStr))
{
var typeStr = typeof(T).FullName;
if (string.IsNullOrEmpty(typeStr)) return default;
var temp = new T();
if (!OpenDic.Keys.Contains(typeStr))
{
OpenDic.Add(typeStr, temp);
return temp;
}
var currentCtl = OpenDic[typeStr];
if (currentCtl.CanDispose)
{
currentCtl.Dispose();
OpenDic[typeStr] = temp;
return temp;
}
return default;
OpenDic.Add(typeStr, temp);
return temp;
}
var currentCtl = OpenDic[typeStr];
if (currentCtl.CanDispose)
{
currentCtl.Dispose();
OpenDic[typeStr] = temp;
return temp;
}
return default;
}
}
}