<https://lh3.googleusercontent.com/-LYp5LamY07g/WqgFhzKcXGI/AAAAAAAANRE/ZGnBCvuQYrguMR8oOnYWfFt-Y3CufxY1ACLcBGAs/s1600/Error.png>


using Castle.Core;
using Castle.Facilities.TypedFactory;
using Castle.MicroKernel.Registration;
using Castle.Windsor;
using LMS.Infrastructure;
using LMS.Infrastructure.Interop.Network;
using MvvmFramework;
using QLMS.ViewModels;
using QLMS.ViewModels.Handlers;
using QLMS.Views.DesignTime;
using QLMS.Views.Infrastructure;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
 
namespace QLMS.Views
{
    public class Bootstrapper : BootstrapperBase
    {
        private WindsorContainer container;
 
        protected override IEnumerable<Assembly> SelectAssemblies()
        {
            return new[] { typeof(MainViewModel).Assembly };
        }
 
        protected override void ConfigureForRunTime()
        {
            container = new WindsorContainer();
            container.Kernel.Resolver.AddSubResolver(new 
AppSettingsConvention());
            container.AddFacility<TypedFactoryFacility>();
            container.Register(
                 Component.For<ICheckInternetConnectivity>()
                .ImplementedBy<CheckInternetConnectivity>(),
                 
                 Component.For<IEventAggregator>()
                .ImplementedBy<EventAggregator>().LifestyleSingleton(),
 
                 //Component.For<ShellViewModel>().LifestyleSingleton(),
 
                Component.For<NotificationsViewModel>().LifestyleSingleton(),
 
                 Classes
                .FromAssembly(typeof(MainViewModel).Assembly)
                .BasedOn(typeof(IHandle<>))
                .Configure(x => x.LifeStyle.Is(LifestyleType.Singleton)),
                //.WithServiceAllInterfaces()
                //.LifestyleSingleton()
                
Classes.FromAssembly(typeof(ViewModel).Assembly).InSameNamespaceAs<ViewModel>().WithServiceDefaultInterfaces()
 
                );
            RegisteViewModels();
            RegisterRoutes();
        }
        protected override void ConfigureForDesignTime()
        {
            container = new WindsorContainer();
            container.Kernel.Resolver.AddSubResolver(new 
AppSettingsConvention());
            
            
            container.Register(
                  Component.For<ICheckInternetConnectivity>()
                .ImplementedBy<DesignTimeCheckInternetConnectivity>(),
 
                Component.For<IEventAggregator>()
                .ImplementedBy<EventAggregator>().LifestyleSingleton(),
 
                //Component.For<ShellViewModel>().LifestyleSingleton(),
 
                 Component.For<NotificationsViewModel>().LifestyleSingleton(),
 
                Classes
                .FromAssembly(typeof(RouteToViewHandler).Assembly)
                .BasedOn(typeof(IHandle<>))
                .Configure(x => x.LifeStyle.Is(LifestyleType.Singleton))
                
//Classes.FromAssembly(typeof(ViewModel).Assembly).InSameNamespaceAs<ViewModel>().WithServiceDefaultInterfaces(),
                //AllTypes.
                );
            RegisteViewModels();
 
            RegisterRoutes();
            container.AddFacility<TypedFactoryFacility>();
        }
        protected override object GetInstance(Type service, string key)
        {
            return string.IsNullOrWhiteSpace(key)
                  ? container.Resolve(service)
                  : container.Resolve(key, service);
        }
        private void RegisteViewModels()
        {
 
 
            
container.Register(Classes.FromAssembly(typeof(ShellViewModel).Assembly)
                .Where(x => x.Name.EndsWith("ViewModel") 
                && !x.Name.Equals(nameof(NotificationsViewModel))
                && !x.Name.Equals(nameof(ShellViewModel))
                )
                //.WithServiceDefaultInterfaces()
                .Configure(x => x.LifeStyle.Is(LifestyleType.Transient)));
 
            
container.Register(Component.For<ShellViewModel>().LifestyleSingleton());
        }
 
        private void RegisterRoutes()
        {
            var routes = container.ResolveAll(typeof(IHandle));
            var aggregator = container.Resolve<IEventAggregator>();
            foreach (var route in routes)
            {
                aggregator.Subscribe(route);
            }
 
        }
 
    }
}



My ViewModels are located in different Assemblies with the respective 
handlers unfortunate the dependencies are throwing an error that I can seem 
to resolve when I debug it the references are resolved but the window keeps 
showing up blank.

I have limited knowledge on using this IOC however I would love it if I can 
be assisted in resolving the issue by looking over my code and help me see 
what I have done or not?






-- 
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to castle-project-users+unsubscr...@googlegroups.com.
To post to this group, send email to castle-project-users@googlegroups.com.
Visit this group at https://groups.google.com/group/castle-project-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to