SceneIOCContainer.cs 868 B

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