Browse Source

Revert "修改前端框架"

This reverts commit 25f9f9dffa4751e3f02fd0ab34a716ed16dff7f4.
蓝色星空 1 year ago
parent
commit
19375db54a
100 changed files with 2375 additions and 1093 deletions
  1. 0 28
      Assets/Scripts/Blue/0.Framework.meta
  2. 0 1064
      Assets/Scripts/Blue/0.Framework/BlueFramework.cs
  3. 8 0
      Assets/Scripts/Blue/0.FrameworkDesign.meta
  4. 8 0
      Assets/Scripts/Blue/0.FrameworkDesign/Command.meta
  5. 7 0
      Assets/Scripts/Blue/0.FrameworkDesign/Command/ICommand.cs
  6. 1 1
      Assets/Scripts/Blue/0.FrameworkDesign/Command/ICommand.cs.meta
  7. 8 0
      Assets/Scripts/Blue/0.FrameworkDesign/Core.meta
  8. 202 0
      Assets/Scripts/Blue/0.FrameworkDesign/Core/AbstractArchitecture.cs
  9. 11 0
      Assets/Scripts/Blue/0.FrameworkDesign/Core/AbstractArchitecture.cs.meta
  10. 133 0
      Assets/Scripts/Blue/0.FrameworkDesign/Core/ControllerAr.cs
  11. 11 0
      Assets/Scripts/Blue/0.FrameworkDesign/Core/ControllerAr.cs.meta
  12. 29 0
      Assets/Scripts/Blue/0.FrameworkDesign/Core/IArchitecture.cs
  13. 11 0
      Assets/Scripts/Blue/0.FrameworkDesign/Core/IArchitecture.cs.meta
  14. 11 0
      Assets/Scripts/Blue/0.FrameworkDesign/Core/IArchitectureModule.cs
  15. 11 0
      Assets/Scripts/Blue/0.FrameworkDesign/Core/IArchitectureModule.cs.meta
  16. 36 0
      Assets/Scripts/Blue/0.FrameworkDesign/Core/IArchitectureModuleExtension.cs
  17. 11 0
      Assets/Scripts/Blue/0.FrameworkDesign/Core/IArchitectureModuleExtension.cs.meta
  18. 6 0
      Assets/Scripts/Blue/0.FrameworkDesign/Core/IAuto.cs
  19. 11 0
      Assets/Scripts/Blue/0.FrameworkDesign/Core/IAuto.cs.meta
  20. 9 0
      Assets/Scripts/Blue/0.FrameworkDesign/Core/IController.cs
  21. 11 0
      Assets/Scripts/Blue/0.FrameworkDesign/Core/IController.cs.meta
  22. 10 0
      Assets/Scripts/Blue/0.FrameworkDesign/Core/IModel.cs
  23. 11 0
      Assets/Scripts/Blue/0.FrameworkDesign/Core/IModel.cs.meta
  24. 10 0
      Assets/Scripts/Blue/0.FrameworkDesign/Core/IService.cs
  25. 11 0
      Assets/Scripts/Blue/0.FrameworkDesign/Core/IService.cs.meta
  26. 9 0
      Assets/Scripts/Blue/0.FrameworkDesign/Core/IUtility.cs
  27. 11 0
      Assets/Scripts/Blue/0.FrameworkDesign/Core/IUtility.cs.meta
  28. 54 0
      Assets/Scripts/Blue/0.FrameworkDesign/Core/ModuleInitiator.cs
  29. 11 0
      Assets/Scripts/Blue/0.FrameworkDesign/Core/ModuleInitiator.cs.meta
  30. BIN
      Assets/Scripts/Blue/0.FrameworkDesign/Design.eddx
  31. 7 0
      Assets/Scripts/Blue/0.FrameworkDesign/Design.eddx.meta
  32. 8 0
      Assets/Scripts/Blue/0.FrameworkDesign/Event.meta
  33. 22 0
      Assets/Scripts/Blue/0.FrameworkDesign/Event/BindablePropertyUnSubscribe.cs
  34. 11 0
      Assets/Scripts/Blue/0.FrameworkDesign/Event/BindablePropertyUnSubscribe.cs.meta
  35. 41 0
      Assets/Scripts/Blue/0.FrameworkDesign/Event/ChainEventSubscription.cs
  36. 11 0
      Assets/Scripts/Blue/0.FrameworkDesign/Event/ChainEventSubscription.cs.meta
  37. 27 0
      Assets/Scripts/Blue/0.FrameworkDesign/Event/DefaultChainEventUnSubcribe.cs
  38. 11 0
      Assets/Scripts/Blue/0.FrameworkDesign/Event/DefaultChainEventUnSubcribe.cs.meta
  39. 160 0
      Assets/Scripts/Blue/0.FrameworkDesign/Event/DefaultTypeEventSystem.cs
  40. 11 0
      Assets/Scripts/Blue/0.FrameworkDesign/Event/DefaultTypeEventSystem.cs.meta
  41. 49 0
      Assets/Scripts/Blue/0.FrameworkDesign/Event/EventToActionAdapter.cs
  42. 11 0
      Assets/Scripts/Blue/0.FrameworkDesign/Event/EventToActionAdapter.cs.meta
  43. 8 0
      Assets/Scripts/Blue/0.FrameworkDesign/Event/IChainEvent.cs
  44. 11 0
      Assets/Scripts/Blue/0.FrameworkDesign/Event/IChainEvent.cs.meta
  45. 18 0
      Assets/Scripts/Blue/0.FrameworkDesign/Event/IChainEventSubscription.cs
  46. 11 0
      Assets/Scripts/Blue/0.FrameworkDesign/Event/IChainEventSubscription.cs.meta
  47. 31 0
      Assets/Scripts/Blue/0.FrameworkDesign/Event/IChainEventUnSubcribeExtension.cs
  48. 11 0
      Assets/Scripts/Blue/0.FrameworkDesign/Event/IChainEventUnSubcribeExtension.cs.meta
  49. 11 0
      Assets/Scripts/Blue/0.FrameworkDesign/Event/IChainEventUnSubscribe.cs
  50. 11 0
      Assets/Scripts/Blue/0.FrameworkDesign/Event/IChainEventUnSubscribe.cs.meta
  51. 6 0
      Assets/Scripts/Blue/0.FrameworkDesign/Event/IEvent.cs
  52. 11 0
      Assets/Scripts/Blue/0.FrameworkDesign/Event/IEvent.cs.meta
  53. 13 0
      Assets/Scripts/Blue/0.FrameworkDesign/Event/ISubscription.cs
  54. 11 0
      Assets/Scripts/Blue/0.FrameworkDesign/Event/ISubscription.cs.meta
  55. 28 0
      Assets/Scripts/Blue/0.FrameworkDesign/Event/ITypeEventSystem.cs
  56. 11 0
      Assets/Scripts/Blue/0.FrameworkDesign/Event/ITypeEventSystem.cs.meta
  57. 11 0
      Assets/Scripts/Blue/0.FrameworkDesign/Event/IUnSubscribe.cs
  58. 11 0
      Assets/Scripts/Blue/0.FrameworkDesign/Event/IUnSubscribe.cs.meta
  59. 26 0
      Assets/Scripts/Blue/0.FrameworkDesign/Event/IUnSubscribeExtension.cs
  60. 11 0
      Assets/Scripts/Blue/0.FrameworkDesign/Event/IUnSubscribeExtension.cs.meta
  61. 49 0
      Assets/Scripts/Blue/0.FrameworkDesign/Event/TypeEventSubscription.cs
  62. 11 0
      Assets/Scripts/Blue/0.FrameworkDesign/Event/TypeEventSubscription.cs.meta
  63. 19 0
      Assets/Scripts/Blue/0.FrameworkDesign/Event/TypeEventSystemUnSubscribe.cs
  64. 11 0
      Assets/Scripts/Blue/0.FrameworkDesign/Event/TypeEventSystemUnSubscribe.cs.meta
  65. 22 0
      Assets/Scripts/Blue/0.FrameworkDesign/Event/UnSubscribeChainEventOnDestroyTrigger.cs
  66. 11 0
      Assets/Scripts/Blue/0.FrameworkDesign/Event/UnSubscribeChainEventOnDestroyTrigger.cs.meta
  67. 22 0
      Assets/Scripts/Blue/0.FrameworkDesign/Event/UnSubscribeOnDestroyTrigger.cs
  68. 11 0
      Assets/Scripts/Blue/0.FrameworkDesign/Event/UnSubscribeOnDestroyTrigger.cs.meta
  69. 22 0
      Assets/Scripts/Blue/0.FrameworkDesign/Event/UnSubscribeOnDisableTrigger.cs
  70. 11 0
      Assets/Scripts/Blue/0.FrameworkDesign/Event/UnSubscribeOnDisableTrigger.cs.meta
  71. 8 0
      Assets/Scripts/Blue/0.FrameworkDesign/Hand.meta
  72. 8 0
      Assets/Scripts/Blue/0.FrameworkDesign/Hand/IQueryCommandHandler.cs
  73. 11 0
      Assets/Scripts/Blue/0.FrameworkDesign/Hand/IQueryCommandHandler.cs.meta
  74. 15 0
      Assets/Scripts/Blue/0.FrameworkDesign/Hand/QueryDefault_Hand.cs
  75. 11 0
      Assets/Scripts/Blue/0.FrameworkDesign/Hand/QueryDefault_Hand.cs.meta
  76. 8 0
      Assets/Scripts/Blue/0.FrameworkDesign/IOC.meta
  77. 236 0
      Assets/Scripts/Blue/0.FrameworkDesign/IOC/AbstractArchitectureComponentInjector.cs
  78. 11 0
      Assets/Scripts/Blue/0.FrameworkDesign/IOC/AbstractArchitectureComponentInjector.cs.meta
  79. 132 0
      Assets/Scripts/Blue/0.FrameworkDesign/IOC/ArchitectureInjecter.cs
  80. 11 0
      Assets/Scripts/Blue/0.FrameworkDesign/IOC/ArchitectureInjecter.cs.meta
  81. 36 0
      Assets/Scripts/Blue/0.FrameworkDesign/IOC/AutoAttribute.cs
  82. 11 0
      Assets/Scripts/Blue/0.FrameworkDesign/IOC/AutoAttribute.cs.meta
  83. 54 0
      Assets/Scripts/Blue/0.FrameworkDesign/IOC/ControllerInjector.cs
  84. 11 0
      Assets/Scripts/Blue/0.FrameworkDesign/IOC/ControllerInjector.cs.meta
  85. 19 0
      Assets/Scripts/Blue/0.FrameworkDesign/IOC/IArchitectureComponentInjector.cs
  86. 11 0
      Assets/Scripts/Blue/0.FrameworkDesign/IOC/IArchitectureComponentInjector.cs.meta
  87. 19 0
      Assets/Scripts/Blue/0.FrameworkDesign/IOC/IInjector.cs
  88. 11 0
      Assets/Scripts/Blue/0.FrameworkDesign/IOC/IInjector.cs.meta
  89. 65 0
      Assets/Scripts/Blue/0.FrameworkDesign/IOC/IOCContainer.cs
  90. 11 0
      Assets/Scripts/Blue/0.FrameworkDesign/IOC/IOCContainer.cs.meta
  91. 13 0
      Assets/Scripts/Blue/0.FrameworkDesign/IOC/InjectInfo.cs
  92. 11 0
      Assets/Scripts/Blue/0.FrameworkDesign/IOC/InjectInfo.cs.meta
  93. 40 0
      Assets/Scripts/Blue/0.FrameworkDesign/IOC/InjectRuleAttribute.cs
  94. 11 0
      Assets/Scripts/Blue/0.FrameworkDesign/IOC/InjectRuleAttribute.cs.meta
  95. 11 0
      Assets/Scripts/Blue/0.FrameworkDesign/IOC/InjectScope.cs
  96. 11 0
      Assets/Scripts/Blue/0.FrameworkDesign/IOC/InjectScope.cs.meta
  97. 43 0
      Assets/Scripts/Blue/0.FrameworkDesign/IOC/ModelInjector.cs
  98. 11 0
      Assets/Scripts/Blue/0.FrameworkDesign/IOC/ModelInjector.cs.meta
  99. 43 0
      Assets/Scripts/Blue/0.FrameworkDesign/IOC/ServiceInjector.cs
  100. 11 0
      Assets/Scripts/Blue/0.FrameworkDesign/IOC/ServiceInjector.cs.meta

+ 0 - 28
Assets/Scripts/Blue/0.Framework.meta

@@ -1,28 +0,0 @@
-fileFormatVersion: 2
-guid: 175e2135c5cd5de45ac86ad255222ca1
-folderAsset: yes
-PluginImporter:
-  externalObjects: {}
-  serializedVersion: 2
-  iconMap: {}
-  executionOrder: {}
-  defineConstraints: []
-  isPreloaded: 0
-  isOverridable: 0
-  isExplicitlyReferenced: 0
-  validateReferences: 1
-  platformData:
-  - first:
-      Any: 
-    second:
-      enabled: 1
-      settings: {}
-  - first:
-      Editor: Editor
-    second:
-      enabled: 0
-      settings:
-        DefaultValueInitialized: true
-  userData: 
-  assetBundleName: 
-  assetBundleVariant: 

+ 0 - 1064
Assets/Scripts/Blue/0.Framework/BlueFramework.cs

