SceneIOCContainer.cs 740 B

12345678910111213141516171819202122232425262728293031
  1. using System.Collections.Generic;
  2. using Blue;
  3. /// <summary>
  4. /// 场景IOC容器,用于存储对象、物体
  5. /// </summary>
  6. public class SceneIOCContainer : BlueSingleton<SceneIOCContainer>
  7. {
  8. private Dictionary<string, object> objContainer = new Dictionary<string, object>();
  9. public void Push(string objName,object obj)
  10. {
  11. if(objContainer.ContainsKey(objName))
  12. {
  13. objContainer[objName] = obj;
  14. }
  15. else
  16. {
  17. objContainer.Add(objName,obj);
  18. }
  19. }
  20. public object Pull(string objName)
  21. {
  22. if(objContainer.ContainsKey(objName))
  23. {
  24. return objContainer[objName];
  25. }
  26. return null;
  27. }
  28. }