Example #1
0
        protected void InstallConfiguration(C configuration)
        {
            foreach (var binding in configuration)
            {
                var bindingTo = binding.viewInterfaceType != null
                                    ? MediationBinder.Rebind(binding.viewType, binding.viewInterfaceType)
                                    : MediationBinder.Rebind(binding.viewType);

                if (binding.mediatorType != null)
                {
                    bindingTo.To(binding.mediatorType);
                }
            }

            _installedConfigs.Add(configuration);
        }
Example #2
0
        private void OpenPopup(PopupBase popup, object data)
        {
            _openPopups.Add(popup);

            IInjectionBinding dataBinding = null;

            if (popup.dataType != null)
            {
                dataBinding = InjectionBinder.Bind(popup.dataType).ToValue(data).ToBinding();
            }

            var instance = GetInstance(popup, UIControlOptions.Instantiate);

            var view = instance.GetComponent <PopupView>() ?? (IPopupView)instance.GetComponent <PopupViewDispatcher>();

            if (view == null)
            {
                throw new Exception("Popup view doesn't inherit from PopupView or PopupViewDispatcher.");
            }

            view.SetUp(popup);

            if (view.Initialized)
            {
                MediationBinder.UpdateViewInjections(view);
            }

            view.GameObject.SetActive(true);

            if (dataBinding != null)
            {
                InjectionBinder.Unbind(dataBinding);
            }

            Dispatcher.Dispatch(PopupEvent.Open, popup);
        }