@@ -1,1064 +0,0 @@
-using System.Threading.Tasks;
-using System.Collections.Generic;
-using System;
-using UnityEngine;
-using System.Reflection;
-
-/*
-修改第三版
-将事件从IArchitecture中剥离
-*/
-namespace Blue
-{
-
-    #region  Architecture
-
-    /// <summary>
-    /// 所有功能在 IArchitecture 接口中定义
-    /// 1. 注册/获取Service、Model、Utility;
-    /// 2. 发送命令、事件、查询
-    /// 3. 注册、取消注册事件
-    /// </summary>
-    public interface IArchitecture
-    {
-        void SetArchitecture(IArchitecture instance);
-        void InitArchitecture();
-
-        void RegisterService<T>(T service) where T : IService;
-        void RegisterModel<T>(T Model) where T : IModel;
-        void RegisterUtility<T>(T utility) where T : IUtility;
-
-        T GetService<T>() where T : class, IService;
-        T GetModel<T>() where T : class, IModel;
-        T GetUtility<T>() where T : class, IUtility;
-    }
-
-    public abstract class AbstractArchitecture<T> : IArchitecture where T : AbstractArchitecture<T>, new()
-    {
-        private IOCContainer mContainer = new IOCContainer(); // 将类型、对象存储进IOC容器
-        private ICommandHandler commandHandler = new DefaultCommandHandler();
-        private IQueryHandler queryHandler = new DefaultQueryHandler();
-        private ITypeEventSystem mTypeEventSystem = new TypeEventSystem();
-        private HashSet<IService> mService;
-        private HashSet<IModel> mModels;
-
-        protected abstract void Init();
-
-        private static IArchitecture mArchitectureInstance;
-        void IArchitecture.SetArchitecture(IArchitecture instance)
-        {
-            mArchitectureInstance = instance;
-            CanGetModelExtension.SetArchitecture(mArchitectureInstance);
-            CanGetServiceExtension.SetArchitecture(mArchitectureInstance);
-            CanGetUtilityExtension.SetArchitecture(mArchitectureInstance);
-
-            CanSendCommandExtension.SetCommandHandler(commandHandler);
-            CanSendQueryExtension.SetQueryHandler(queryHandler);
-
-            CanRegisterEventExtension.SetTypeEventSystem(mTypeEventSystem);
-            CanSendEventExtension.SetTypeEventSystem(mTypeEventSystem);
-        }
-        void IArchitecture.InitArchitecture()
-        {
-            StartInit();
-            FinishInit();
-        }
-        private void StartInit()
-        {
-            mService = new HashSet<IService>();
-            mModels = new HashSet<IModel>();
-            Init();
-
-            foreach (var architectureModel in mModels)
-            {
-                architectureModel.OnInit();
-            }
-            foreach (var service in mService)
-            {
-                service.OnInit();
-            }
-        }
-        private void FinishInit()
-        {
-            mService.Clear();
-            mModels.Clear();
-            mService = null;
-            mModels = null;
-        }
-
-        public void RegisterService<T>(T service) where T : IService
-        {
-            mContainer.Register<T>(service);
-
-            mService.Add(service);
-        }
-        public void RegisterModel<T>(T model) where T : IModel
-        {
-            mContainer.Register<T>(model);
-
-            mModels.Add(model);
-        }
-        public void RegisterUtility<T>(T utility) where T : IUtility
-        {
-            mContainer.Register<T>(utility);
-        }
-
-        public T GetService<T>() where T : class, IService
-        {
-            return mContainer.Get<T>();
-        }
-        public T GetModel<T>() where T : class, IModel
-        {
-            return mContainer.Get<T>();
-        }
-        public T GetUtility<T>() where T : class, IUtility
-        {
-            return mContainer.Get<T>();
-        }
-    }
-
-    /// <summary>
-    /// 启动 Architecture
-    /// </summary>
-    internal sealed class ArchitectureInitiator
-    {
-        private ArchitectureInitiator() { }
-        private static ArchitectureInitiator mInstance;
-
-        private IArchitecture architectureInstance = null; // Architecture 实例
-        private Type architectureType = typeof(IArchitecture);
-        private bool architectureInited; // Architecture 是否初始化完成
-
-        [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterAssembliesLoaded)]
-        private static void Initiate()
-        {
-            mInstance = new ArchitectureInitiator();
-
-            Type[] typeArr = Assembly.GetExecutingAssembly().GetTypes(); // 获取正在执行的程序集类型数组
-            for (int i = 0; i < typeArr.Length; i++)
-            {
-                Type tmpType = typeArr[i];
-                if (!tmpType.IsInterface)
-                {
-                    if (mInstance.IsArchitecture(tmpType))
-                    {
-                        mInstance.CreateArchitectureInstance(tmpType);
-                    }
-                }
-            }
-            mInstance.RegisterArchitecture();
-            mInstance.InitArchitecture();
-        }
-        private void RegisterArchitecture()
-        {
-            if (architectureInstance != null)
-            {
-                architectureInstance.SetArchitecture(architectureInstance);
-            }
-        }
-
-        private void InitArchitecture()
-        {
-            if (architectureInstance != null)
-            {
-                architectureInstance.InitArchitecture();
-            }
-        }
-
-
-        private bool IsArchitecture(Type tmpType)
-        {
-            if (architectureInited)
-            {
-                return false;
-            }
-            if (tmpType.IsAbstract)
-            {
-                return false;
-            }
-            return architectureType.IsAssignableFrom(tmpType); // 确定指定类型 c 的实例是否能分配给当前类型的变量
-        }
-
-        private void CreateArchitectureInstance(Type archiType)
-        {
-            if (architectureInstance == null)
-            {
-                architectureInstance = (IArchitecture)Activator.CreateInstance(archiType);
-                architectureInited = true;
-            }
-            else
-            {
-                throw new Exception("More than one Architecture sub-class in the application,it should be only one!");
-            }
-        }
-    }
-
-    public interface IOnEvent<T>
-    {
-        void OnEvent(T e);
-    }
-
-    public static class OnGlobalEventExtension
-    {
-        public static IUnRegister RegisterEvent<T>(this IOnEvent<T> self) where T :struct,IEvent
-        {
-            return TypeEventSystem.Global.Register<T>(self.OnEvent);
-        }
-
-        public static void UnRegisterEvent<T>(this IOnEvent<T> self) where T : struct,IEvent
-        {
-            TypeEventSystem.Global.UnRegister<T>(self.OnEvent);
-        }
-    }
-
-    #endregion
-
-    #region Controller
-
-    public interface IController : ICanGetUtility, ICanGetService, ICanGetModel,
-                                   ICanRegisterEvent, ICanSendQuery, ICanSendCommand
-    {
-
-    }
-
-    #endregion
-
-    #region  Service
-
-    public interface IService : ICanGetService, ICanGetModel, ICanGetUtility,
-                                ICanRegisterEvent, ICanSendEvent
-    {
-        void OnInit();
-    }
-
-    #endregion
-
-    #region  Model
-
-    public interface IModel : ICanGetUtility, ICanSendEvent
-    {
-        void OnInit();
-    }
-
-    #endregion
-
-    #region  Utility
-
-    public interface IUtility
-    {
-
-    }
-
-    #endregion
-
-    #region  Command
-
-    public interface ICommand : ICanGetService, ICanGetModel, ICanGetUtility,
-                                ICanSendEvent, ICanSendCommand, ICanSendQuery
-    {
-        void OnExcute();
-    }
-    public interface ICommand<T> : ICanGetService, ICanGetModel, ICanGetUtility,
-                                   ICanSendEvent, ICanSendCommand, ICanSendQuery
-    {
-        T OnExcute();
-    }
-
-    public interface ICommandHandler
-    {
-        void ExcuteCommand(ICommand command);
-        void ExcuteCommand<T>() where T : ICommand, new();
-        T ExcuteCommand<T>(ICommand<T> command);
-    }
-
-    public class DefaultCommandHandler : ICommandHandler
-    {
-        public void ExcuteCommand(ICommand command)
-        {
-            command.OnExcute();
-        }
-
-        public void ExcuteCommand<T>() where T : ICommand, new()
-        {
-            ExcuteCommand(new T());
-        }
-
-        public T ExcuteCommand<T>(ICommand<T> command)
-        {
-            return command.OnExcute();
-        }
-    }
-
-    #endregion
-
-    #region  Query
-
-    public interface IQuery<T> : ICanGetModel, ICanGetService, ICanSendQuery
-    {
-        T DoQuery();
-    }
-    public interface IQueryAsync : ICanGetModel, ICanGetService, ICanSendQuery
-    {
-        void DoQueryAsync<T>(Action<T> onQueryCompleted);
-    }
-    public interface IQueryResult<T>
-    {
-        void OnQuerySucceed(Action<T> onQuerySucceed);
-        void OnQueryFailed(Action onQueryFailed);
-    }
-    public interface IQueryHandler
-    {
-        T DoQuery<T>(IQuery<T> query);
-        K DoQuery<T, K>() where T : IQuery<K>, new();
-
-        IQueryResult<T> DoQueryAsync<T>(IQuery<T> query);
-        IQueryResult<K> DoQueryAsync<T, K>() where T : IQuery<K>, new();
-    }
-
-    public class DefaultQueryHandler : IQueryHandler
-    {
-        public T DoQuery<T>(IQuery<T> query)
-        {
-            return query.DoQuery();
-        }
-
-        public K DoQuery<T, K>() where T : IQuery<K>, new()
-        {
-            return DoQuery(new T());
-        }
-
-        public IQueryResult<T> DoQueryAsync<T>(IQuery<T> query)
-        {
-            DefaultQueryResult<T> queryResult = new DefaultQueryResult<T>();
-            var queryTask = Task.Run(() =>
-            {
-                return query.DoQuery();
-            });
-            var awaiter = queryTask.GetAwaiter();
-            awaiter.OnCompleted(() =>
-            {
-                if (queryTask.IsFaulted | queryTask.IsCanceled)
-                {
-                    queryResult.TriggerFailed();
-                }
-                else
-                {
-                    queryResult.TriggerSuccess(awaiter.GetResult());
-                }
-            });
-            return queryResult;
-        }
-
-        public IQueryResult<K> DoQueryAsync<T, K>() where T : IQuery<K>, new()
-        {
-            return DoQueryAsync(new T());
-        }
-    }
-
-    public class DefaultQueryResult<T> : IQueryResult<T>
-    {
-        private Action<T> mOnQuerySucceed;
-        private Action mOnQueryFailed;
-
-        public void OnQuerySucceed(Action<T> onQuerySucceed)
-        {
-            mOnQuerySucceed += onQuerySucceed;
-        }
-        public void OnQueryFailed(Action onQueryFailed)
-        {
-            mOnQueryFailed += onQueryFailed;
-        }
-        public void TriggerSuccess(T result)
-        {
-            mOnQuerySucceed?.Invoke(result);
-        }
-        public void TriggerFailed()
-        {
-            mOnQueryFailed?.Invoke();
-        }
-    }
-    #endregion
-
-    #region Rule
-
-    /// <summary>
-    /// 能够 GetModel 的接口
-    /// </summary>
-    public interface ICanGetModel
-    {
-    }
-
-    /// <summary>
-    /// ICanGetModel 的静态扩展 GetModel
-    /// </summary>
-    public static class CanGetModelExtension
-    {
-        public static T GetModel<T>(this ICanGetModel self) where T : class, IModel
-        {
-            return _architecture.GetModel<T>();
-        }
-
-        private static IArchitecture _architecture;
-        public static void SetArchitecture(IArchitecture architecture)
-        {
-            _architecture = architecture;
-        }
-    }
-    /// <summary>
-    /// 能够 GetService 的接口
-    /// </summary>
-    public interface ICanGetService
-    {
-    }
-
-    /// <summary>
-    /// ICanGetService 的静态扩展 GetService
-    /// </summary>
-    public static class CanGetServiceExtension
-    {
-        public static T GetService<T>(this ICanGetService self) where T : class, IService
-        {
-            return _architecture.GetService<T>();
-        }
-
-        private static IArchitecture _architecture;
-        public static void SetArchitecture(IArchitecture architecture)
-        {
-            _architecture = architecture;
-        }
-    }
-
-    /// <summary>
-    /// 能够 GetUtility 的接口
-    /// </summary>
-    public interface ICanGetUtility
-    {
-    }
-
-    /// <summary>
-    /// ICanGetUtility 的静态扩展 GetUtility
-    /// </summary>
-    public static class CanGetUtilityExtension
-    {
-        public static T GetUtility<T>(this ICanGetUtility self) where T : class, IUtility
-        {
-            return _architecture.GetUtility<T>();
-        }
-
-        private static IArchitecture _architecture;
-        public static void SetArchitecture(IArchitecture architecture)
-        {
-            _architecture = architecture;
-        }
-    }
-
-    /// <summary>
-    /// 能够 RegisterEvent 的接口
-    /// </summary>
-    public interface ICanRegisterEvent
-    {
-    }
-
-    /// <summary>
-    /// ICanRegisterEvent 的静态扩展 RegisterEvent
-    /// </summary>
-    public static class CanRegisterEventExtension
-    {
-        public static IUnRegister RegisterEvent<T>(this ICanRegisterEvent self, Action<T> onEvent) where T : IEvent
-        {
-            return typeEventSystem.Register<T>(onEvent);
-        }
-
-        public static void UnRegisterEvent<T>(this ICanRegisterEvent self, Action<T> onEvent) where T : IEvent
-        {
-            typeEventSystem.UnRegister<T>(onEvent);
-        }
-
-        private static ITypeEventSystem typeEventSystem;
-        public static void SetTypeEventSystem(ITypeEventSystem mTypeEventSystem)
-        {
-            typeEventSystem = mTypeEventSystem;
-        }
-    }
-
-    /// <summary>
-    /// 能够 SendCommand 的接口
-    /// </summary>
-    public interface ICanSendCommand
-    {
-    }
-
-    /// <summary>
-    /// ICanSendCommand 的静态扩展 SendCommand
-    /// </summary>
-    public static class CanSendCommandExtension
-    {
-        public static void SendCommand<T>(this ICanSendCommand self) where T : ICommand, new()
-        {
-            mCommandHandler.ExcuteCommand<T>();
-        }
-
-        public static void SendCommand<T>(this ICanSendCommand self, T command) where T : ICommand
-        {
-            mCommandHandler.ExcuteCommand(command);
-        }
-
-        public static T SendCommand<T>(this ICanSendCommand self, ICommand<T> command)
-        {
-            return mCommandHandler.ExcuteCommand(command);
-        }
-
-        private static ICommandHandler mCommandHandler;
-        public static void SetCommandHandler(ICommandHandler commandHandler)
-        {
-            mCommandHandler = commandHandler;
-        }
-    }
-
-    /// <summary>
-    /// 能够 SendEvent 的接口
-    /// </summary>
-    public interface ICanSendEvent
-    {
-    }
-
-    /// <summary>
-    /// ICanSendEvent 的静态扩展 SendEvent
-    /// </summary>
-    public static class CanSendEventExtension
-    {
-        public static void SendEvent<T>(this ICanSendEvent self) where T : IEvent, new()
-        {
-            typeEventSystem.Send<T>();
-        }
-
-        public static void SendEvent<T>(this ICanSendEvent self, T e) where T : IEvent
-        {
-            typeEventSystem.Send<T>(e);
-        }
-
-        private static ITypeEventSystem typeEventSystem;
-        public static void SetTypeEventSystem(ITypeEventSystem mTypeEventSystem)
-        {
-            typeEventSystem = mTypeEventSystem;
-        }
-    }
-
-    /// <summary>
-    /// 能够 SendQuery 的接口
-    /// </summary>
-    public interface ICanSendQuery
-    {
-    }
-
-    /// <summary>
-    /// ICanSendQuery 的静态扩展 SendQuery
-    /// </summary>
-    public static class CanSendQueryExtension
-    {
-        public static T SendQuery<T>(this ICanSendQuery self, IQuery<T> queryInstance)
-        {
-            return _queryHandler.DoQuery<T>(queryInstance);
-        }
-        public static K SendQuery<T, K>(this ICanSendQuery self) where T : IQuery<K>, new()
-        {
-            return _queryHandler.DoQuery<T, K>();
-        }
-        public static IQueryResult<T> SendQueryAsync<T>(this ICanSendQuery self, IQuery<T> queryInstance)
-        {
-            return _queryHandler.DoQueryAsync<T>(queryInstance);
-        }
-        public static IQueryResult<K> SendQueryAsync<T, K>(this ICanSendQuery self) where T : IQuery<K>, new()
-        {
-            return _queryHandler.DoQueryAsync<T, K>();
-        }
-        private static IQueryHandler _queryHandler;
-        public static void SetQueryHandler(IQueryHandler queryHandler)
-        {
-            _queryHandler = queryHandler;
-        }
-    }
-
-    #endregion
-
-    #region  TypeEventSystem
-
-    /// <summary>
-    /// 取消监听接口
-    /// </summary>
-    public interface IUnRegister
-    {
-        void UnRegister();
-    }
-
-    /// <summary>
-    /// 取消监听列表接口
-    /// </summary>
-    public interface IUnRegisterList
-    {
-        List<IUnRegister> UnRegistersList { get; }
-    }
-
-    /// <summary>
-    /// 取消监听列表接口的静态扩展
-    /// 【IUnRegister 添加进 IUnRegisterList】
-    /// 【IUnRegisterList全部取消监听】
-    /// </summary>
-    public static class IUnRegisterListExtension
-    {
-        public static void AddToUnRegisterList(this IUnRegister self, IUnRegisterList unRegisterList)
-        {
-            unRegisterList.UnRegistersList.Add(self);
-        }
-
-        public static void UnRegisterAll(this IUnRegisterList self)
-        {
-            foreach (IUnRegister unRegister in self.UnRegistersList)
-            {
-                unRegister.UnRegister();
-            }
-            self.UnRegistersList.Clear();
-        }
-    }
-
-    /// <summary>
-    /// 取消监听的类
-    /// </summary>
-    public struct CustomUnRegister : IUnRegister
-    {
-        private Action mOnUnregister { get; set; }
-
-        public CustomUnRegister(Action onUnRegsiter)
-        {
-            mOnUnregister = onUnRegsiter;
-        }
-
-        public void UnRegister()
-        {
-            mOnUnregister?.Invoke();
-            mOnUnregister = null;
-        }
-    }
-
-    /// <summary>
-    /// 物体销毁时触发取消监听
-    /// </summary>
-    public class UnRegisterOnDestroyTrigger : MonoBehaviour
-    {
-        private readonly HashSet<IUnRegister> mUnRegisters = new HashSet<IUnRegister>();
-
-        public void AddUnRegister(IUnRegister unRegister)
-        {
-            mUnRegisters.Add(unRegister);
-        }
-
-        public void RemoveUnRegister(IUnRegister unRegister)
-        {
-            mUnRegisters.Remove(unRegister);
-        }
-
-        private void OnDestroy()
-        {
-            foreach (IUnRegister unRegister in mUnRegisters)
-            {
-                unRegister.UnRegister();
-            }
-            mUnRegisters.Clear();
-        }
-    }
-
-    /// <summary>
-    /// 取消监听的静态扩展
-    /// 【物体销毁时触发取消监听】
-    /// 【组件所属物体销毁时触发取消监听】
-    /// </summary>
-    public static class UnRegisterExtension
-    {
-        /// <summary>
-        /// 物体:物体销毁时触发取消监听
-        /// </summary>
-        /// <param name="unRegister">取消监听的接口</param>
-        /// <param name="component">物体对象</param>
-        /// <returns>取消监听的接口</returns>
-        public static IUnRegister UnRegisterWhenGameObjectDestroyed(this IUnRegister unRegister, GameObject go)
-        {
-            UnRegisterOnDestroyTrigger trigger = go.GetComponent<UnRegisterOnDestroyTrigger>();
-
-            if (!trigger)
-            {
-                trigger = go.AddComponent<UnRegisterOnDestroyTrigger>();
-            }
-
-            trigger.AddUnRegister(unRegister);
-
-            return unRegister;
-        }
-
-        /// <summary>
-        /// 组件:物体销毁时触发取消监听
-        /// </summary>
-        /// <param name="unRegister">取消监听的接口</param>
-        /// <param name="component">组件对象</param>
-        /// <returns>取消监听的接口</returns>
-        public static IUnRegister UnRegisterWhenGameObjectDestroyed<T>(this IUnRegister unRegister, T component) where T : Component
-        {
-            return unRegister.UnRegisterWhenGameObjectDestroyed(component.gameObject);
-        }
-    }
-
-    public interface ITypeEventSystem
-    {
-        IUnRegister Register<T>(Action<T> onEvent) where T: IEvent;
-        void UnRegister<T>(Action<T> onEvent) where T: IEvent;
-        void Send<T>() where T: IEvent, new();
-        void Send<T>(T e) where T: IEvent;
-    }
-    public class TypeEventSystem:ITypeEventSystem
-    {
-        private readonly EasyEvents mEvents = new EasyEvents();
-        public static readonly TypeEventSystem Global = new TypeEventSystem();
-
-        public void Send<T>() where T : IEvent,new()
-        {
-            mEvents.GetEvent<EasyEvent<T>>()?.Trigger(new T());
-        }
-
-        public void Send<T>(T e) where T: IEvent
-        {
-            mEvents.GetEvent<EasyEvent<T>>()?.Trigger(e);
-        }
-
-        public IUnRegister Register<T>(Action<T> onEvent)where T: IEvent
-        {
-            var e = mEvents.GetOrAddEvent<EasyEvent<T>>();
-            return e.Register(onEvent);
-        }
-
-        public void UnRegister<T>(Action<T> onEvent)where T: IEvent
-        {
-            var e = mEvents.GetEvent<EasyEvent<T>>();
-            if (e != null)
-            {
-                e.UnRegister(onEvent);
-            }
-        }
-    }
-
-    #endregion
-
-    #region  IOC
-
-    /// <summary>
-    /// IOC 容器 ,将类型对应的对象存储进字典
-    /// 【注册 + 获取】
-    /// </summary>
-    public class IOCContainer
-    {
-        private Dictionary<Type, object> mInstances = new Dictionary<Type, object>();
-
-        /// <summary>
-        /// IOC 容器注册方法
-        /// </summary>
-        /// <param name="instance">实例</param>
-        /// <typeparam name="T">指定类型</typeparam>
-        public void Register<T>(T instance)
-        {
-            Type key = typeof(T);
-
-            if (mInstances.ContainsKey(key))
-            {
-                mInstances[key] = instance;
-            }
-            else
-            {
-                mInstances.Add(key, instance);
-            }
-        }
-
-        /// <summary>
-        /// IOC 容器获取方法
-        /// </summary>
-        /// <typeparam name="T">指定类型</typeparam>
-        public T Get<T>() where T : class
-        {
-            Type key = typeof(T);
-
-            if (mInstances.TryGetValue(key, out object retInstance))
-            {
-                return retInstance as T;
-            }
-
-            return null;
-        }
-    }
-
-    #endregion
-
-    #region BindableProperty
-
-    public interface IReadonlyBindableProperty<T>
-    {
-        T Value { get; }
-
-        IUnRegister Register(Action<T> onValueChanged);
-        void UnRegister(Action<T> onValueChanged);
-        IUnRegister RegisterWithInitValue(Action<T> action);
-    }
-
-    public interface IBindableProperty<T> : IReadonlyBindableProperty<T>
-    {
-        new T Value { get; set; }
-        void SetValueWithoutEvent(T newValue);
-    }
-
-
-    public class BindableProperty<T> : IBindableProperty<T>
-    {
-        private Action<T> mOnValueChanged = (v) => { };
-
-        public BindableProperty(T defaultValue = default)
-        {
-            mValue = defaultValue;
-        }
-
-        protected T mValue;
-
-        public T Value
-        {
-            get => GetValue();
-            set
-            {
-                if (value == null && mValue == null) return;
-                if (value != null && value.Equals(mValue)) return;
-
-                SetValue(value);
-                mOnValueChanged?.Invoke(value);
-            }
-        }
-
-        protected virtual void SetValue(T newValue)
-        {
-            mValue = newValue;
-        }
-
-        protected virtual T GetValue()
-        {
-            return mValue;
-        }
-
-        public void SetValueWithoutEvent(T newValue)
-        {
-            mValue = newValue;
-        }
-
-
-        public IUnRegister Register(Action<T> onValueChanged)
-        {
-            mOnValueChanged += onValueChanged;
-            return new BindablePropertyUnRegister<T>()
-            {
-                BindableProperty = this,
-                OnValueChanged = onValueChanged
-            };
-        }
-
-        public IUnRegister RegisterWithInitValue(Action<T> onValueChanged)
-        {
-            onValueChanged(mValue);
-            return Register(onValueChanged);
-        }
-
-        public static implicit operator T(BindableProperty<T> property)
-        {
-            return property.Value;
-        }
-
-        public override string ToString()
-        {
-            return Value.ToString();
-        }
-
-        public void UnRegister(Action<T> onValueChanged)
-        {
-            mOnValueChanged -= onValueChanged;
-        }
-    }
-
-    public class BindablePropertyUnRegister<T> : IUnRegister
-    {
-        public BindableProperty<T> BindableProperty { get; set; }
-
-        public Action<T> OnValueChanged { get; set; }
-
-        public void UnRegister()
-        {
-            BindableProperty.UnRegister(OnValueChanged);
-
-            BindableProperty = null;
-            OnValueChanged = null;
-        }
-    }
-
-    #endregion
-
-    #region EasyEvent
-
-    public interface IEasyEvent
-    {
-
-    }
-
-    public class EasyEvent : IEasyEvent
-    {
-        private Action mOnEvent = () => { };
-
-        public IUnRegister Register(Action onEvent)
-        {
-            mOnEvent += onEvent;
-
-            return new CustomUnRegister(() =>
-            {
-                UnRegister(onEvent);
-            });
-        }
-
-        public void UnRegister(Action onEvent)
-        {
-            mOnEvent -= onEvent;
-        }
-
-        public void Trigger()
-        {
-            mOnEvent?.Invoke();
-        }
-    }
-
-    public class EasyEvent<T> : IEasyEvent
-    {
-        private Action<T> mOnEvent = e => { };
-
-        public IUnRegister Register(Action<T> onEvent)
-        {
-            mOnEvent += onEvent;
-
-            return new CustomUnRegister(() =>
-            {
-                UnRegister(onEvent);
-            });
-        }
-
-        public void UnRegister(Action<T> onEvent)
-        {
-            mOnEvent -= onEvent;
-        }
-
-        public void Trigger(T t)
-        {
-            mOnEvent?.Invoke(t);
-        }
-    }
-
-    public class EasyEvent<T, K> : IEasyEvent
-    {
-        private Action<T, K> mOnEvent = (t, k) => { };
-
-        public IUnRegister Register(Action<T, K> onEvent)
-        {
-            mOnEvent += onEvent;
-
-            return new CustomUnRegister(() =>
-            {
-                UnRegister(onEvent);
-            });
-        }
-
-        public void UnRegister(Action<T, K> onEvent)
-        {
-            mOnEvent -= onEvent;
-        }
-
-        public void Trigger(T t, K k)
-        {
-            mOnEvent?.Invoke(t, k);
-        }
-    }
-
-    public class EasyEvent<T, K, S> : IEasyEvent
-    {
-        private Action<T, K, S> mOnEvent = (t, k, s) => { };
-
-        public IUnRegister Register(Action<T, K, S> onEvent)
-        {
-            mOnEvent += onEvent;
-
-            return new CustomUnRegister(() =>
-            {
-                UnRegister(onEvent);
-            });
-        }
-
-        public void UnRegister(Action<T, K, S> onEvent)
-        {
-            mOnEvent -= onEvent;
-        }
-
-        public void Trigger(T t, K k, S s)
-        {
-            mOnEvent?.Invoke(t, k, s);
-        }
-    }
-
-    public class EasyEvents
-    {
-        private static EasyEvents mGlobalEvents = new EasyEvents();
-
-        public static T Get<T>() where T : IEasyEvent
-        {
-            return mGlobalEvents.GetEvent<T>();
-        }
-
-        public static void Register<T>() where T : IEasyEvent, new()
-        {
-            mGlobalEvents.AddEvent<T>();
-        }
-
-        private Dictionary<Type, IEasyEvent> mTypeEvents = new Dictionary<Type, IEasyEvent>();
-
-        public void AddEvent<T>() where T : IEasyEvent, new()
-        {
-            mTypeEvents.Add(typeof(T), new T());
-        }
-
-        public T GetEvent<T>() where T : IEasyEvent
-        {
-            if (mTypeEvents.TryGetValue(typeof(T), out IEasyEvent e))
-            {
-                return (T)e;
-            }
-
-            return default;
-        }
-
-        public T GetOrAddEvent<T>() where T : IEasyEvent, new()
-        {
-            var eType = typeof(T);
-            if (mTypeEvents.TryGetValue(eType, out var e))
-            {
-                return (T)e;
-            }
-
-            var t = new T();
-            mTypeEvents.Add(eType, t);
-            return t;
-        }
-    }
-    #endregion
-
-    #region Event
-
-    public interface IEvent
-    {
-
-    }
-    #endregion
-}

