public T GetObject(DIContainer container) { var obj = Activator.CreateInstance <T>(); container.BuildUp(obj); return(obj); }
public T GetObject(DIContainer container) { var gameObject = new MaskFinder().Find(_path); if (gameObject == null) { throw new ContainerException("Can't find game object \"" + _path + "\""); } if (!_inited) { container.BuildUp(gameObject); _inited = true; } if (typeof(T) == typeof(GameObject)) { return((T)(object)gameObject); } if (typeof(T) == typeof(Transform)) { return((T)(object)gameObject.transform); } T component = gameObject.GetComponents <Component>().OfType <T>().FirstOrDefault(); if (component != null) { return(component); } throw new ContainerException("Can't find component \"" + typeof(T).FullName + "\" of game object \"" + _path + "\""); }
public T GetObject(DIContainer container) { if (!_inited) { _instance = Activator.CreateInstance <T>(); _inited = true; container.BuildUp(_instance); } return(_instance); }
public T GetObject(DIContainer container) { if (!_inited) { container.BuildUp(_instance); _inited = true; } return(_instance); }
void Start() { Application.runInBackground = true; _diContainer = new DIContainer(); var swipeController = gameObject.AddComponent <SwipeController>(); var monoProvider = gameObject.AddComponent <MonoProvider>(); _diContainer.RegisterInstance <DIContainer>(_diContainer); _diContainer.RegisterInstance <FieldMediator>(FieldMediator); _diContainer.RegisterInstance <MenuMediator>(MenuMediator); _diContainer.RegisterInstance <SwipeController>(swipeController); _diContainer.RegisterInstance <MonoProvider>(monoProvider); _diContainer.RegisterSingleton <PhotonServerController>(); _diContainer.BuildUp(MenuMediator); }