Exemplo n.º 1
0
        protected override void mapBindings()
        {
            //Bind some abstract and/or concrete Views


            Debug.LogWarning("mapBindings: " + mediationBinder);

            IMediationBinding binding = mediationBinder.Bind <TesterView> ();

            Debug.LogWarning("binding: " + binding);

            binding = binding.ToAbstraction <ITesterView> ();

            Debug.LogWarning("binding2: " + binding);

            binding = binding.To <BoxCollider2D> ();
        }
Exemplo n.º 2
0
        override protected IBinding ConsumeItem(Dictionary <string, object> item, IBinding testBinding)
        {
            IBinding binding = base.ConsumeItem(item, testBinding);

            foreach (var i in item)
            {
                if (i.Key == "ToAbstraction")
                {
                    Type abstractionType = Type.GetType(i.Value as string);
                    IMediationBinding mediationBinding = (binding as IMediationBinding);
                    if (abstractionType == null)
                    {
                        throw new BinderException("A runtime abstraction in the MediationBinder returned a null Type. " + i.ToString(), BinderExceptionType.RUNTIME_NULL_VALUE);
                    }
                    if (mediationBinding == null)
                    {
                        throw new MediationException("During an attempt at runtime abstraction a MediationBinding could not be found. " + i.ToString(), MediationExceptionType.BINDING_RESOLVED_TO_NULL);
                    }

                    mediationBinding.ToAbstraction(abstractionType);
                }
            }
            return(binding);
        }