Пример #1
0
        private void Bind(ImplicitBindingVO toBind)
        {
            //We do not check for the existence of a binding. Because implicit bindings are weak bindings, they are overridden automatically by other implicit bindings
            //Therefore, ImplementedBy will be overriden by an Implements to that interface.

            IInjectionBinding binding = injectionBinder.Bind(toBind.BindTypes.First());

            binding.Weak();            //SDM2014-0120: added as part of cross-context implicit binding fix (moved from below)

            for (int i = 1; i < toBind.BindTypes.Count; i++)
            {
                Type bindType = toBind.BindTypes.ElementAt(i);
                binding.Bind(bindType);
            }

            binding = toBind.ToType != null?
                      binding.To(toBind.ToType).ToName(toBind.Name).ToSingleton() :
                          binding.ToName(toBind.Name).ToSingleton();

            if (toBind.IsCrossContext)             //Bind this to the cross context injector
            {
                binding.CrossContext();
            }

            //binding.Weak();//SDM2014-0120: removed as part of cross-context implicit binding fix (moved up higher)
        }
Пример #2
0
 public void ByWayOf <T>() where T : P
 {
     _binding.To <T>().ToSingleton().CrossContext();
 }