Ejemplo n.º 1
0
 /// <summary>
 /// Adds a service to the provider, and adds a binding to the Kernel, allowing the service to be part of the dependency
 /// injection machanism.
 /// </summary>
 /// <param name="contractType">Service's contract type.</param>
 /// <param name="service">Service implementation (must support contract's type)</param>
 public override void RegisterService(Type contractType, IService service)
 {
     base.RegisterService(contractType, service);
     
     //Create a special binding for services
     IBinding binding;
     binding = new StandardBinding(Kernel, contractType);
     binding.Provider = new ServiceProvider(contractType, service);
     Kernel.AddBinding(binding);
 }
Ejemplo n.º 2
0
        private static IBinding ResolveViewModel(Type type, IContext context)
        {
            if( type.Name.Equals("ViewModel"))
            {
                var proxy = Weaver.GetProxyType(type);
                var binding = new StandardBinding(Kernel, type);

                var provider = new StandardProvider(proxy);
                binding.Provider = provider;
                return binding;
            }
            return null;
        }
Ejemplo n.º 3
0
        private IBinding DisplayBindingResolver(IContext context)
        {
            var binding = new StandardBinding(this, typeof(IDisplay));
            IBindingTargetSyntax binder = new StandardBindingBuilder(binding);

            if (null != context.ParentContext &&
                context.ParentContext is DisplayActivationContext)
            {
                var display = ((DisplayActivationContext)context.ParentContext).Display;
                binder.ToConstant(display);
            }

            return binding;
        }