+ 8 - 0
Assets/Scripts/Blue/0.FrameworkDesign.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 77ed7435e9ea8ee4baa3ed85f70d94a0
+folderAsset: yes
+DefaultImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 8 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Command.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: ddfab4732bc4200488644a06987a4e3d
+folderAsset: yes
+DefaultImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 7 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Command/ICommand.cs

@@ -0,0 +1,7 @@
+namespace Blue
+{
+    public interface ICommand:ICanGetService,ICanGetModel,ICanGetUtility,ICanTriggerEvent,ICanSendCommand
+    {
+        void OnExcute();
+    }
+}

+ 1 - 1
Assets/Scripts/Blue/0.Framework/BlueFramework.cs.meta → Assets/Scripts/Blue/0.FrameworkDesign/Command/ICommand.cs.meta

@@ -1,5 +1,5 @@
 fileFormatVersion: 2
-guid: 7be01675e002f2a48b1b177b93da629b
+guid: de3ff73d66e6dc44d85d583a30ca4137
 MonoImporter:
   externalObjects: {}
   serializedVersion: 2

+ 8 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Core.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: c1e93bff4fd1fe346906a5880e4bdf96
+folderAsset: yes
+DefaultImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 202 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Core/AbstractArchitecture.cs

@@ -0,0 +1,202 @@
+using System;
+using System.Collections.Generic;
+
+namespace Blue
+{
+    /// <summary>
+    /// Architecture抽象类,继承自IArchitecture
+    /// </summary>
+    public abstract class AbstractArchitecture<T>:IArchitecture where T:AbstractArchitecture<T>,new()
+    {
+        private static IArchitecture architectureInstance;
+        private List<IModel> modelList;
+        private List<IService> serviceList;
+        private IOCContainer modelContainer = new IOCContainer();
+        private IOCContainer serviceContainer=new IOCContainer();
+        private IOCContainer utilityContainer = new IOCContainer();
+        private ITypeEventSystem eventSystem=new DefaultTypeEventSystem();
+        private IQueryCommandHandler commandHandle=new QueryDefault_Hand();
+        private IQueryHandler queryHandler = new DefaultQueryHandler();
+
+        /// <summary>
+        /// 设置Architecture_Instance
+        /// </summary>
+        void IArchitecture.SetArchitectureInstance(IArchitecture instance)
+        {
+            architectureInstance = instance;
+            ICanGetModelExtension.SetArchitecture(architectureInstance);
+            ICanGetServiceExtension.SetArchitecture(architectureInstance);
+            ICanGetUtilityExtension.SetArchitecture(architectureInstance);
+            IArchitectureModuleExtension.SetArchitecture(architectureInstance);
+            ICanSendCommandExtension.SetCommandHandler(commandHandle);
+            ICanTriggerEventExtension.SetEventSystem(eventSystem);
+            ICanSubscribeEventExtension.SetEventSystem(eventSystem);
+            IChainEventUnSubcribeExtension.SetEventSystem(eventSystem);
+            ICanSendQueryExtension.SetQueryHandler(queryHandler);
+        }
+
+        /// <summary>
+        /// 注册
+        /// </summary>
+        void IArchitecture.Register()
+        {
+            modelList = new List<IModel>();
+            serviceList = new List<IService>();
+            OnInit();
+        }
+
+        /// <summary>
+        /// 初始化Architecture
+        /// </summary>
+        void IArchitecture.InitArchitecture()
+        {
+            InitModels();
+            InitServices();
+        }
+
+        /// <summary>
+        /// 完成初始化Architecture
+        /// </summary>
+        void IArchitecture.FinishInit()
+        {
+            modelList.Clear();
+            serviceList.Clear();
+            modelList = null;
+            serviceList = null;
+        }
+
+        /// <summary>
+        /// 初始化 Model 层
+        /// </summary>
+        private void InitModels()
+        {
+            foreach (var model in modelList)
+            {
+                model.OnInit();
+            }
+            /*modelList.Clear();
+            modelList = null;*/
+        }
+
+        /// <summary>
+        /// 初始化 Services 层
+        /// </summary>
+        private void InitServices()
+        {
+            foreach (var service in serviceList)
+            {
+                service.OnInit();
+            }
+            /*serviceList.Clear();
+            serviceList = null;*/
+        }
+
+        protected abstract void OnInit();
+
+        /// <summary>
+        /// 设置事件系统
+        /// </summary>
+        protected virtual void SetTypeEventSystem(ITypeEventSystem typeEventSystem)
+        {
+            eventSystem = typeEventSystem;
+        }
+
+        /// <summary>
+        /// 获取 Model
+        /// </summary>
+        public K GetModel<K>() where K:IModel
+        {
+            return modelContainer.Get<K>();
+        }
+
+        /// <summary>
+        /// 获取 Service
+        /// </summary>
+        public K GetService<K>() where K : IService
+        {
+            return serviceContainer.Get<K>();
+        }
+
+        /// <summary>
+        /// 获取 Utility
+        /// </summary>
+        public K GetUtility<K>() where K : IUtility
+        {
+            return utilityContainer.Get<K>();
+        }
+
+        /// <summary>
+        /// 获取 Model
+        /// </summary>
+        public object GetModel(Type type)
+        {
+            return modelContainer.Get(type);
+        }
+
+        /// <summary>
+        /// 获取 Service
+        /// </summary>
+        public object GetService(Type type)
+        {
+            return serviceContainer.Get(type);
+        }
+
+        /// <summary>
+        /// 获取 Utility
+        /// </summary>
+        public object GetUtility(Type type)
+        {
+            return utilityContainer.Get(type);
+        }
+
+        /// <summary>
+        /// 注册 Model
+        /// </summary>
+        public void RegisterModel<K>() where K :  IModel, new()
+        {
+            RegisterModel(new K());
+        }
+
+        /// <summary>
+        /// 注册 Service
+        /// </summary>
+        public void RegisterService<K>() where K : IService, new()
+        {
+            RegisterService(new K());
+        }
+
+        /// <summary>
+        /// 注册 Utility
+        /// </summary>
+        public void RegisterUtility<K>() where K : IUtility, new()
+        {
+            RegisterUtility(new K());
+        }
+
+        /// <summary>
+        /// 注册 Model
+        /// </summary>
+        public void RegisterModel<K>(K modelInstance) where K : IModel
+        {
+            modelContainer.Register(modelInstance);
+            modelList.Add(modelInstance);
+        }
+
+        /// <summary>
+        /// 注册 Service
+        /// </summary>
+        public void RegisterService<K>(K serviceInstance) where K : IService
+        {
+            serviceContainer.Register(serviceInstance);
+            serviceList.Add(serviceInstance);
+        }
+
+        /// <summary>
+        /// 注册 Utility
+        /// </summary>
+        public void RegisterUtility<K>(K utilityInstance) where K : IUtility
+        {
+            utilityContainer.Register(utilityInstance);
+        }
+    }
+}

