Wrox Programmer Forums
|
BOOK: Professional Test Driven Development with C#: Developing Real World Applications with TDD
This is the forum to discuss the Wrox book Professional Test Driven Development with C#: Developing Real World Applications with TDD by James Bender, Jeff McWherter; ISBN: 978-0-470-64320-4
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional Test Driven Development with C#: Developing Real World Applications with TDD section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 23rd, 2014, 11:12 AM
Registered User
 
Join Date: Jul 2014
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 11 WPF example doesn't use Ninject

Just wondering why the code contains Ninject Modules but does not actual use them. This is frustrating for me when trying to use this as a base for my own project.

Is there a good example of Caliburn.Micro being used with Ninject?

Thanks.
 
Old July 24th, 2014, 03:45 AM
Registered User
 
Join Date: Jul 2014
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

If anyone is interested, I managed to get it working with the following bootstrapper:

Caliburn.Micro v2.0.0.6
Ninject v3.2.0.0

Code:
    public class AppBootstrapper : BootstrapperBase
    {
        private IKernel kernel;

        public AppBootstrapper()
        {
            Initialize();
        }

        protected override void OnStartup(object sender, StartupEventArgs e)
        {
            DisplayRootViewFor<IShellViewModel>();
        }

        protected override void Configure()
        {
            kernel = new StandardKernel();

            kernel.Bind<IWindowManager>().To<WindowManager>().InSingletonScope();
            kernel.Bind<IEventAggregator>().To<EventAggregator>().InSingletonScope();

            kernel.Bind<IShellViewModel>().To<ShellViewModel>().InSingletonScope();
        }

        protected override void OnExit(object sender, EventArgs e)
        {
            kernel.Dispose();
            base.OnExit(sender, e);
        }

        protected override object GetInstance(Type service, string key)
        {
            if (service == null)
                throw new ArgumentNullException("service");

            return kernel.Get(service);
        }

        protected override IEnumerable<object> GetAllInstances(Type service)
        {
            return kernel.GetAll(service);
        }

        protected override void BuildUp(object instance)
        {
            kernel.Inject(instance);
        }
    }





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 18 WPF Toolkit and Silverlight SDK Problems vikingdriver BOOK: Professional Visual Studio 2010 0 May 10th, 2012 12:50 PM
Error with Chapter 2 Src code for WPF that uses Lists.asmx treycarroll BOOK: Beginning SharePoint 2010 Development 4 April 28th, 2011 02:47 AM
WPF basics Chapter 6 mhccStudent BOOK: Beginning Microsoft Visual Basic 2008 ISBN: 978-0-470-19134-7 8 May 12th, 2010 07:37 AM
Chapter 7 - WPF Text Editor - pg 236 Crissytenav BOOK: Beginning Microsoft Visual Basic 2008 ISBN: 978-0-470-19134-7 2 April 14th, 2010 10:38 AM
chapter 11 figure 11-7 relative positioning pelopito BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3 2 November 29th, 2007 06:11 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.