框架上传

This commit is contained in:
2025-03-31 11:16:52 +08:00
parent 7197b4c0d0
commit ffcdddbd2a
429 changed files with 19115 additions and 1579 deletions

View File

@@ -0,0 +1,72 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Stary.Evo
{
public class IOCContainer
{
/// <summary>
/// 实例
/// </summary>
public Dictionary<Type, object> mInstances = new Dictionary<Type, object>();
/// <summary>
/// 注册
/// </summary>
/// <param name="instance"></param>
/// <typeparam name="T"></typeparam>
public void Register<T>(T instance)
{
var key = typeof(T);
if (mInstances.ContainsKey(key))
{
mInstances[key] = instance;
}
else
{
mInstances.Add(key, instance);
}
}
/// <summary>
/// 注销
/// </summary>
public void UnRegister<T>() where T : class
{
var key = typeof(T);
if (mInstances.TryGetValue(key, out var retObj))
{
retObj = null;
mInstances.Remove(key);
}
else
{
Debug.LogErrorFormat("IOC容器里不存在Key:--【{0}】--请用对应创建的key进行调用",key);
}
}
public T Get<T>() where T : class
{
var key = typeof(T);
if (mInstances.TryGetValue(key, out var retObj))
{
return retObj as T;
}
else
{
Debug.LogErrorFormat("IOC容器里不存在Key:--【{0}】--请用对应创建的key进行调用",key);
}
return null;
}
}
}

View File

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