+ 11 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Core/AbstractArchitecture.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 32afae3298447024aa4cfeb2e4c7f555
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 133 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Core/ControllerAr.cs

@@ -0,0 +1,133 @@
+using System;
+using System.Reflection;
+using UnityEngine;
+using UnityEngine.Scripting;
+
+namespace Blue
+{
+    /// <summary>
+    /// 控制的Archi
+    /// </summary>
+    [Preserve]
+    internal sealed class ControllerAr
+    {
+        private ControllerAr() { }
+
+        private Type architectureType = typeof(IArchitecture);
+        private IArchitecture architectureInstance = null;
+        private IInjector mInjector;
+        private bool architectureInited = false;
+        //private bool
+        private static ControllerAr mInstance;
+        private ModuleInitiator moduleInitiator;
+
+        [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterAssembliesLoaded)]
+        private static void Initiate()
+        {
+            mInstance = new ControllerAr();
+            mInstance.CreateInjector();
+            mInstance.CreateModuleInitiator();
+            Type[] typeArr = Assembly.GetExecutingAssembly().GetTypes();
+            int typeLength = typeArr.Length;
+            for (int i = 0; i < typeLength; i++)
+            {
+                Type tmpType = typeArr[i];
+                if (!tmpType.IsInterface) 
+                {
+                    if (mInstance.IsArchitecture(tmpType))
+                    {
+                        mInstance.CreateArchitectureInstance(tmpType);
+                    }
+                    mInstance.PrepairModuleData(tmpType);
+                    mInstance.PrepairInjectionData(tmpType);
+                }
+            }
+            mInstance.RegisterArchitecture();
+            StartInject();
+            mInstance.InitArchitecture();
+            mInstance.FinishInit();
+        }
+        //[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
+        private static void StartInject() 
+        {
+            //Debug.Log("StartInject");
+            mInstance.Inject();
+            //mInstance.Clear();
+        }
+        private void Clear() 
+        {
+            mInjector.Dispose();
+            moduleInitiator.Dispose();
+            mInjector = null;
+            moduleInitiator = null;
+            mInstance = null;
+        }
+        private void Inject() 
+        {
+            mInjector.Inject(architectureInstance);
+        }
+        private void FinishInit()
+        {
+            architectureInstance.FinishInit();
+            mInstance.Clear();
+        }
+        private void RegisterArchitecture()
+        {
+            if (architectureInstance != null)
+            {
+                architectureInstance.SetArchitectureInstance(architectureInstance);
+                architectureInstance.Register();
+                InitModule();
+            }
+        }
+        private void InitArchitecture()
+        {
+            architectureInstance.InitArchitecture();
+        }
+        private void InitModule() 
+        {
+            moduleInitiator.InitModule();
+        }
+        private bool IsArchitecture(Type tmpType)
+        {
+            if (architectureInited) 
+            {
+                return false;
+            }
+            if (tmpType.IsAbstract)
+            {
+                return false;
+            }
+            return architectureType.IsAssignableFrom(tmpType);
+        }
+        private void PrepairModuleData(Type type) 
+        {
+            moduleInitiator.PrepairModuleData(type);
+        }
+
+        private void CreateArchitectureInstance(Type archiType)
+        {
+            if (architectureInstance == null)
+            {
+                architectureInstance = (IArchitecture)Activator.CreateInstance(archiType);
+                architectureInited = true;
+            }
+            else
+            {
+                throw new Exception("More than one Architecture sub-class in the application,it should be only one!");
+            }
+        }
+        private void PrepairInjectionData(Type type) 
+        {
+            mInjector.PrepairInjectionData(type);
+        }
+        private void CreateModuleInitiator() 
+        {
+            moduleInitiator=new ModuleInitiator();
+        }
+        private void CreateInjector() 
+        {
+            mInjector = new ArchitectureInjecter();
+        }
+    }
+}

+ 11 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Core/ControllerAr.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 1ab12634675f7e9449ae7461b5e0b8f6
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 29 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Core/IArchitecture.cs

@@ -0,0 +1,29 @@
+using System;
+using UnityEngine.Scripting;
+namespace Blue
+{
+    /// <summary>
+    /// Architecture 接口
+    /// </summary>
+    [RequireImplementors]
+    public interface IArchitecture
+    {
+        void SetArchitectureInstance(IArchitecture instance);
+        void Register();
+        void InitArchitecture();
+        void FinishInit();
+        T GetService<T>() where T : IService;
+        T GetModel<T>() where T : IModel;
+        T GetUtility<T>() where T : IUtility;
+        object GetService(Type type);
+        object GetModel(Type type);
+        object GetUtility(Type type);
+        void RegisterService<T>() where T : IService,new();
+        void RegisterModel<T>() where T : IModel,new();
+        void RegisterUtility<T>() where T : IUtility,new();
+
+        void RegisterModel<T>(T modelInstance) where T : IModel;
+        void RegisterService<T>(T serviceInstance) where T : IService;
+        void RegisterUtility<T>(T utilityInstance) where T : IUtility;
+    }
+}

+ 11 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Core/IArchitecture.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: b31c733c3aa4cdd4b960743d9d431154
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 11 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Core/IArchitectureModule.cs

