protected Context(IContextView contextView, Context[] subContexts, bool autoRegisterExports = true) : this(contextView) { if(autoRegisterExports) { RegisterExports(); } RegisterSubContexts(subContexts); }
/*============================================================================*/ /* Private Functions */ /*============================================================================*/ private void HandleContextView(object contextView) { if (_contextView != null) { return; } IContextView castContextView = contextView as IContextView; if (castContextView == null) { return; } _contextView = castContextView; if (_injector.HasDirectMapping(typeof(IViewStateWatcher))) { return; } IViewStateWatcher viewStateWatcher = GetViewStateWatcher(_contextView.view); if (viewStateWatcher == null) { _logger.Warn("Unable to create View State Watcher."); return; } _injector.Map(typeof(IViewStateWatcher)).ToValue(viewStateWatcher); }
public Component AddComponent(Injector activeInjector, Type componentType) { if (parentObject == null) { if (activeInjector.HasMapping(typeof(IContextView))) { IContextView contextViewObj = (IContextView)activeInjector.GetInstance(typeof(IContextView)); object contextView = contextViewObj.view; if (contextView != null) { if (contextView is Transform) { parentObject = (Transform)contextView; } else if (contextView is GameObject) { parentObject = ((GameObject)contextView).transform; } } } } if (parentObject == null) { destroyGameObjectWhenComplete = true; parentObject = new GameObject("Unity Component Provider").transform; } component = parentObject.gameObject.AddComponent(componentType); return(component); }
/*============================================================================*/ /* Private Functions */ /*============================================================================*/ private void HandleContextView(object contextView) { if (_contextView != null) { return; } IContextView castContextView = contextView as IContextView; if (castContextView == null) { return; } _contextView = castContextView; if (_contextViewStateWatcher != null) { _logger.Warn("A IViewStateWatcher on the context view has already been set"); return; } if (!_context.injector.HasDirectMapping(typeof(IViewStateWatcher))) { _logger.Info("No ViewStateWatcherExtension has been found yet. We will check again at the end of the contextview Configuration"); _context.AddConfigHandler(new InstanceOfMatcher(typeof(IContextView)), HandleViewStateWatcher); return; } else { HandleViewStateWatcher(_context.injector.GetInstance(typeof(IViewStateWatcher))); } }
/*============================================================================*/ /* Private Functions */ /*============================================================================*/ private void HandleContextView(object contextView) { if (_contextView != null) return; IContextView castContextView = contextView as IContextView; if (castContextView == null) return; _contextView = castContextView; if (_contextViewStateWatcher != null) { _logger.Warn ("A IViewStateWatcher on the context view has already been set"); return; } if (!_context.injector.HasDirectMapping (typeof(IViewStateWatcher))) { _logger.Info ("No ViewStateWatcherExtension has been found yet. We will check again at the end of the contextview Configuration"); _context.AddConfigHandler (new InstanceOfMatcher (typeof(IContextView)), HandleViewStateWatcher); return; } else { HandleViewStateWatcher(_context.injector.GetInstance (typeof(IViewStateWatcher))); } }
/*============================================================================*/ /* Private Functions */ /*============================================================================*/ private void HandleContextView(object contextViewObject) { IContextView contextView = contextViewObject as IContextView; _contextView = contextView.view; if (!_injector.HasDirectMapping(typeof(IViewStateWatcher))) { _logger.Error("No IViewStateWatcher installed prior to Modularity Extension. The Modularity extension requires IViewStateWatcher to be installed first"); return; } _contextViewStateWatcher = _injector.GetInstance(typeof(IViewStateWatcher)) as IViewStateWatcher; if (!_injector.HasDirectMapping(typeof(IParentFinder))) { _logger.Error("No IParentFinder Installed. The Modularity extension required this"); return; } _parentFinder = _injector.GetInstance(typeof(IParentFinder)) as IParentFinder; if (_expose) { ConfigureExistenceWatcher(); } if (_inherit) { ConfigureExistenceBroadcaster(); } }
protected Context(IContextView contextView, Context[] subContexts, bool autoRegisterExports = true) : this(contextView) { if (autoRegisterExports) { RegisterExports(); } RegisterSubContexts(subContexts); }
private void ScanContextView() { _logger.Debug("ViewManager is not installed. Checking the ContextView..."); IContextView contextView = _injector.GetInstance(typeof(IContextView)) as IContextView; // TODO: Matt How to check if the contextView is on the stage?? Use a View watcher? //contextView.view.stage && ScanContainer(contextView.view); ScanContainer(contextView.view); }
/*============================================================================*/ /* Private Functions */ /*============================================================================*/ private void BeforeInitializing() { if (_injector.HasDirectMapping(typeof(IContextView))) { IContextView contextView = _injector.GetInstance(typeof(IContextView)) as IContextView; unitySingletons = (contextView.view as Transform).gameObject.AddComponent <UnitySingletons>(); unitySingletons.SetFactory(_singletonFactory); } }
private IEnumerator WaitForReady(IContextView contextView) { var concreteContextView = contextView as ContextView; var counter = 0f; while(concreteContextView == null || !concreteContextView.IsReady) { counter += Time.deltaTime; if(counter > 10f) { break; } yield return null; } }
public void icontextView_is_mapped() { IContextView actual = null; context.Install <ContextViewExtension>().Configure(new ContextView(view)); context.WhenInitializing((Action) delegate() { actual = context.injector.GetInstance <IContextView>(); }); context.Initialize(); Assert.That(actual.view, Is.EqualTo(view)); }
public MainContext(IContextView contextView, string sceneName) : base(contextView) { this.sceneName = sceneName; ContextConfiguration.Default.Configure(container); container.Register<IMainContextView>(contextView as IMainContextView); RegisterExports(); try { container.Resolve<IMainContextConfiguration>().Configure(container); } catch { // Do nothing. } }
public void second_view_container_is_ignored() { IContextView actual = null; SupportView secondView = new SupportView(); context.Install <ContextViewExtension>().Configure(new ContextView(view), new ContextView(secondView)); context.WhenInitializing((Action) delegate() { actual = context.injector.GetInstance <IContextView>(); }); context.Initialize(); Assert.That(actual.view, Is.EqualTo(view)); }
public MainContext(IContextView contextView, string sceneName) : base(contextView) { this.sceneName = sceneName; ContextConfiguration.Default.Configure(container); container.Register <IMainContextView>(contextView as IMainContextView); RegisterExports(); try { container.Resolve <IMainContextConfiguration>().Configure(container); } catch { // Do nothing. } }
/*============================================================================*/ /* Private Functions */ /*============================================================================*/ private void AddContextView(object contextViewObject) { IContextView contextView = contextViewObject as IContextView; if (!HasContextBinding()) { _logger.Debug("Mapping {0} as contextView", contextView.view); _injector.Map(typeof(IContextView)).ToValue(contextView); } else { _logger.Warn("A contextView has already been installed, ignoring {0}", contextView.view); } }
private IEnumerator WaitForReady(IContextView contextView) { var concreteContextView = contextView as ContextView; var counter = 0f; while (concreteContextView == null || !concreteContextView.IsReady) { counter += Time.deltaTime; if (counter > 10f) { break; } yield return(null); } }
private IEnumerator DoLoadSceneForContext(IObserver <IContext> observer, string sceneName) { yield return(Application.LoadLevelAdditiveAsync(sceneName)); IContextView contextView = null; while (contextView == null) { var gameObject = GameObject.Find("_" + sceneName + "ContextView"); if (gameObject != null) { contextView = gameObject.GetComponent(typeof(IContextView)) as IContextView; } yield return(null); } observer.OnNext(contextView.Context); observer.OnCompleted(); }
/*============================================================================*/ /* Private Functions */ /*============================================================================*/ private void HandleContextView(object contextView) { if (_contextView != null) return; IContextView castContextView = contextView as IContextView; if (castContextView == null) return; _contextView = castContextView; if (_injector.HasDirectMapping (typeof(IViewStateWatcher))) return; IViewStateWatcher viewStateWatcher = GetViewStateWatcher(_contextView.view); if (viewStateWatcher == null) { _logger.Warn ("Unable to create View State Watcher."); return; } _injector.Map(typeof(IViewStateWatcher)).ToValue(viewStateWatcher); }
/*============================================================================*/ /* Private Functions */ /*============================================================================*/ private void AddContextView(object contextViewObject) { IContextView contextView = contextViewObject as IContextView; if (!(contextView.view is UnityEngine.Transform)) { _logger.Warn("Cannot map {0} as Transform for the ContextViewTransformExtension to work. Try to configure with 'new TransformContextView(transform)'", contextView.view); return; } if (_injector.HasDirectMapping(typeof(UnityEngine.Transform))) { _logger.Warn("A Transform has already been mapped, ignoring {0}", contextView.view); return; } _logger.Debug("Mapping {0} as Transform", contextView.view); _injector.Map(typeof(UnityEngine.Transform)).ToValue(contextView.view); }
protected override void postBindings() { //It's possible for views to fire their Awake before bindings. This catches any early risers and attaches their Mediators. mediateViewCache(); //Ensure that all Views underneath the ContextView are triggered #region ido's modifications //This is a Strange bug (pun intended) - why assume the root has a component of type ContextView? maybe //it's some other "animal" that implements the IView interface? after all, Trigger requires IView, not //ContextView, and in our case that is indeed the case - our StrangeRoot object inherits from TaskManager, //and implements all IView interfaces. I'm guessing the Strange guy didn't know how to get, by reflection, //an implementor of IView, rather than an instance of ContextView, so I've chamged it. //Don't forget to add using System.Linq if using this... //mediationBinder.Trigger(MediationEvent.AWAKE, (contextView as GameObject).GetComponent<ContextView>()); IContextView viewImplemetor = (contextView as GameObject).GetComponentsInChildren <Component>() .Where(c => c == null ? false : c.GetType().GetInterfaces() .Contains(typeof(IContextView))).Cast <IContextView>().FirstOrDefault(); mediationBinder.Trigger(MediationEvent.AWAKE, viewImplemetor); #endregion }
protected Context(IContextView contextView) : this() { container.Register <IContextView>(contextView); }
protected Context(IContextView contextView) : this() { container.Register<IContextView>(contextView); }
public ContextScheduler(IContextView contextView) { this.contextDispatcher = contextView.GameObject.AddComponent <ContextDispatcher>(); }
public ContextScheduler(IContextView contextView) { this.contextDispatcher = contextView.GameObject.AddComponent<ContextDispatcher>(); }