public virtual T CreateUIMediator <T>(RectTransform parent, string customPath = "", ViewInitData data = null) where T : IMediator, new() { if (parent == null) { parent = UIParent(); } //view var view = Assets.GetAsset <GameObject>(GetMediatorPath(typeof(T), customPath)); view.transform.SetParent(parent, false); //mediator var mediator = new T(); Injector.InjectInto(mediator); if (data != null) { mediator.SetInitData(data); } mediator.RegisterView(view); return(mediator); }
public virtual void Init(Fsm fsm) { if (Screen == null) { Screen = new TScreen(); Injector.InjectInto(Screen); } Fsm = fsm; RegisterEventHandlers(); }
private void EventHandler <TEvent>(AbstractEvent e) { //TODO event type could be - forced(has to be processed), queued(until there will be right mapping for it), weak(or so - is processed when there is processor) var commandType = _eventToCommandMap[e.GetType()]; var command = (ICommand)Activator.CreateInstance(commandType); if (command == null) { Debug.LogWarningFormat("<color=\"aqua\">" + this + " : MAPPED CLASS FOR {0} IS NOT {1}</color>", e.GetType(), typeof(ICommand)); return; } _injector.MapValue(e, e.GetType()); _injector.InjectInto(command); _injector.Unmap(e); //Debug.LogWarning("<color=\"aqua\">" + this + " Execute: " + command + "</color>"); command.Execute(); }
/// <summary> /// Switches current state for a new one. If fsm is already in some state, new state is queued. /// First the current state is closed (transition out) then new state is opened (transition in). /// </summary> /// <param name="newState">New state to be opened</param> public virtual void SwitchState(IAppState newState) { //Debug.LogWarningFormat("<color=\"aqua\">{0}.SwitchState : {1}</color>", this, newState.GetType()); Injector.InjectInto(newState); if (_currentTransition == TransitionType.None) { if (_currentState == null) { StartState(newState); } else { _nextStates.Enqueue(newState); CloseCurrentState(); } } else { _nextStates.Enqueue(newState); } }
/*============================================================================*/ /* Private Functions */ /*============================================================================*/ private void InjectAndRemember(object view, IInjector injector) { injector.InjectInto(view); _injectedObjects[view] = true; }
public void RunBeforeEachTest() { contextView = new TestContextView(); context = new Robotlegs.Mvcs.Support.TestContext( contextView ); actor = new TestActor(); injector = context.GetInjector(); TestPanel.Children.Add( contextView ); injector.InjectInto( actor ); }
private void ProcessObject(object obj) { _injector.InjectInto(obj); InvokeConfigure(obj); }