@@ -0,0 +1,11 @@
+namespace Blue
+{
+    /// <summary>
+    /// 模块的基本接口
+    /// 所有模块都需要继承此接口并实现
+    /// </summary>
+    public interface IArchitectureModule
+    {
+        void OnInit();
+    }
+}

+ 11 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Core/IArchitectureModule.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 2a74765de6b66d74dbf16b836db70b1a
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 36 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Core/IArchitectureModuleExtension.cs

@@ -0,0 +1,36 @@
+namespace Blue
+{
+    public static class IArchitectureModuleExtension
+    {
+        private static IArchitecture _architecture;
+        public static void SetArchitecture(IArchitecture architecture)
+        {
+            _architecture = architecture;
+        }
+        public static void RegisterModel<T>(this IArchitectureModule self) where T : IModel, new()
+        {
+            _architecture.RegisterModel<T>();
+        }
+        public static void RegisterModel<T>(this IArchitectureModule self,T modelInstance) where T : IModel
+        {
+            _architecture.RegisterModel<T>(modelInstance);
+        }
+
+        public static void RegisterService<T>(this IArchitectureModule self) where T:IService,new()
+        {
+            _architecture.RegisterService<T>();
+        }
+        public static void RegisterService<T>(this IArchitectureModule self,T serviceInstance) where T : IService
+        {
+            _architecture.RegisterService<T>(serviceInstance);
+        }
+        public static void RegisterUtility<T>(this IArchitectureModule self) where T : IUtility, new()
+        {
+            _architecture.RegisterUtility<T>();
+        }
+        public static void RegisterUtility<T>(this IArchitectureModule self, T utilityInstance) where T : IUtility
+        {
+            _architecture.RegisterUtility<T>(utilityInstance);
+        }
+    }
+}

+ 11 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Core/IArchitectureModuleExtension.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 8a2172eafe60365449adcc0a04674f79
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 6 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Core/IAuto.cs

@@ -0,0 +1,6 @@
+namespace Blue
+{
+    public interface IAuto
+    {
+    }
+}

+ 11 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Core/IAuto.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 3c1cdcc8388923a449c35bd3adcb8fcf
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 9 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Core/IController.cs

@@ -0,0 +1,9 @@
+namespace Blue
+{
+    /// <summary>
+    /// Controller 层接口
+    /// </summary>
+    public interface IController :IAuto,ICanGetService,ICanGetModel,ICanGetUtility,ICanSendCommand,ICanSubscribeEvent,ICanSendQuery
+    {
+    }
+}

+ 11 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Core/IController.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 66a47c3ec2764924ea72fb85f095fdc0
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 10 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Core/IModel.cs

@@ -0,0 +1,10 @@
+namespace Blue
+{
+    /// <summary>
+    /// Model 层接口
+    /// </summary>
+    public interface IModel:IAuto,ICanGetUtility,ICanTriggerEvent
+    {
+        void OnInit();
+    }
+}

+ 11 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Core/IModel.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 503ddaef7fb374740b196c39b34d8ff4
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 10 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Core/IService.cs

@@ -0,0 +1,10 @@
+namespace Blue
+{
+    /// <summary>
+    /// Service 层接口
+    /// </summary>
+    public interface IService : IAuto,ICanGetService, ICanSendCommand,ICanGetModel, ICanGetUtility,ICanSubscribeEvent,ICanTriggerEvent,ICanSendQuery
+    {
+        void OnInit();
+    }
+}

+ 11 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Core/IService.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: e47cad12f256280419369689b8f3a46a
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 9 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Core/IUtility.cs

@@ -0,0 +1,9 @@
+namespace Blue
+{
+    /// <summary>
+    /// Utility 层接口
+    /// </summary>
+    public interface IUtility:IAuto,ICanGetUtility
+    {
+    }
+}

+ 11 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Core/IUtility.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 7969df155656a76438f58da4b53183d6
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 54 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Core/ModuleInitiator.cs

@@ -0,0 +1,54 @@
+using System;
+using System.Collections.Generic;
+
+namespace Blue
+{
+    public class ModuleInitiator:IDisposable
+    {
+        private Type moduleInterfaceType;
+        private List<Type> moduleList;
+        public ModuleInitiator() 
+        {
+            moduleInterfaceType = typeof(IArchitectureModule);
+            moduleList = new List<Type>();
+        }
+        public void PrepairModuleData(Type type) 
+        {
+            if (IsModule(type)) 
+            {
+                moduleList.Add(type);
+            }
+        }
+        public void InitModule() 
+        {
+            int moduleCount = moduleList.Count;
+            if (moduleCount == 0) 
+            {
+                return;
+            }
+            for (int i = 0; i < moduleCount; i++)
+            {
+                IArchitectureModule module =(IArchitectureModule)Activator.CreateInstance(moduleList[i]);
+                module.OnInit();
+            }
+        }
+
+        public void Dispose() 
+        {
+            moduleInterfaceType = null;
+            moduleList = null;
+        }
+        private bool IsModule(Type type)
+        {
+            if (type.IsInterface)
+            {
+                return false;
+            }
+            if (type.IsAbstract)
+            {
+                return false;
+            }
+            return moduleInterfaceType.IsAssignableFrom(type);
+        }
+    }
+}

+ 11 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Core/ModuleInitiator.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 5188fd3725c63fd4d9e31632b19b0172
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

BIN
Assets/Scripts/Blue/0.FrameworkDesign/Design.eddx


+ 7 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Design.eddx.meta

@@ -0,0 +1,7 @@
+fileFormatVersion: 2
+guid: 2b7919ae31a57be4fbcef440aece1f8b
+DefaultImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 8 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Event.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 182ecb4e6148c144eb1311060ec35775
+folderAsset: yes
+DefaultImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 22 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Event/BindablePropertyUnSubscribe.cs

@@ -0,0 +1,22 @@
+using System;
+namespace Blue
+{
+    public struct BindablePropertyUnSubscribe<T> : IUnSubscribe
+    {
+        private Action<T> _onPropertyChanged;
+        private BindableProperty<T> _property;
+
+        public BindablePropertyUnSubscribe(BindableProperty<T> property,Action<T> onPropertyChanged) 
+        {
+            _property = property;
+            _onPropertyChanged = onPropertyChanged;
+        }
+
+        public void UnSubscribe()
+        {
+            _property.UnSubscribe(_onPropertyChanged);
+            _property = null;
+            _onPropertyChanged = null;
+        }
+    }
+}

+ 11 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Event/BindablePropertyUnSubscribe.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: d06c79933b7d1364a82598aeb1b21625
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 41 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Event/ChainEventSubscription.cs

@@ -0,0 +1,41 @@
+using System;
+using System.Collections.Generic;
+
+
+namespace Blue {
+    public class ChainEventSubscription : IChainEventSubscription
+    {
+        private Dictionary<Type, int> actionHashPool;
+        private Type mChainEventType;
+        public ChainEventSubscription(Type chainEventType)
+        {
+            mChainEventType = chainEventType;
+        }
+        public int SubscribeCount => actionHashPool.Count;
+
+        public IChainEventUnSubscribe Subscribe(Type eventType,int actionHashCode,Action onOnSubscribe)
+        {
+            actionHashPool.TryAdd(eventType, actionHashCode);
+            return new DefaultChainEventUnSubcribe(mChainEventType, () => { onOnSubscribe?.Invoke(); UnSubscribe(eventType); });
+        }
+        public bool IsSubscribed(Type eventType)
+        {
+            return actionHashPool.ContainsKey(eventType);
+        }
+        public int GetActionHashCode(Type eventType)
+        {
+            return actionHashPool[eventType];
+        }
+        public List<Type> GetEventTypeList()
+        {
+            List<Type> valueList = new List<Type>(actionHashPool.Count);
+            valueList.AddRange(actionHashPool.Keys);
+            return valueList;
+        }
+
+        public bool UnSubscribe(Type eventType)
+        {
+            return actionHashPool.Remove(eventType);
+        }
+    }
+}

+ 11 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Event/ChainEventSubscription.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: f66d043e4732e3c4ea955f6d1eb44fbe
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 27 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Event/DefaultChainEventUnSubcribe.cs

@@ -0,0 +1,27 @@
+using System;
+namespace Blue
+{
+
+    public class DefaultChainEventUnSubcribe : IChainEventUnSubscribe
+    {
+        private Action mOnUnSub;
+        private Type mChainEventType;
+        public DefaultChainEventUnSubcribe(Type chainEventType,Action onUnSub)
+        {
+            mChainEventType = chainEventType;
+            mOnUnSub = onUnSub;
+        }
+
+        public Type GetChainEventType()
+        {
+            return mChainEventType;
+        }
+
+        public void UnSubscribe()
+        {
+            mOnUnSub?.Invoke();
+            mOnUnSub = null;
+            mChainEventType = null;
+        }
+    }
+}

+ 11 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Event/DefaultChainEventUnSubcribe.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 6a5468baf24a91541953bb08963c7d19
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 160 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Event/DefaultTypeEventSystem.cs

@@ -0,0 +1,160 @@
+using System;
+using System.Collections.Generic;
+
+namespace Blue
+{
+    /// <summary>
+    /// 默认事件系统类,实现ITypeEventSystem
+    /// </summary>
+    public class DefaultTypeEventSystem : ITypeEventSystem
+    {
+        private Dictionary<Type, ISubscription> eventSubscriptionPool = new Dictionary<Type, ISubscription>(128);
+        private Dictionary<Type, IChainEventSubscription> chainEventPool = new Dictionary<Type, IChainEventSubscription>(8);
+        public IUnSubscribe SubscribeEvent<T>(Action<T> onEvent) where T : IEvent
+        {
+            Type t = typeof(T);
+            ISubscription subscription;
+            var adapter = new EventToActionAdapter(onEvent.GetHashCode(),(ievent) => { onEvent?.Invoke((T)ievent); });
+            if (!eventSubscriptionPool.TryGetValue(t, out subscription))
+            {
+                subscription = new TypeEventSubscription(t);
+                eventSubscriptionPool.Add(t, subscription);
+            }
+            return subscription.Subscribe(adapter);
+        }
+
+        public IChainEventUnSubscribe SubscribeChainEvent<T,K>(Action<K> onEvent) where T : IChainEvent where K:IEvent
+        {
+            Type chainEventType = typeof(T);
+            return SubscribeChainEvent(chainEventType,onEvent);
+        }
+        public IChainEventUnSubscribe SubscribeChainEvent<K>(Type chainEventType, Action<K> onEvent) where K : IEvent 
+        {
+            Type eventType = typeof(K);
+            IChainEventSubscription chainSubscription;
+            if (!chainEventPool.TryGetValue(chainEventType, out chainSubscription))
+            {
+                chainSubscription = new ChainEventSubscription(chainEventType);
+                chainEventPool.Add(chainEventType, chainSubscription);
+            }
+            if (chainSubscription.IsSubscribed(eventType))
+            {
+                UnSubscribeEvent(eventType, chainSubscription.GetActionHashCode(eventType));
+                chainSubscription.UnSubscribe(eventType);
+            }
+            ISubscription eventSubscription;
+            var adapter = new EventToActionAdapter(onEvent.GetHashCode(), (ievent) => { onEvent?.Invoke((K)ievent); });
+            if (!eventSubscriptionPool.TryGetValue(eventType, out eventSubscription))
+            {
+                eventSubscription = new TypeEventSubscription(eventType);
+                eventSubscriptionPool.Add(eventType, eventSubscription);
+            }
+            eventSubscription.Subscribe(adapter);
+            return chainSubscription.Subscribe(eventType, onEvent.GetHashCode(),()=> { eventSubscription.UnSubscribe(onEvent.GetHashCode()); });
+        }
+        public void TriggerEvent<T>() where T : IEvent, new()
+        {
+            TriggerEvent(new T());
+        }
+
+        public void TriggerEvent<T>(T e) where T : IEvent
+        {
+            if (eventSubscriptionPool.TryGetValue(e.GetType(), out ISubscription subscription))
+            {
+                subscription.TriggerEvent(e);
+            }
+        }
+
+        public void TriggerChainEvent<T>(params IEvent[] events) where T:IChainEvent
+        {
+            IChainEventSubscription chainSubscription;
+            Type chainEventType = typeof(T);
+            if (chainEventPool.TryGetValue(chainEventType, out chainSubscription))
+            {
+                Dictionary<Type, IEvent> eventInstanceMap = new Dictionary<Type, IEvent>(events.Length);
+                foreach (var mEvent in events)
+                {
+                    eventInstanceMap.TryAdd(mEvent.GetType(),mEvent);
+                }
+                List<Type> chainEventTypeList=chainSubscription.GetEventTypeList();
+                foreach (var eventType in chainEventTypeList)
+                {
+                    IEvent eventInstance;
+                    if (!eventInstanceMap.TryGetValue(eventType, out eventInstance))
+                    {
+                        eventInstance = (IEvent)Activator.CreateInstance(eventType);
+                    }
+                    TriggerEvent(eventInstance);
+                }
+            }
+        }
+        public void TriggerChainEvent<T>() where T : IChainEvent
+        {
+            IChainEventSubscription chainSubscription;
+            Type chainEventType = typeof(T);
+            if (chainEventPool.TryGetValue(chainEventType, out chainSubscription))
+            {
+                List<Type> chainEventTypeList = chainSubscription.GetEventTypeList();
+                foreach (var eventType in chainEventTypeList)
+                {
+                    TriggerEvent((IEvent)Activator.CreateInstance(eventType));
+                }
+            }
+        }
+
+        public void UnSubscribeEvent<T>(Action<T> onEvent) where T : IEvent
+        {
+            Type t = typeof(T);
+            UnSubscribeEvent(t, onEvent.GetHashCode());
+        }
+        public void UnSubscribeChainEvent<T>() where T:IChainEvent
+        {
+            Type chainEventType = typeof(T);
+            UnSubscribeChainEvent(chainEventType);
+        }
+        public void UnSubscribeChainEvent(Type chainEventType)
+        {
+            IChainEventSubscription chainSubscription;
+            if (chainEventPool.TryGetValue(chainEventType, out chainSubscription))
+            {
+                List<Type> chainEventTypeList= chainSubscription.GetEventTypeList();
+                foreach (var eventType in chainEventTypeList)
+                {
+                    UnSubscribeEvent(eventType,chainSubscription.GetActionHashCode(eventType));
+                    chainSubscription.UnSubscribe(eventType);
+                }
+                chainEventPool.Remove(chainEventType);
+            }
+        }
+        public void UnSubscribeEventFromChainEvent<T, K>() where T : IChainEvent where K : IEvent
+        {
+            IChainEventSubscription chainSubscription;
+            Type chainEventType = typeof(T);
+            if (chainEventPool.TryGetValue(chainEventType, out chainSubscription))
+            {
+                Type eventType = typeof(K);
+                if (chainSubscription.UnSubscribe(eventType))
+                {
+                    UnSubscribeEvent(eventType,chainSubscription.GetActionHashCode(eventType));
+                }
+                if (chainSubscription.SubscribeCount == 0)
+                {
+                    chainEventPool.Remove(chainEventType);
+                }
+            }
+        }
+        private bool UnSubscribeEvent(Type eventType, int hash)
+        {
+            bool result = false;
+            if (eventSubscriptionPool.TryGetValue(eventType, out ISubscription subscription))
+            {
+                result=subscription.UnSubscribe(hash);
+                if (subscription.SubscribeCount <= 0)
+                {
+                    eventSubscriptionPool.Remove(eventType);
+                }
+            }
+            return result;
+        }
+    }
+}

