更新框架,增加云库搜索模块
This commit is contained in:
1 parent
8526e5e0d2
commit
f2caec6083
192 files changed
+3626
-804
No files matched your search
@@ -0,0 +1,33 @@
|
||||
namespace MAX.Core.Interfaces;
|
||||
|
||||
public interface IPriority
|
||||
{
|
||||
/// <summary> 优先级(优先级越高越先执行) </summary>
|
||||
int Priority { get; }
|
||||
}
|
||||
|
||||
public static class IntPriority
|
||||
{
|
||||
public const int Highest = 5000;
|
||||
|
||||
public const int VeryHigh = 4000;
|
||||
|
||||
public const int Higher = 3000;
|
||||
|
||||
public const int High = 2000;
|
||||
|
||||
public const int AboveNormal = 1000;
|
||||
|
||||
public const int Normal = 0;
|
||||
|
||||
public const int BelowNormal = -1000;
|
||||
|
||||
public const int Low = -2000;
|
||||
|
||||
public const int Lower = -3000;
|
||||
|
||||
public const int VeryLow = -4000;
|
||||
|
||||
public const int Lowest = -5000;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using MAX.Core.DependencyInjection;
|
||||
|
||||
namespace MAX.Core.Interfaces;
|
||||
|
||||
/// <summary>
|
||||
/// 启动器:实现 <see cref="IDependencyRegistrar"/>,由宿主项目统一发现并按 <see cref="Priority"/> 排序执行。
|
||||
/// </summary>
|
||||
public interface IStartup : IDependencyRegistrar
|
||||
{
|
||||
/// <summary>
|
||||
/// 优先级(优先级越高越先执行)
|
||||
/// </summary>
|
||||
int Priority { get; }
|
||||
/// <summary>
|
||||
/// 初始化
|
||||
/// </summary>
|
||||
void Initialize();
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
namespace MAX.Core.Interfaces;
|
||||
|
||||
/// <summary>
|
||||
/// 单例,需要在当前类中定义
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
public class SingleInstance<T> where T : class
|
||||
{
|
||||
private static readonly object lockObj = new();
|
||||
private static T mySelf;//= default(T);
|
||||
public static T Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (lockObj)
|
||||
{
|
||||
mySelf ??= InstanceCreator.CreateInstance<T>();
|
||||
}
|
||||
|
||||
return mySelf;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class InstanceCreator
|
||||
{
|
||||
public static T CreateInstance<T>()
|
||||
{
|
||||
Type type = typeof(T);
|
||||
try
|
||||
{
|
||||
return (T)type.Assembly.CreateInstance(type.FullName, true, BindingFlags.NonPublic | BindingFlags.Instance, null, null, null, null);
|
||||
}
|
||||
catch (MissingMethodException ex)
|
||||
{
|
||||
throw new Exception($"{ex.Message}\n(单例模式下,构造函数必须为 private)");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user