diff --git a/Directory.Build.props b/Directory.Build.props
new file mode 100644
index 0000000..45b1b57
--- /dev/null
+++ b/Directory.Build.props
@@ -0,0 +1,24 @@
+
+
+
+
+ net8.0
+ $(DefaultTargetFramework)-windows
+ 12.0
+ true
+ false
+ true
+ annotations
+ CS1591
+ enable
+
+
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+
diff --git a/Source/Core/MAX.Core/Autofac/AutofaceMiddleware.cs b/Source/Core/MAX.Core/Autofac/AutofaceMiddleware.cs
new file mode 100644
index 0000000..3dc6506
--- /dev/null
+++ b/Source/Core/MAX.Core/Autofac/AutofaceMiddleware.cs
@@ -0,0 +1,85 @@
+using Autofac;
+using MAX.Core.DependencyInjection;
+using MAX.Core.Helpers;
+using MAX.Core.Infrastructure;
+using MAX.Core.Reflections;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace MAX.Core.Autofac;
+
+public static class AutofaceMiddlewareExtensions
+{
+ public static Bootstrap UseAutofac(this Bootstrap engine)
+ {
+ engine.UseMiddleware();
+ return engine;
+ }
+}
+
+internal class AutofaceMiddleware : IBootstrap
+{
+ private ContainerBuilder _builder;
+ public void Build()
+ {
+ IocManager.Container = _builder.Build();
+ }
+
+ public void Use()
+ {
+ _builder = new ContainerBuilder();
+ IocManager.ContainerBuilder = _builder;
+ RegisterDependencies(_builder);
+ }
+
+
+ ///
+ /// 注册IOC
+ ///
+ ///
+ ///
+ private void RegisterDependencies(ContainerBuilder builder)
+ {
+ #region 注册所有IOC接口
+
+ IEnumerable ListDependency = ReflectionHelper.GetInstancesByInterface(AppTypeFinder.Assemblies.ToArray());
+ foreach (IDependencyRegistrar item in ListDependency)
+ {
+ item.Register(builder);
+ }
+
+
+ //ISingletonDependency
+ Type singtype = typeof(ISingletonDependency);
+ builder.RegisterAssemblyTypes(AppTypeFinder.Assemblies.ToArray())
+ .Where(a =>
+ singtype.IsAssignableFrom(a)
+ && a.IsClass
+ && !a.IsAbstract
+ && !typeof(INoDependency).IsAssignableFrom(a)
+ )
+ .AsImplementedInterfaces()
+ .AsSelf()
+ .PropertiesAutowired(new CustomPropertySelector())
+ .SingleInstance();
+
+
+ //ITransientDependency
+ Type transienttype = typeof(ITransientDependency);
+ builder.RegisterAssemblyTypes(AppTypeFinder.Assemblies.ToArray())
+ .Where(a =>
+ transienttype.IsAssignableFrom(a)
+ && a.IsClass
+ && !a.IsAbstract
+ && !typeof(INoDependency).IsAssignableFrom(a)
+ )
+ .AsImplementedInterfaces()
+ .AsSelf()
+ .PropertiesAutowired(new CustomPropertySelector())
+ .InstancePerLifetimeScope();
+
+
+ #endregion
+ }
+}
diff --git a/Source/Core/MAX.Core/Autofac/AutowiredAttribute.cs b/Source/Core/MAX.Core/Autofac/AutowiredAttribute.cs
new file mode 100644
index 0000000..e6c0853
--- /dev/null
+++ b/Source/Core/MAX.Core/Autofac/AutowiredAttribute.cs
@@ -0,0 +1,11 @@
+using System;
+
+namespace MAX.Core.Autofac;
+
+///
+/// 自动填充属性特性
+///
+[AttributeUsage(AttributeTargets.Property)]
+public class AutowiredAttribute : Attribute
+{
+}
diff --git a/Source/Core/MAX.Core/Autofac/CustomPropertySelector.cs b/Source/Core/MAX.Core/Autofac/CustomPropertySelector.cs
new file mode 100644
index 0000000..28938cb
--- /dev/null
+++ b/Source/Core/MAX.Core/Autofac/CustomPropertySelector.cs
@@ -0,0 +1,22 @@
+using Autofac.Core;
+using System.Linq;
+using System.Reflection;
+
+namespace MAX.Core.Autofac;
+
+///
+/// autofac 找出所有属性上是否摸个特性
+///
+public class CustomPropertySelector : IPropertySelector
+{
+ public bool InjectProperty(PropertyInfo propertyInfo, object instance)
+ {
+ if (propertyInfo.CustomAttributes.Any(iterator => iterator.AttributeType == typeof(AutowiredAttribute)))
+ {
+
+ }
+ //需要一个判断
+ //;如果标记的有CustomPropertyAttribute特性返回True:返回true;就构造实例
+ return propertyInfo.CustomAttributes.Any(iterator => iterator.AttributeType == typeof(AutowiredAttribute));
+ }
+}
diff --git a/Source/Core/MAX.Core/Autofac/IDependencyRegistrar.cs b/Source/Core/MAX.Core/Autofac/IDependencyRegistrar.cs
new file mode 100644
index 0000000..ca54fc9
--- /dev/null
+++ b/Source/Core/MAX.Core/Autofac/IDependencyRegistrar.cs
@@ -0,0 +1,8 @@
+using Autofac;
+
+namespace MAX.Core.Autofac;
+
+public interface IDependencyRegistrar
+{
+ void Register(ContainerBuilder builder);
+}
diff --git a/Source/Core/MAX.Core/Autofac/IocManager.cs b/Source/Core/MAX.Core/Autofac/IocManager.cs
new file mode 100644
index 0000000..22c50c4
--- /dev/null
+++ b/Source/Core/MAX.Core/Autofac/IocManager.cs
@@ -0,0 +1,96 @@
+using Autofac;
+using Autofac.Core;
+using System;
+using System.Collections.Generic;
+
+namespace MAX.Core.Autofac;
+
+///
+/// 容器
+///
+public static partial class IocManager
+{
+ ///
+ /// 默认容器
+ ///
+ public static IContainer Container { get; internal set; }
+ public static void SetContainer(IContainer container)
+ {
+ Container = container;
+ }
+
+ ///
+ /// 注册容器
+ ///
+ public static ContainerBuilder ContainerBuilder { get; internal set; }
+ public static void SetContainerBuilder(ContainerBuilder containerBuilder)
+ {
+ ContainerBuilder = containerBuilder;
+ }
+ public static void RegisterType()
+ {
+ ContainerBuilder.RegisterType().As().InstancePerLifetimeScope();
+ }
+ ///
+ /// 确定指定的服务在上下文中是否可用。
+ ///
+ ///
+ ///
+ public static bool IsRegistered()
+ {
+ return Container.IsRegistered();
+ }
+ ///
+ /// 确定指定的服务在上下文中是否可用。
+ ///
+ ///
+ ///
+ public static bool IsRegistered(Type serverType)
+ {
+ return Container.IsRegistered(serverType);
+ }
+
+ public static TService Resolve()
+ {
+ if (Container.IsRegistered())
+ {
+ return Container.Resolve();
+ }
+ return default;
+ }
+ public static object Resolve(Type serviceType)
+ {
+ if (Container.IsRegistered(serviceType))
+ {
+ return Container.Resolve(serviceType);
+ }
+ return default;
+ }
+ public static TService Resolve(params Parameter[] parameters)
+ {
+ if (Container.IsRegistered())
+ {
+ return Container.Resolve(parameters);
+ }
+ return default;
+ }
+ ///
+ /// 获取所有注册
+ ///
+ ///
+ ///
+ public static TService[] ResolveAll()
+ {
+ return ResolveAll(typeof(TService)) as TService[];
+ }
+ ///
+ /// 获取所有注册
+ ///
+ ///
+ ///
+ public static object[] ResolveAll(Type type)
+ {
+ Type enumerableOfType = typeof(IEnumerable<>).MakeGenericType(type);
+ return (object[])Container.ResolveService(new TypedService(enumerableOfType));
+ }
+}
diff --git a/Source/Core/MAX.Core/Caches/ICache.cs b/Source/Core/MAX.Core/Caches/ICache.cs
new file mode 100644
index 0000000..9407565
--- /dev/null
+++ b/Source/Core/MAX.Core/Caches/ICache.cs
@@ -0,0 +1,99 @@
+using System;
+
+namespace MAX.Core.Caches;
+
+///
+/// 缓存
+///
+public interface ICache
+{
+ ///
+ /// 是否存在指定键的缓存
+ ///
+ /// 缓存键
+ bool Exists(string key);
+ ///
+ /// 从缓存中获取数据
+ ///
+ ///
+ ///
+ T Get(string key);
+ ///
+ /// 从缓存中获取数据,如果不存在,则执行获取数据操作并添加到缓存中
+ ///
+ /// 缓存数据类型
+ /// 缓存键
+ /// 获取数据操作
+ T Get(string key, Func func);
+ ///
+ /// 当缓存数据不存在则添加,已存在不会添加,添加成功返回true
+ ///
+ /// 缓存数据类型
+ /// 缓存键
+ /// 值
+ bool TryAdd(string key, T value);
+ ///
+ /// 覆盖添加
+ ///
+ ///
+ ///
+ ///
+ ///
+ bool OverlayAdd(string key, T value);
+ ///
+ /// 移除缓存
+ ///
+ /// 缓存键
+ void Remove(string key);
+ ///
+ /// 清空缓存
+ ///
+ void Clear();
+}
+
+public interface ICache
+{
+ ///
+ /// 是否存在指定键的缓存
+ ///
+ /// 缓存键
+ bool Exists(string key);
+
+ ///
+ /// 从缓存中获取数据,如果不存在,则执行获取数据操作并添加到缓存中
+ ///
+ /// 缓存数据类型
+ /// 缓存键
+ T Get(string key);
+ ///
+ /// 从缓存中获取数据,如果不存在,则执行获取数据操作并添加到缓存中
+ ///
+ /// 缓存数据类型
+ /// 缓存键
+ /// 获取数据操作
+ T Get(string key, Func func);
+ ///
+ /// 当缓存数据不存在则添加,已存在不会添加,添加成功返回true
+ ///
+ /// 缓存数据类型
+ /// 缓存键
+ /// 值
+ bool TryAdd(string key, T value);
+ ///
+ /// 覆盖添加
+ ///
+ ///
+ ///
+ ///
+ ///
+ bool OverlayAdd(string key, T value);
+ ///
+ /// 移除缓存
+ ///
+ /// 缓存键
+ void Remove(string key);
+ ///
+ /// 清空缓存
+ ///
+ void Clear();
+}
diff --git a/Source/Core/MAX.Core/Caches/MemoryCache.cs b/Source/Core/MAX.Core/Caches/MemoryCache.cs
new file mode 100644
index 0000000..b2bc36a
--- /dev/null
+++ b/Source/Core/MAX.Core/Caches/MemoryCache.cs
@@ -0,0 +1,168 @@
+
+using MAX.Core.DependencyInjection;
+using MAX.Core.Infrastructure;
+using System;
+using System.Collections.Concurrent;
+using System.Linq;
+
+namespace MAX.Core.Caches;
+
+///
+/// 内存缓存
+///
+public class MemoryCache : ICache, ISingletonDependency
+{
+ //private static readonly Object _locker = new object();
+ private readonly ConcurrentDictionary _cache = new();
+
+ public virtual void Clear()
+ {
+ _cache.Clear();
+ }
+
+ public virtual bool Exists(string key)
+ {
+ return _cache.ContainsKey(key);
+ }
+ public virtual T Get(string key)
+ {
+ if (Exists(key))
+ {
+ return (T)_cache[key];
+ }
+ return default;
+ }
+ public virtual TResult Get(string key, Func func)
+ {
+ if (Exists(key))
+ {
+ return (TResult)_cache[key];
+ }
+ else
+ {
+ if (func != null)
+ {
+ TResult t = func();
+ TryAdd(key, t);
+ return t;
+ }
+ }
+ return default;
+ }
+
+ public virtual bool OverlayAdd(string key, T value)
+ {
+ if (Exists(key))
+ {
+ _cache[key] = value;
+ }
+ else
+ {
+ _cache.TryAdd(key, value);
+ }
+ return true;
+ }
+
+ public virtual void Remove(string key)
+ {
+ _cache.TryRemove(key, out _);
+ }
+
+ public virtual bool TryAdd(string key, T value)
+ {
+ _cache.AddOrUpdate(key, value, (oldkey, oldvalue) => value);
+ return true;
+ }
+ ///
+ /// 获取所有Key
+ ///
+ ///
+ public string[] AllKeys()
+ {
+ return _cache.Keys.ToArray();
+ }
+}
+///
+/// 单例缓存抽象类
+///
+/// 单例对象
+/// 缓存类型
+public abstract class SingleInstanceLittleCache : SingleInstance, ICache where TModel : class
+{
+ private readonly ConcurrentDictionary _cache = new();
+ ///
+ /// 自定义前缀
+ ///
+ //public abstract string KeyPrefix { get; }
+ //private string FormatKey(string key)
+ //{
+ // return KeyPrefix + key;
+ //}
+
+ public virtual void Clear()
+ {
+ _cache.Clear();
+ }
+
+ public virtual bool Exists(string key)
+ {
+ return _cache.ContainsKey(key);
+ }
+ public virtual TValue Get(string key)
+ {
+ if (Exists(key))
+ {
+ return _cache[key];
+ }
+ return default;
+ }
+ public virtual TValue Get(string key, Func func)
+ {
+ if (Exists(key))
+ {
+ return _cache[key];
+ }
+ else
+ {
+ if (func != null)
+ {
+ TValue t = func();
+ TryAdd(key, t);
+ return t;
+ }
+ }
+ return default;
+ }
+
+ public virtual bool OverlayAdd(string key, TValue value)
+ {
+ if (Exists(key))
+ {
+ _cache[key] = value;
+ }
+ else
+ {
+ _cache.TryAdd(key, value);
+ }
+ return true;
+ }
+
+ public virtual void Remove(string key)
+ {
+ _cache.TryRemove(key, out _);
+ }
+
+ public virtual bool TryAdd(string key, TValue value)
+ {
+ _cache.AddOrUpdate(key, value, (oldkey, oldvalue) => value);
+ return true;
+ }
+ ///
+ /// 获取所有Key
+ ///
+ ///
+ public string[] AllKeys()
+ {
+ return _cache.Keys.ToArray();
+ }
+}
diff --git a/Source/Core/MAX.Core/Commons/CommonValue.cs b/Source/Core/MAX.Core/Commons/CommonValue.cs
new file mode 100644
index 0000000..ddcd731
--- /dev/null
+++ b/Source/Core/MAX.Core/Commons/CommonValue.cs
@@ -0,0 +1,37 @@
+namespace MAX.Core.Commons;
+
+///
+/// 公共Value
+///
+///
+public class CommonValue
+{
+ public CommonValue() { }
+ public CommonValue(TValue value)
+ {
+ Value = value;
+ }
+ public TValue Value { get; set; }
+}
+///
+/// 公共TextValue
+///
+///
+public class CommonTextValue : CommonValue
+{
+ public string Text { get; set; }
+}
+///
+/// 公共TextValue
+///
+public class CommonTextValue : CommonTextValue
+{
+
+}
+///
+/// 默认公共键值对 Key Value
+///
+public class CommonKeyValue : CommonValue
+{
+ public string Key { get; set; }
+}
diff --git a/Source/Core/MAX.Core/Commons/Result.cs b/Source/Core/MAX.Core/Commons/Result.cs
new file mode 100644
index 0000000..5d71941
--- /dev/null
+++ b/Source/Core/MAX.Core/Commons/Result.cs
@@ -0,0 +1,55 @@
+using System;
+
+namespace MAX.Core.Commons;
+
+///
+/// 通用返回
+///
+public class Result
+{
+ ///
+ /// 返回结果是否成功
+ ///
+ public bool Success { get; set; } = false;
+ ///
+ /// 返回消息
+ ///
+ public string Msg { get; set; } = "";
+ ///
+ /// 返回内容
+ ///
+ public object Data { get; set; } = null;
+
+ ///
+ /// 返回状态码
+ ///
+ public int Code { get; set; }
+
+}
+///
+/// 通用返回 指定Data类型
+///
+/// 数据类型
+public class Result : Result
+{
+ ///
+ /// 返回内容
+ ///
+ public new TData Data { get; set; }
+}
+///
+/// 通用返回
+///
+/// 状态类型枚举
+/// 数据类型
+public class Result : Result where TStatus : Enum
+{
+ ///
+ /// 状态
+ ///
+ public TStatus Status { get; set; }
+ ///
+ /// 返回内容
+ ///
+ public new TData Data { get; set; }
+}
diff --git a/Source/Core/MAX.Core/Cryptography/Base64Helper.cs b/Source/Core/MAX.Core/Cryptography/Base64Helper.cs
new file mode 100644
index 0000000..768c732
--- /dev/null
+++ b/Source/Core/MAX.Core/Cryptography/Base64Helper.cs
@@ -0,0 +1,69 @@
+using System;
+using System.Text;
+
+namespace MAX.Core.Cryptography;
+
+public class Base64Helper
+{
+ ///
+ /// Base64加密
+ ///
+ /// 加密采用的编码方式
+ /// 待加密的明文
+ ///
+ public static string Encode(string source, Encoding encode)
+ {
+ string encodeValue = "";
+ byte[] bytes = encode.GetBytes(source);
+ try
+ {
+ encodeValue = Convert.ToBase64String(bytes);
+ }
+ catch
+ {
+ encodeValue = source;
+ }
+ return encodeValue;
+ }
+
+ ///
+ /// Base64加密,采用utf8编码方式加密
+ ///
+ /// 待加密的明文
+ /// 加密后的字符串
+ public static string Encode(string source)
+ {
+ return Encode(source, Encoding.UTF8);
+ }
+
+ ///
+ /// Base64解密
+ ///
+ /// 解密采用的编码方式,注意和加密时采用的方式一致
+ /// 待解密的密文
+ /// 解密后的字符串
+ public static string Decode(string result, Encoding encode)
+ {
+ string decode = "";
+ byte[] bytes = Convert.FromBase64String(result);
+ try
+ {
+ decode = encode.GetString(bytes);
+ }
+ catch
+ {
+ decode = result;
+ }
+ return decode;
+ }
+
+ ///
+ /// Base64解密,采用utf8编码方式解密
+ ///
+ /// 待解密的密文
+ /// 解密后的字符串
+ public static string Decode(string result)
+ {
+ return Decode(result, Encoding.UTF8);
+ }
+}
diff --git a/Source/Core/MAX.Core/Cryptography/DESHelper.cs b/Source/Core/MAX.Core/Cryptography/DESHelper.cs
new file mode 100644
index 0000000..67e37f0
--- /dev/null
+++ b/Source/Core/MAX.Core/Cryptography/DESHelper.cs
@@ -0,0 +1,215 @@
+using System;
+using System.IO;
+using System.Security.Cryptography;
+using System.Text;
+
+namespace MAX.Core.Cryptography;
+
+public sealed class DESHelper
+{
+
+ //默认密钥向量
+ private static readonly byte[] IVKey = { 36, 109, 97, 120, 111, 110, 120, 36 };
+ ///
+ /// DES加密字符串
+ ///
+ /// 待加密的字符串
+ /// 加密密钥,要求为8位
+ /// 加密成功返回加密后的字符串,失败返回源串
+ public static string Encrypt(string encryptString, string encryptKey)
+ {
+ try
+ {
+ encryptKey = GetSubString(encryptKey, 8, "");
+ encryptKey = encryptKey.PadRight(8, ' ');
+ byte[] rgbKey = Encoding.UTF8.GetBytes(encryptKey.Substring(0, 8));
+ byte[] rgbIV = IVKey;
+ byte[] inputByteArray = Encoding.UTF8.GetBytes(encryptString);
+ DES dCSP = DES.Create();
+ MemoryStream mStream = new();
+ CryptoStream cStream = new(mStream, dCSP.CreateEncryptor(rgbKey, rgbIV), CryptoStreamMode.Write);
+ cStream.Write(inputByteArray, 0, inputByteArray.Length);
+ cStream.FlushFinalBlock();
+ return Convert.ToBase64String(mStream.ToArray());
+ }
+ catch
+ {
+ return encryptString;
+ }
+ }
+
+ ///
+ /// DES解密字符串
+ ///
+ /// 待解密的字符串
+ /// 解密密钥,要求为8位,和加密密钥相同
+ /// 解密成功返回解密后的字符串,失败返源串
+ public static string Decrypt(string decryptString, string decryptKey)
+ {
+ try
+ {
+ decryptKey = GetSubString(decryptKey, 0, 8, "");
+ decryptKey = decryptKey.PadRight(8, ' ');
+ byte[] rgbKey = Encoding.UTF8.GetBytes(decryptKey);
+ byte[] rgbIV = IVKey;
+ byte[] inputByteArray = Convert.FromBase64String(decryptString);
+ DES DCSP = DES.Create();
+
+ MemoryStream mStream = new();
+ CryptoStream cStream = new(mStream, DCSP.CreateDecryptor(rgbKey, rgbIV), CryptoStreamMode.Write);
+ cStream.Write(inputByteArray, 0, inputByteArray.Length);
+ cStream.FlushFinalBlock();
+ return Encoding.UTF8.GetString(mStream.ToArray());
+ }
+ catch
+ {
+ return string.Empty;
+ }
+
+ }
+
+ #region 截取字符串函数
+
+ ///
+ /// 截取字符串函数
+ ///
+ /// 所要截取的字符串
+ /// 截取字符串的长度
+ ///
+ public static string GetSubString(string Str, int Num)
+ {
+ if (Str is null or "")
+ {
+ return "";
+ }
+ string outstr = string.Empty;
+ int n = 0;
+ foreach (char ch in Str)
+ {
+ n += Encoding.Default.GetByteCount(ch.ToString());
+
+ if (n > Num)
+ {
+ break;
+ }
+ else
+ {
+ outstr += ch;
+ }
+ }
+
+ return outstr;
+ }
+ ///
+ /// 截取字符串函数,如果超过指定长度则将超出的部分用指定字符串代替
+ ///
+ /// 所要截取的字符串
+ /// 截取字符串的长度
+ /// 截取字符串后省略部分的字符串
+ ///
+ public static string GetSubString(string Str, int Num, string LastStr)
+ {
+ return GetSubString(Str, 0, Num, LastStr);
+ }
+
+ #endregion
+
+ #region 截取字符串,超过部分用指定字符串替换
+
+ /* 宗波于 2010-6-12 日添加, 来源于DiscuzNt */
+ ///
+ /// 取指定长度的字符串
+ ///
+ /// 要检查的字符串
+ /// 起始位置
+ /// 指定长度
+ /// 用于替换的字符串
+ /// 截取后的字符串
+ public static string GetSubString(string p_SrcString, int p_StartIndex, int p_Length, string p_TailString)
+ {
+ string myResult = p_SrcString;
+
+ byte[] bComments = Encoding.UTF8.GetBytes(p_SrcString);
+ foreach (char c in Encoding.UTF8.GetChars(bComments))
+ { //当是日文或韩文时(注:中文的范围:\u4e00 - \u9fa5, 日文在\u0800 - \u4e00, 韩文为\xAC00-\xD7A3)
+ if (c is (> '\u0800' and < '\u4e00') or (> '\xAC00' and < '\xD7A3'))
+ {
+ //if (System.Text.RegularExpressions.Regex.IsMatch(p_SrcString, "[\u0800-\u4e00]+") || System.Text.RegularExpressions.Regex.IsMatch(p_SrcString, "[\xAC00-\xD7A3]+"))
+ //当截取的起始位置超出字段串长度时
+ if (p_StartIndex >= p_SrcString.Length)
+ {
+ return "";
+ }
+ else
+ {
+ return p_SrcString.Substring(p_StartIndex,
+ p_Length + p_StartIndex > p_SrcString.Length ? p_SrcString.Length - p_StartIndex : p_Length);
+ }
+ }
+ }
+
+ if (p_Length >= 0)
+ {
+ byte[] bsSrcString = Encoding.Default.GetBytes(p_SrcString);
+
+ //当字符串长度大于起始位置
+ if (bsSrcString.Length > p_StartIndex)
+ {
+ int p_EndIndex = bsSrcString.Length;
+
+ //当要截取的长度在字符串的有效长度范围内
+ if (bsSrcString.Length > p_StartIndex + p_Length)
+ {
+ p_EndIndex = p_Length + p_StartIndex;
+ }
+ else
+ { //当不在有效范围内时,只取到字符串的结尾
+
+ p_Length = bsSrcString.Length - p_StartIndex;
+ p_TailString = "";
+ }
+
+ int nRealLength = p_Length;
+ int[] anResultFlag = new int[p_Length];
+ byte[] bsResult = null;
+
+ int nFlag = 0;
+ for (int i = p_StartIndex; i < p_EndIndex; i++)
+ {
+ if (bsSrcString[i] > 127)
+ {
+ nFlag++;
+ if (nFlag == 3)
+ {
+ nFlag = 1;
+ }
+ }
+ else
+ {
+ nFlag = 0;
+ }
+
+ anResultFlag[i] = nFlag;
+ }
+
+ if (bsSrcString[p_EndIndex - 1] > 127 && anResultFlag[p_Length - 1] == 1)
+ {
+ nRealLength = p_Length + 1;
+ }
+
+ bsResult = new byte[nRealLength];
+
+ Array.Copy(bsSrcString, p_StartIndex, bsResult, 0, nRealLength);
+
+ myResult = Encoding.Default.GetString(bsResult);
+ myResult += p_TailString;
+ }
+ }
+
+ return myResult;
+ }
+
+
+ #endregion
+
+}
diff --git a/Source/Core/MAX.Core/Cryptography/MD5Helper.cs b/Source/Core/MAX.Core/Cryptography/MD5Helper.cs
new file mode 100644
index 0000000..8397396
--- /dev/null
+++ b/Source/Core/MAX.Core/Cryptography/MD5Helper.cs
@@ -0,0 +1,62 @@
+using System;
+using System.Security.Cryptography;
+using System.Text;
+
+namespace MAX.Core.Cryptography;
+
+public class MD5Helper
+{
+ ///
+ /// MD5加密
+ ///
+ ///
+ ///
+ public static string Md5_32(string instring)
+ {
+ return _Md532(instring);
+ }
+ public static string Md5_Lower32(string instring)
+ {
+ return _Md532(instring, true);
+ }
+ public static string _Md532(string instring, bool IsLower = false)
+ {
+ byte[] result = Encoding.UTF8.GetBytes(string.IsNullOrEmpty(instring) ? "" : instring.Trim());
+ MD5 md5 = MD5.Create();
+ byte[] output = md5.ComputeHash(result);
+ string value = BitConverter.ToString(output).Replace("-", "");
+ if (IsLower)
+ {
+ return value.ToLower();
+ }
+ return value;
+ }
+
+
+ ///
+ /// MD5加密
+ ///
+ ///
+ public static long GetLong(byte[] result)
+ {
+ return
+ Convert.ToInt64(
+ BitConverter.ToString(MD5.Create().ComputeHash(result), 4,
+ 8).Replace("-", ""), 16);
+ }
+
+ ///
+ /// MD5 16位加密转long
+ ///
+ ///
+ ///
+ public static long GetLong(string url)
+ {
+ if (string.IsNullOrEmpty(url))
+ {
+ return 0;
+ }
+
+ return Convert.ToInt64(BitConverter.ToString(MD5.Create().ComputeHash(Encoding.Default.GetBytes(url)), 4, 8).Replace("-", ""), 16);
+ }
+}
diff --git a/Source/Core/MAX.Core/Cryptography/UrlHelper.cs b/Source/Core/MAX.Core/Cryptography/UrlHelper.cs
new file mode 100644
index 0000000..35f2521
--- /dev/null
+++ b/Source/Core/MAX.Core/Cryptography/UrlHelper.cs
@@ -0,0 +1,51 @@
+using System.Text;
+
+namespace MAX.Core.Cryptography;
+
+///
+/// Url 加密 解密
+///
+public class UrlHelper
+{
+ ///
+ /// Url加密
+ ///
+ /// 加密采用的编码方式
+ /// 待加密的明文
+ ///
+ public static string Encode(string source, Encoding encode)
+ {
+ return System.Web.HttpUtility.UrlEncode(source, encode);
+ }
+
+ ///
+ /// Url加密,采用utf8编码方式加密
+ ///
+ /// 待加密的明文
+ /// 加密后的字符串
+ public static string Encode(string source)
+ {
+ return Encode(source, Encoding.UTF8);
+ }
+
+ ///
+ /// Url解密
+ ///
+ /// 解密采用的编码方式,注意和加密时采用的方式一致
+ /// 待解密的密文
+ /// 解密后的字符串
+ public static string Decode(string result, Encoding encode)
+ {
+ return System.Web.HttpUtility.UrlDecode(result, Encoding.UTF8);
+ }
+
+ ///
+ /// Url解密,采用utf8编码方式解密
+ ///
+ /// 待解密的密文
+ /// 解密后的字符串
+ public static string Decode(string result)
+ {
+ return Decode(result, Encoding.UTF8);
+ }
+}
diff --git a/Source/Core/MAX.Core/DependencyInjection/INoDependency.cs b/Source/Core/MAX.Core/DependencyInjection/INoDependency.cs
new file mode 100644
index 0000000..e30b6a7
--- /dev/null
+++ b/Source/Core/MAX.Core/DependencyInjection/INoDependency.cs
@@ -0,0 +1,5 @@
+namespace MAX.Core.DependencyInjection;
+
+public interface INoDependency
+{
+}
diff --git a/Source/Core/MAX.Core/DependencyInjection/ISingletonDependency.cs b/Source/Core/MAX.Core/DependencyInjection/ISingletonDependency.cs
new file mode 100644
index 0000000..bcacfcb
--- /dev/null
+++ b/Source/Core/MAX.Core/DependencyInjection/ISingletonDependency.cs
@@ -0,0 +1,8 @@
+namespace MAX.Core.DependencyInjection;
+
+///
+/// 单例
+///
+public interface ISingletonDependency
+{
+}
diff --git a/Source/Core/MAX.Core/DependencyInjection/ITransientDependency.cs b/Source/Core/MAX.Core/DependencyInjection/ITransientDependency.cs
new file mode 100644
index 0000000..3da15a0
--- /dev/null
+++ b/Source/Core/MAX.Core/DependencyInjection/ITransientDependency.cs
@@ -0,0 +1,8 @@
+namespace MAX.Core.DependencyInjection;
+
+///
+/// 每次实例化
+///
+public interface ITransientDependency
+{
+}
diff --git a/Source/Core/MAX.Core/DependencyInjection/LazyServiceProvider.cs b/Source/Core/MAX.Core/DependencyInjection/LazyServiceProvider.cs
new file mode 100644
index 0000000..b7e9a59
--- /dev/null
+++ b/Source/Core/MAX.Core/DependencyInjection/LazyServiceProvider.cs
@@ -0,0 +1,37 @@
+using MAX.Core.Autofac;
+using MAX.Core.Infrastructure;
+using System;
+using System.Collections.Concurrent;
+
+namespace MAX.Core.DependencyInjection;
+
+public interface ILazyServiceProvider
+{
+ object LazyGetService(Type serviceType);
+ T LazyGetService();
+}
+
+public class LazyServiceProvider : SingleInstance, ILazyServiceProvider
+{
+ protected ConcurrentDictionary> CachedServices { get; }
+ private LazyServiceProvider()
+ {
+ CachedServices = new ConcurrentDictionary>();
+ }
+ public virtual T LazyGetService()
+ {
+ return (T)LazyGetService(typeof(T));
+ }
+
+ public virtual object LazyGetService(Type serviceType)
+ {
+ return GetService(serviceType);
+ }
+ public virtual object GetService(Type serviceType)
+ {
+ return CachedServices.GetOrAdd(
+ serviceType,
+ _ => new Lazy