+ 11 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Event/DefaultTypeEventSystem.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: b1c6bf9c7ceccdc48be0e5670f6cbbbf
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 49 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Event/EventToActionAdapter.cs

@@ -0,0 +1,49 @@
+using System;
+namespace Blue
+{
+    /// <summary>
+    /// Event Action 适配
+    /// </summary>
+    public struct EventToActionAdapter
+    {
+        private Action<IEvent> mAdapterAction;
+        private int mHashCode;
+
+        /// <summary>
+        /// 初始化 hashCode ,Action
+        /// </summary>
+        /// <param name="hashCode"></param>
+        /// <param name="adapterAction"></param>
+        public EventToActionAdapter(int hashCode,Action<IEvent> adapterAction)
+        {
+            mHashCode = hashCode;
+            mAdapterAction = adapterAction;
+        }
+
+        /// <summary>
+        /// 获取适配的 Action
+        /// </summary>
+        /// <returns></returns>
+        public Action<IEvent> GetAdapterAction()
+        {
+            return mAdapterAction;
+        }
+
+        /// <summary>
+        /// 获取 Action 的 HashCode
+        /// </summary>
+        /// <returns></returns>
+        public int GetActionHashCode()
+        {
+            return mHashCode;
+        }
+
+        /// <summary>
+        /// 清除 Action
+        /// </summary>
+        public void Clear()
+        {
+            mAdapterAction = null;
+        }
+    }
+}

+ 11 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Event/EventToActionAdapter.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 508bb6b400b007049905805f0b89a427
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 8 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Event/IChainEvent.cs

@@ -0,0 +1,8 @@
+using System;
+namespace Blue
+{
+    public interface IChainEvent : IEvent
+    {
+        //IChainEvent NextEvent<T>(Action<T> onEvent) where T : IEvent;
+    }
+}

+ 11 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Event/IChainEvent.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 9f4f56a81d70e9749a9dce79de2bdb63
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 18 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Event/IChainEventSubscription.cs

@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+
+namespace Blue
+{
+	/// <summary>
+	/// 订阅链事件的接口
+	/// </summary>
+	public interface IChainEventSubscription
+	{
+		int SubscribeCount { get; }
+		IChainEventUnSubscribe Subscribe(Type eventType, int actionHashCode, Action onOnSubscribe);
+		List<Type> GetEventTypeList();
+		bool IsSubscribed(Type eventType);
+		int GetActionHashCode(Type eventType);
+		bool UnSubscribe(Type eventType);
+	}
+}

+ 11 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Event/IChainEventSubscription.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: ced60633d27b154448f77c490aafd9b3
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 31 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Event/IChainEventUnSubcribeExtension.cs

@@ -0,0 +1,31 @@
+using System;
+using UnityEngine;
+namespace Blue
+{
+    public static class IChainEventUnSubcribeExtension
+    {
+        private static ITypeEventSystem _typeEventSystem;
+        public static void SetEventSystem(ITypeEventSystem typeEventSystem) 
+        {
+            _typeEventSystem = typeEventSystem;
+        }
+        public static void UnSubscribeAllEventOnGameobjectDestroyed(this IChainEventUnSubscribe unSubscribe, GameObject gameObject)
+        {
+            var trigger = gameObject.GetComponent<UnSubscribeChainEventOnDestroyTrigger>();
+            if (!trigger)
+            {
+                trigger = gameObject.AddComponent<UnSubscribeChainEventOnDestroyTrigger>();
+            }
+            trigger.AddUnSubscribe(unSubscribe);
+        }
+        public static IChainEventUnSubscribe NextEvent<T>(this IChainEventUnSubscribe self,Action<T> onEvent) where T:IEvent
+        {
+            return _typeEventSystem.SubscribeChainEvent(self.GetChainEventType(),onEvent);
+        }
+
+        public static void UnSubscribeAllEventsOnChain(this IChainEventUnSubscribe self) 
+        {
+            _typeEventSystem.UnSubscribeChainEvent(self.GetChainEventType());
+        }
+    }
+}

+ 11 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Event/IChainEventUnSubcribeExtension.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 9b6a4df5b9e8d2d46beeec36947e9988
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 11 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Event/IChainEventUnSubscribe.cs

@@ -0,0 +1,11 @@
+using System;
+namespace Blue
+{
+    /// <summary>
+    /// 链事件取消订阅事件的接口
+    /// </summary>
+    public interface IChainEventUnSubscribe:IUnSubscribe
+    {
+        Type GetChainEventType();
+    }
+}

+ 11 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Event/IChainEventUnSubscribe.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 1d1c4a86f4744964488f49a0f96be4a9
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 6 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Event/IEvent.cs

@@ -0,0 +1,6 @@
+namespace Blue
+{
+    public interface IEvent
+    {
+    }
+}

+ 11 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Event/IEvent.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: fc15043a7bae13545a4917169a4dafbb
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 13 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Event/ISubscription.cs

@@ -0,0 +1,13 @@
+namespace Blue
+{
+    /// <summary>
+    /// 订阅事件的接口
+    /// </summary>
+    public interface ISubscription
+    {
+        int SubscribeCount { get; }
+        IUnSubscribe Subscribe(EventToActionAdapter adapter);
+        bool UnSubscribe(int hashCode);
+        void TriggerEvent(IEvent e);
+    }
+}

+ 11 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Event/ISubscription.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 84b9daa0c1696a24aa1da163cfef3d92
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 28 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Event/ITypeEventSystem.cs

@@ -0,0 +1,28 @@
+using System;
+namespace Blue
+{
+    /// <summary>
+    /// 事件系统接口
+    /// ① 注册事件、注册链事件
+    /// ② 订阅事件、订阅链事件
+    /// ③ 取消订阅事件、取消订阅链事件
+    /// ④ 取消订阅链事件中的事件
+    /// </summary>
+    public interface ITypeEventSystem
+    {
+        void TriggerEvent<T>() where T : IEvent, new();
+        void TriggerEvent<T>(T e) where T : IEvent;
+        void TriggerChainEvent<T>(params IEvent[] events) where T : IChainEvent;
+        void TriggerChainEvent<T>() where T : IChainEvent;
+
+        IUnSubscribe SubscribeEvent<T>(Action<T> onEvent) where T : IEvent;
+        IChainEventUnSubscribe SubscribeChainEvent<T, K>(Action<K> onEvent) where T : IChainEvent where K : IEvent;
+        IChainEventUnSubscribe SubscribeChainEvent<K>(Type chainEventType,Action<K> onEvent) where K : IEvent;
+
+        void UnSubscribeEvent<T>(Action<T> onEvent) where T : IEvent;
+        void UnSubscribeChainEvent<T>() where T : IChainEvent;
+        void UnSubscribeChainEvent(Type chainEventType);
+
+        void UnSubscribeEventFromChainEvent<T, K>() where T : IChainEvent where K : IEvent;
+    }
+}

+ 11 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Event/ITypeEventSystem.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: d82e9e7dfba9ff94fb9aecdfd3d6b496
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 11 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Event/IUnSubscribe.cs

@@ -0,0 +1,11 @@
+using System;
+namespace Blue
+{
+    /// <summary>
+    /// 取消订阅事件的接口
+    /// </summary>
+    public interface IUnSubscribe
+    {
+        void UnSubscribe();
+    }
+}

+ 11 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Event/IUnSubscribe.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 5688daa9d0182bb41b587264043cb717
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 26 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Event/IUnSubscribeExtension.cs

@@ -0,0 +1,26 @@
+using UnityEngine;
+namespace Blue
+{
+    public static class IUnSubscribeExtension
+    {
+        public static void UnSubScribeWhenGameObjectDestroyed(this  IUnSubscribe unSubscribe,GameObject gameObject) 
+        {
+            var trigger= gameObject.GetComponent<UnSubscribeOnDestroyTrigger>();
+            if (!trigger) 
+            {
+                trigger = gameObject.AddComponent<UnSubscribeOnDestroyTrigger>();
+            }
+            trigger.AddUnSubscribe(unSubscribe);
+        }
+        public static void UnSubScribeWhenGameObjectDisabled(this IUnSubscribe unSubscribe, GameObject gameObject)
+        {
+            var trigger = gameObject.GetComponent<UnSubscribeOnDisableTrigger>();
+            if (!trigger)
+            {
+                trigger = gameObject.AddComponent<UnSubscribeOnDisableTrigger>();
+            }
+            trigger.AddUnSubscribe(unSubscribe);
+        }
+
+    }
+}

+ 11 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Event/IUnSubscribeExtension.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 303c2a2d213a0334190a068194e50398
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 49 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Event/TypeEventSubscription.cs

@@ -0,0 +1,49 @@
+using System;
+using System.Collections.Generic;
+namespace Blue
+{
+    public class TypeEventSubscription : ISubscription
+    {
+        private Action<IEvent> mOnEvent;
+        private int subscribeCount;
+        private Type mEventType;
+        private Dictionary<int, EventToActionAdapter> adapterPool = new Dictionary<int, EventToActionAdapter>();
+        public TypeEventSubscription(Type eventType) 
+        {
+            mEventType = eventType;
+        }
+        public int SubscribeCount { get => subscribeCount;}
+        public IUnSubscribe Subscribe(EventToActionAdapter adapter)
+        {
+            try
+            {
+                adapterPool.Add(adapter.GetActionHashCode(), adapter);
+                mOnEvent += adapter.GetAdapterAction();
+                subscribeCount++;
+                return new TypeEventSystemUnSubscribe(() => { UnSubscribe(adapter.GetActionHashCode()); });
+            }
+            catch (ArgumentException)
+            {
+                //LogUtil.LogError("Event subscription duplicated on "+mEventType+",please make sure you have unsubscribe it before re-subscribe!");
+                throw;
+            }
+        }
+        public void TriggerEvent(IEvent e)
+        {
+            mOnEvent?.Invoke(e);
+        }
+
+        public bool UnSubscribe(int hashCode)
+        {
+            if (adapterPool.TryGetValue(hashCode, out var adapter)) 
+            {
+                mOnEvent -= adapter.GetAdapterAction();
+                subscribeCount--;
+                adapter.Clear();
+                adapterPool.Remove(hashCode);
+                return true;
+            }
+            return false;
+        }
+    }
+}

+ 11 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Event/TypeEventSubscription.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: a3815b906ccbdc8468f82c22c1822841
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 19 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Event/TypeEventSystemUnSubscribe.cs

@@ -0,0 +1,19 @@
+using System;
+
+namespace Blue
+{
+
+    public struct TypeEventSystemUnSubscribe : IUnSubscribe
+    {
+        private Action mOnUnSubscribe;
+        public TypeEventSystemUnSubscribe(Action onUnSubscribe) 
+        {
+            mOnUnSubscribe = onUnSubscribe;
+        }
+        public void UnSubscribe() 
+        {
+            mOnUnSubscribe?.Invoke();
+            mOnUnSubscribe = null;
+        }
+    }
+}

+ 11 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Event/TypeEventSystemUnSubscribe.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 44ae6ff8f6dfeb844bac5d1b65b54d80
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 22 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Event/UnSubscribeChainEventOnDestroyTrigger.cs

@@ -0,0 +1,22 @@
+using System.Collections.Generic;
+using UnityEngine;
+namespace Blue
+{
+    public class UnSubscribeChainEventOnDestroyTrigger : MonoBehaviour
+    {
+        private HashSet<IChainEventUnSubscribe> unSubscribes = new HashSet<IChainEventUnSubscribe>();
+
+        public void AddUnSubscribe(IChainEventUnSubscribe unSubscribe)
+        {
+            unSubscribes.Add(unSubscribe);
+        }
+        private void OnDestroy()
+        {
+            foreach (var item in unSubscribes)
+            {
+                item.UnSubscribeAllEventsOnChain();
+            }
+            unSubscribes.Clear();
+        }
+    }
+}

+ 11 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Event/UnSubscribeChainEventOnDestroyTrigger.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: e2ea2cf248d81c942b3e2f71515b8a5a
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 22 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Event/UnSubscribeOnDestroyTrigger.cs

@@ -0,0 +1,22 @@
+using System.Collections.Generic;
+using UnityEngine;
+namespace Blue
+{
+    public class UnSubscribeOnDestroyTrigger : MonoBehaviour
+    {
+        private HashSet<IUnSubscribe> unSubscribes = new HashSet<IUnSubscribe>();
+
+        public void AddUnSubscribe(IUnSubscribe unSubscribe) 
+        {
+            unSubscribes.Add(unSubscribe);
+        }
+        private void OnDestroy()
+        {
+            foreach (var item in unSubscribes)
+            {
+                item.UnSubscribe();
+            }
+            unSubscribes.Clear();
+        }
+    }
+}

+ 11 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Event/UnSubscribeOnDestroyTrigger.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 2410ca90123a40f40b013a57fed4236d
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 22 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Event/UnSubscribeOnDisableTrigger.cs

@@ -0,0 +1,22 @@
+using System.Collections.Generic;
+using UnityEngine;
+namespace Blue
+{
+    public class UnSubscribeOnDisableTrigger : MonoBehaviour
+    {
+        private HashSet<IUnSubscribe> unSubscribes = new HashSet<IUnSubscribe>();
+
+        public void AddUnSubscribe(IUnSubscribe unSubscribe) 
+        {
+            unSubscribes.Add(unSubscribe);
+        }
+        private void OnDisable()
+        {
+            foreach (var item in unSubscribes)
+            {
+                item.UnSubscribe();
+            }
+            unSubscribes.Clear();
+        }
+    }
+}

+ 11 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Event/UnSubscribeOnDisableTrigger.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 67d3e185b45a31b46ae1d9b41aaefd8d
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 8 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Hand.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: f97b2a2e9d3b4724e9a700e43f803b0e
+folderAsset: yes
+DefaultImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 8 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Hand/IQueryCommandHandler.cs

@@ -0,0 +1,8 @@
+namespace Blue
+{
+    public interface IQueryCommandHandler
+    {
+        void ExcuteQueryCommand(ICommand command);
+        void ExcuteQueryCommand<T>() where T:ICommand,new();
+    }
+}

+ 11 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Hand/IQueryCommandHandler.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 0589e9d01727a9242ac4bb6701ade270
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 15 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Hand/QueryDefault_Hand.cs

@@ -0,0 +1,15 @@
+namespace Blue
+{
+    public class QueryDefault_Hand : IQueryCommandHandler
+    {
+        public void ExcuteQueryCommand(ICommand command)
+        {
+            command.OnExcute();
+        }
+
+        public void ExcuteQueryCommand<T>() where T : ICommand, new()
+        {
+            ExcuteQueryCommand(new T());
+        }
+    }
+}

+ 11 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Hand/QueryDefault_Hand.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: f65ee8c3cb5750344add0dbe504ffe68
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 8 - 0
Assets/Scripts/Blue/0.FrameworkDesign/IOC.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: f127b83d66b479f4289ea12e6c748925
+folderAsset: yes
+DefaultImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 236 - 0
Assets/Scripts/Blue/0.FrameworkDesign/IOC/AbstractArchitectureComponentInjector.cs

@@ -0,0 +1,236 @@
+using System;
+using System.Reflection;
+using System.Collections.Generic;
+
+namespace Blue
+{
+    public abstract class AbstractArchitectureComponentInjector : IArchitectureComponentInjector
+    {
+        private Type mComponentType;
+        private bool canInjectTypeListNotInitiated=true;
+        private List<Type> canInjectTypeList;
+        private Dictionary<Type, List<InjectInfo>> injectionMap;
+        protected IArchitecture architectureInstance;
+
+        public AbstractArchitectureComponentInjector(Type componentType)
+        {
+            SetComponentType(componentType);
+        }
+        public void SetArchitecture(IArchitecture architecture)
+        {
+            if (architectureInstance == null)
+            {
+                architectureInstance = architecture;
+            }
+        }
+        private void SetComponentType(Type componentType)
+        {
+            mComponentType = componentType;
+        }
+
+        public virtual void PrepairInjectionData(Type baseType)
+        {
+            if (canInjectTypeListNotInitiated)
+            {
+                canInjectTypeListNotInitiated = false;
+                injectionMap = new Dictionary<Type, List<InjectInfo>>();
+                canInjectTypeList = GetCanInjectTypeList(mComponentType);
+            }
+            FilterInjectInfoList(GetInjectInfo(baseType), mComponentType);
+        }
+        public virtual void Inject(IArchitecture architecture)
+        {
+            if (injectionMap == null)
+            {
+                return;
+            }
+            SetArchitecture(architecture);
+            int injectionCount = injectionMap.Count;
+            List<Type> types = new List<Type>(injectionCount);
+            types.AddRange(injectionMap.Keys);
+            if (injectionCount > 0)
+            {
+                for (int i = 0; i < injectionCount; i++)
+                {
+                    Type baseType = types[i];
+                    object injectObject = GetInjectObject(baseType);
+                    if (injectObject == null)
+                    {
+                        continue;
+                        //throw new Exception("Can not find instance of "+baseType.FullName+" ,please make sure you have registed it.");
+                    }
+                    if (!injectObject.GetType().Equals(baseType))
+                    {
+                        continue;//Not the registed Type
+                    }
+                    List<InjectInfo> typeInjectInfoList = injectionMap[baseType];
+                    foreach (InjectInfo injectInfo in typeInjectInfoList)
+                    {
+                        if (injectInfo.InjectScope == InjectScope.Prototype)
+                        {
+                            InjectPrototype(injectObject, injectInfo.InjectField, injectInfo.InjectType);
+                        }
+                        else
+                        {
+                            object injectInstance = GetInjectInstance(injectInfo.InjectType);
+                            InjectSingleton(injectObject, injectInfo.InjectField, injectInstance);
+                        }
+                    }
+                }
+            }
+        }
+        public void Dispose()
+        {
+            if (canInjectTypeList != null)
+            {
+                canInjectTypeList.Clear();
+                canInjectTypeList = null;
+            }
+            if (injectionMap != null)
+            {
+                injectionMap.Clear();
+                injectionMap = null;
+            }
+            mComponentType = null;
+            architectureInstance = null;
+        }
+        protected virtual object GetInjectObject(Type baseType)
+        {
+            return null;
+        }
+        protected virtual object GetInjectInstance(Type injectType)
+        {
+            if (TypeChecker.Instance.IsService(injectType))
+            {
+                return architectureInstance.GetService(injectType);
+            }
+            if (TypeChecker.Instance.IsModel(injectType))
+            {
+                return architectureInstance.GetModel(injectType);
+            }
+            if (TypeChecker.Instance.IsUtility(injectType))
+            {
+                return architectureInstance.GetUtility(injectType);
+            }
+            throw new Exception(injectType.FullName+" is not a can inject type!");
+        }
+        protected Dictionary<Type, List<InjectInfo>> GetInjectionMap()
+        {
+            return injectionMap;
+        }
+        protected void InjectSingleton(object injectObject, FieldInfo fieldInfo, object injectInstance)
+        {
+            fieldInfo.SetValue(injectObject, injectInstance);
+        }
+        protected void InjectPrototype(object injectObject, FieldInfo fieldInfo, Type injectType)
+        {
+            fieldInfo.SetValue(injectObject, Activator.CreateInstance(injectType));
+        }
+
+        private List<Type> GetCanInjectTypeList(Type baseType)
+        {
+            List<Type> canInjectTypeList = new List<Type>();
+            Type[] interfaceArr = baseType.GetInterfaces();
+            for (int i = 0; i < interfaceArr.Length; i++)
+            {
+                Type interfaceType = interfaceArr[i];
+                InjectRuleAttribute attribute = null;
+                if ((attribute = interfaceType.GetCustomAttribute<InjectRuleAttribute>()) != null)
+                {
+                    canInjectTypeList.AddRange(attribute.GetCanInjectList());
+                }
+            }
+            return canInjectTypeList;
+        }
+        private List<InjectInfo> GetInjectInfo(Type tmpType)
+        {
+            List<InjectInfo> injectInfoList = new List<InjectInfo>();
+            FieldInfo[] tmpFieldArr = tmpType.GetFields(BindingFlags.Instance | BindingFlags.NonPublic);
+            int length = 0;
+            if (tmpFieldArr != null)
+            {
+                length = tmpFieldArr.Length;
+            }
+            for (int i = 0; i < length; i++)
+            {
+                FieldInfo tmpField = tmpFieldArr[i];
+                AutoAttribute autoInjectAttribute = tmpField.GetCustomAttribute<AutoAttribute>();
+                if (autoInjectAttribute != null)
+                {
+                    InjectInfo injectInfo = new InjectInfo()
+                    {
+                        BaseType = tmpType,
+                        InjectField = tmpField,
+                        InjectScope = autoInjectAttribute.GetInjectScope()
+                    };
+                    if (autoInjectAttribute.GetInjectType() != null)
+                    {
+                        if (CheckType(tmpField.FieldType, autoInjectAttribute.GetInjectType()))
+                        {
+                            injectInfo.InjectType = autoInjectAttribute.GetInjectType();
+                        }
+                        else
+                        {
+                            throw new Exception("Can not finish the injection of:" + tmpType.FullName + ": property: " + tmpField.Name + ", please check the injectType!");
+                        }
+                    }
+                    else
+                    {
+                        injectInfo.InjectType = tmpField.FieldType;
+                    }
+                    injectInfoList.Add(injectInfo);
+                }
+            }
+            return injectInfoList;
+        }
+        //if the injectinfo not match the inject rule,than remove it from the injectInfoList
+        //for example,you can not  inject a IService instance in a IMolde implementation class 
+        private void FilterInjectInfoList(List<InjectInfo> injectInfoList, Type type)
+        {
+            int count = injectInfoList.Count;
+            for (int i = 0; i < count; i++)
+            {
+                InjectInfo injectInfo = injectInfoList[i];
+                if (CheckIfCanInject(canInjectTypeList, injectInfo.InjectType))
+                {
+                    if (injectionMap.ContainsKey(injectInfo.BaseType))
+                    {
+                        injectionMap[injectInfo.BaseType].Add(injectInfo);
+                    }
+                    else
+                    {
+                        List<InjectInfo> typeInjectInfoList = new List<InjectInfo>();
+                        typeInjectInfoList.Add(injectInfo);
+                        injectionMap.Add(injectInfo.BaseType, typeInjectInfoList);
+                    }
+                }
+            }
+        }
+        //check if the fieldType and injectType is mismatch;
+        private bool CheckType(Type fieldType, Type injectType)
+        {
+            if (injectType.Equals(fieldType))
+            {
+                return true;
+            }
+            if (fieldType.IsInterface)
+            {
+                return fieldType.IsAssignableFrom(injectType);
+            }
+            return injectType.IsSubclassOf(fieldType);
+        }
+        private bool CheckIfCanInject(List<Type> canInjectTypeList, Type injectType)
+        {
+            bool result = false;
+            foreach (var canInjectType in canInjectTypeList)
+            {
+                if (canInjectType.IsAssignableFrom(injectType))
+                {
+                    result = true;
+                    break;
+                }
+            }
+            return result;
+        }
+    }
+}

+ 11 - 0
Assets/Scripts/Blue/0.FrameworkDesign/IOC/AbstractArchitectureComponentInjector.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 8214e77b5dfd03f4caf9b282e105b66c
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 132 - 0
Assets/Scripts/Blue/0.FrameworkDesign/IOC/ArchitectureInjecter.cs

@@ -0,0 +1,132 @@
+using System.Diagnostics;
+using System.Linq.Expressions;
+using System;
+
+namespace Blue
+{
+    /// <summary>
+    /// Architecture注入类
+    /// 主要负责四层 Controller、Model、Service、Utility的分别注入
+    /// </summary>
+    public class ArchitectureInjecter:IInjector
+    {
+        private IArchitectureComponentInjector controllerInjector;
+        private IArchitectureComponentInjector serviceInjector;
+        private IArchitectureComponentInjector modelInjector;
+        private IArchitectureComponentInjector utilityInjector;
+
+        /// <summary>
+        /// ArchitectureInjecter初始化
+        /// 主要初始化四层 Controller、Model、Service、Utility的注入
+        /// </summary>
+        public ArchitectureInjecter()
+        {
+            controllerInjector = new ControllerInjector();
+            serviceInjector = new ServiceInjector();
+            modelInjector = new ModelInjector();
+            utilityInjector = new UtilityInjector();
+        }
+
+        public void PrepairInjectionData(Type processtype)
+        {
+            PrepairInjectionDataImpl(processtype);
+        }
+
+        /// <summary>
+        /// 根据传入的类型注入到指定的层注入
+        /// </summary>
+        /// <param name="baseType">传入的类型</param>
+        private void PrepairInjectionDataImpl(Type baseType)
+        {
+            if (!TypeChecker.Instance.IsCanInject(baseType))
+            {
+                return;
+            }
+
+            if (TypeChecker.Instance.IsController(baseType))
+            {
+                PrepairControllerInjectionData(baseType);
+            }
+            if (TypeChecker.Instance.IsService(baseType))
+            {
+                PrepairServiceInjectionData(baseType);
+            }
+            if (TypeChecker.Instance.IsModel(baseType))
+            {
+                PrepairModelInjectionData(baseType);
+            }
+            if (TypeChecker.Instance.IsUtility(baseType))
+            {
+                PrepairUtilityInjectionData(baseType);
+            }
+        }
+
+        /// <summary>
+        /// 设置 Architecture
+        /// Controller、Model、Service、Utility注入分别设置architecture
+        /// </summary>
+        public void Inject(IArchitecture architecture)
+        {
+            InjectImpl(architecture);
+        }
+
+        /// <summary>
+        /// 执行与释放或重置非托管资源相关的应用程序定义的任务
+        /// </summary>
+        public void Dispose()
+        {
+            controllerInjector.Dispose();
+            serviceInjector.Dispose();
+            modelInjector.Dispose();
+            utilityInjector.Dispose();
+            controllerInjector = null;
+            serviceInjector = null;
+            modelInjector = null;
+            utilityInjector = null;
+        }
+
+        /// <summary>
+        /// Controller、Model、Service、Utility注入设置architecture
+        /// </summary>
+        /// <param name="architecture"></param>
+        private void InjectImpl(IArchitecture architecture)
+        {
+            controllerInjector.Inject(architecture);
+            serviceInjector.Inject(architecture);
+            modelInjector.Inject(architecture);
+            utilityInjector.Inject(architecture);
+        }
+
+        /// <summary>
+        /// 预注入Controller数据
+        /// </summary>
+        private void PrepairControllerInjectionData(Type baseType)
+        {
+            controllerInjector.PrepairInjectionData(baseType);
+        }
+
+        /// <summary>
+        /// 预注入Model数据
+        /// </summary>
+        private void PrepairModelInjectionData(Type baseType)
+        {
+            modelInjector.PrepairInjectionData(baseType);
+        }
+
+        /// <summary>
+        /// 预注入Service数据
+        /// </summary>
+        private void PrepairServiceInjectionData(Type baseType)
+        {
+            serviceInjector.PrepairInjectionData(baseType);
+        }
+
+        /// <summary>
+        /// 预注入Utility数据
+        /// </summary>
+        private void PrepairUtilityInjectionData(Type baseType)
+        {
+            utilityInjector.PrepairInjectionData(baseType);
+        }
+    }
+}

+ 11 - 0
Assets/Scripts/Blue/0.FrameworkDesign/IOC/ArchitectureInjecter.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 7e47abc65d2742c4ea267497fb2cff32
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 36 - 0
Assets/Scripts/Blue/0.FrameworkDesign/IOC/AutoAttribute.cs

@@ -0,0 +1,36 @@
+using System;
+
+namespace Blue
+{
+    /// <summary>
+    /// 自动化
+    /// </summary>
+    [AttributeUsage(AttributeTargets.Field)]
+    public class AutoAttribute : Attribute
+    {
+        private Type type;
+        private InjectScope scope;
+        public AutoAttribute()
+        {
+            scope = InjectScope.Singleton;
+        }
+        public AutoAttribute(Type injectType):base()
+        {
+            type = injectType;
+        }
+        public AutoAttribute(Type injectType, InjectScope injectScope)
+        {
+            type = injectType;
+            scope = injectScope;
+        }
+        public Type GetInjectType()
+        {
+            return type;
+        }
+        public InjectScope GetInjectScope()
+        {
+            return scope;
+        }
+
+    }
+}

+ 11 - 0
Assets/Scripts/Blue/0.FrameworkDesign/IOC/AutoAttribute.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: a1ba8f9fa51acb24f88d6e14968e5b25
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 54 - 0
Assets/Scripts/Blue/0.FrameworkDesign/IOC/ControllerInjector.cs

@@ -0,0 +1,54 @@
+using System;
+using System.Collections.Generic;
+using UnityEngine;
+namespace Blue
+{
+
+    public class ControllerInjector : AbstractArchitectureComponentInjector
+    {
+        public ControllerInjector():base(typeof(IController))
+        {
+        }
+        private  object[] GetInjectObjects(Type baseType)
+        {
+            return GameObject.FindObjectsOfType(baseType, true);
+        }
+        public override void Inject(IArchitecture architecture)
+        {
+            SetArchitecture(architecture);
+            Dictionary<Type, List<InjectInfo>> injectionMap = GetInjectionMap();
+            if (injectionMap == null)
+            {
+                return;
+            }
+            int injectionCount = injectionMap.Count;
+            var types = injectionMap.Keys;
+            if (injectionCount > 0)
+            {
+                foreach (Type baseType in types)
+                {
+                    object[] injectObjects = GetInjectObjects(baseType);
+                    List<InjectInfo> typeInjectInfoList = injectionMap[baseType];
+                    foreach (InjectInfo injectInfo in typeInjectInfoList)
+                    {
+                        if (injectInfo.InjectScope == InjectScope.Prototype)
+                        {
+                            for (int i = 0; i < injectObjects.Length; i++)
+                            {
+                                InjectPrototype(injectObjects[i], injectInfo.InjectField, injectInfo.InjectType);
+                            }
+                        }
+                        else
+                        {
+                            object injectInstance = GetInjectInstance(injectInfo.InjectType);
+                            for (int i = 0; i < injectObjects.Length; i++)
+                            {
+                                InjectSingleton(injectObjects[i], injectInfo.InjectField, injectInstance);
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+}

+ 11 - 0
Assets/Scripts/Blue/0.FrameworkDesign/IOC/ControllerInjector.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 144a0729d028e0e44a5c3f8f3e6518df
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 19 - 0
Assets/Scripts/Blue/0.FrameworkDesign/IOC/IArchitectureComponentInjector.cs

@@ -0,0 +1,19 @@
+using System;
+namespace Blue
+{
+    /// <summary>
+    /// 实现Architecture组件注入的接口
+    /// </summary>
+    public interface IArchitectureComponentInjector:IDisposable
+    {
+        /// <summary>
+        /// 根据类型预注入数据
+        /// </summary>
+        void PrepairInjectionData(Type baseType);
+
+        /// <summary>
+        /// architecture注入
+        /// </summary>
+        void Inject(IArchitecture architecture);
+    }
+}

+ 11 - 0
Assets/Scripts/Blue/0.FrameworkDesign/IOC/IArchitectureComponentInjector.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 105d465be23a30444bf454786de1b4b1
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 19 - 0
Assets/Scripts/Blue/0.FrameworkDesign/IOC/IInjector.cs

@@ -0,0 +1,19 @@
+using System;
+namespace Blue
+{
+    /// <summary>
+    /// 实现注入功能的接口
+    /// </summary>
+    public interface IInjector:IDisposable
+    {
+        /// <summary>
+        /// 根据类型预注入数据
+        /// </summary>
+        void PrepairInjectionData(Type processType);
+
+        /// <summary>
+        /// architectureInstance注入
+        /// </summary>
+        void Inject(IArchitecture architectureInstance);
+    }
+}

+ 11 - 0
Assets/Scripts/Blue/0.FrameworkDesign/IOC/IInjector.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: aa04e3a22ee33394aad98f1fc928cdc9
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 65 - 0
Assets/Scripts/Blue/0.FrameworkDesign/IOC/IOCContainer.cs

@@ -0,0 +1,65 @@
+using System.Collections.Generic;
+using System;
+
+namespace Blue
+{
+    /// <summary>
+    /// IOC容器---根据类型存储Object
+    /// </summary>
+    public class IOCContainer
+    {
+        private Dictionary<Type, object> container = new Dictionary<Type, object>();
+
+        /// <summary>
+        /// 将实例注入IOC容器
+        /// </summary>
+        public void Register<T>() where T:new()
+        {
+            Register(new T());
+        }
+
+        /// <summary>
+        /// 将实例注入IOC容器
+        /// </summary>
+        public void Register<T>(T instance)
+        {
+            Type t = typeof(T);
+            if (container.ContainsKey(t))
+            {
+                container[t] = instance;
+            }
+            else
+            {
+                container.Add(t,instance);
+            }
+        }
+
+        /// <summary>
+        /// 根据类型从IOC容器获取对象
+        /// </summary>
+        public object Get(Type type)
+        {
+            if (container.TryGetValue(type,out object instance))
+            {
+                return instance;
+            }
+            return default;
+        }
+
+        /// <summary>
+        /// 从IOC容器获取指定的实例
+        /// </summary>
+        public T Get<T>()
+        {
+            Type t = typeof(T);
+            if (container.TryGetValue(t, out object instance))
+            {
+                return (T)instance;
+            }
+            else
+            {
+                throw new Exception("Can Not Find Instance of type "+t.FullName+",Please Call Register At First!");
+            }
+        }
+    }
+}

+ 11 - 0
Assets/Scripts/Blue/0.FrameworkDesign/IOC/IOCContainer.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 2ebda3f9caf5b6c4d8643c4ca72881a7
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 13 - 0
Assets/Scripts/Blue/0.FrameworkDesign/IOC/InjectInfo.cs

@@ -0,0 +1,13 @@
+using System;
+using System.Reflection;
+
+namespace Blue
+{
+    public class InjectInfo
+    {
+        public Type BaseType { get; set; }
+        public FieldInfo InjectField { get; set; }
+        public Type InjectType { get; set; }
+        public InjectScope InjectScope { get; set; }
+    }
+}

+ 11 - 0
Assets/Scripts/Blue/0.FrameworkDesign/IOC/InjectInfo.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 8eb598d89bd29854f9a9fe845b908385
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 40 - 0
Assets/Scripts/Blue/0.FrameworkDesign/IOC/InjectRuleAttribute.cs

@@ -0,0 +1,40 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace Blue
+{
+    /// <summary>
+    /// 注入规则属性---可以对接口应用属性
+    /// </summary>
+    [AttributeUsage(AttributeTargets.Interface)]
+    public class InjectRuleAttribute : Attribute
+    {
+        private List<Type> canInjectList;
+        private Type baseInjectType;
+        public InjectRuleAttribute(params Type[] canInject)
+        {
+            baseInjectType = typeof(IAuto);
+            canInjectList = new List<Type>(canInject.Length);
+            foreach (var item in canInject)
+            {
+                if (item.GetInterfaces().Contains(baseInjectType))
+                {
+                    canInjectList.Add(item);
+                }
+            }
+        }
+        public List<Type> GetCanInjectList()
+        {
+            return canInjectList;
+        }
+        public bool IfCanInject(Type canInject)
+        {
+            if (canInjectList.Contains(canInject))
+            {
+                return true;
+            }
+            return false;
+        }
+    }
+}

+ 11 - 0
Assets/Scripts/Blue/0.FrameworkDesign/IOC/InjectRuleAttribute.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 2ad7db74bb765af499b9cd9dc185e2f1
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 11 - 0
Assets/Scripts/Blue/0.FrameworkDesign/IOC/InjectScope.cs

@@ -0,0 +1,11 @@
+namespace Blue
+{
+    /// <summary>
+    /// 注入范围
+    /// </summary>
+    public enum InjectScope
+    {
+        Singleton,
+        Prototype
+    }
+}

+ 11 - 0
Assets/Scripts/Blue/0.FrameworkDesign/IOC/InjectScope.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: b71e99f9b37a39949ac4e3aa4a5e98a8
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 43 - 0
Assets/Scripts/Blue/0.FrameworkDesign/IOC/ModelInjector.cs

@@ -0,0 +1,43 @@
+using System;
+
+namespace Blue
+{
+    /// <summary>
+    /// Model 层注入
+    /// </summary>
+    public class ModelInjector : AbstractArchitectureComponentInjector
+    {
+        private Type modelType;
+
+        /// <summary>
+        /// 获取 IModel 的类型
+        /// </summary>
+        public ModelInjector() : base(typeof(IModel)) {
+            modelType = typeof(IModel);
+        }
+
+        /// <summary>
+        /// 根据类型获取注入的Object
+        /// </summary>
+        protected override object GetInjectObject(Type baseType)
+        {
+            object instance = architectureInstance.GetModel(baseType);
+            if (instance == null)
+            {
+                var interfaces = baseType.GetInterfaces(); // 当在派生类中重写时,获取由当前 Type 实现或继承的所有接口
+                foreach (var type in interfaces)
+                {
+                    if (modelType.IsAssignableFrom(type)&&!modelType.Equals(type)) // 确定指定类型 type 的实例是否能分配给当前类型的变量
+                    {
+                        instance = architectureInstance.GetModel(type);
+                        if (instance != null)
+                        {
+                            break;
+                        }
+                    }
+                }
+            }
+            return instance;
+        }
+    }
+}

+ 11 - 0
Assets/Scripts/Blue/0.FrameworkDesign/IOC/ModelInjector.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 7d35a136b3463e947a131ae517850345
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 43 - 0
Assets/Scripts/Blue/0.FrameworkDesign/IOC/ServiceInjector.cs

@@ -0,0 +1,43 @@
+using System;
+namespace Blue
+{
+    /// <summary>
+    /// Service 层注入
+    /// </summary>
+    public class ServiceInjector : AbstractArchitectureComponentInjector
+    {
+        private Type serviceType;
+
+        /// <summary>
+        /// 获取 IService 的类型
+        /// </summary>
+        public ServiceInjector():base(typeof(IService)) {
+            serviceType = typeof(IService);
+        }
+
+        /// <summary>
+        /// 根据类型获取注入的Object
+        /// </summary>
+        protected override object GetInjectObject(Type baseType)
+        {
+            object instance= architectureInstance.GetService(baseType);
+            if (instance == null)
+            {
+                var interfaces = baseType.GetInterfaces();
+
+                foreach (var type in interfaces)
+                {
+                    if (serviceType.IsAssignableFrom(type)&&!serviceType.Equals(type))
+                    {
+                        instance = architectureInstance.GetService(type);
+                        if (instance != null)
+                        {
+                            break;
+                        }
+                    }
+                }
+            }
+            return instance;
+        }
+    }
+}

+ 11 - 0
Assets/Scripts/Blue/0.FrameworkDesign/IOC/ServiceInjector.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 83a1500b493c1e34daae8bc88af224a5
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

Some files were not shown because too many files changed in this diff