public void Configure( ContainerBuilder builder, BootstrapConventions conventions, IEnumerable<Assembly> assemblies )
		{
			var types = assemblies.SelectMany( a => a.GetTypes() ).ToArray();

			types.Where( t => conventions.IsViewModel( t ) && !conventions.IsExcluded( t ) )
				.Select( t => new
				{
					Contracts = conventions.SelectViewModelContracts( t ),
					Implementation = t
				} )
				.ForEach( r =>
				{
					if ( conventions.IsShellViewModel( r.Contracts, r.Implementation ) )
					{
						builder.RegisterType( r.Implementation ).As( r.Contracts.ToArray() ).SingleInstance();
					}
					else
					{
						builder.RegisterType( r.Implementation ).As( r.Contracts.ToArray() ).InstancePerDependency();
					}
				} );

			types.Where( t => conventions.IsView( t ) && !conventions.IsExcluded( t ) )
				.Select( t => new
				{
					Contracts = conventions.SelectViewContracts( t ),
					Implementation = t
				} )
				.ForEach( r =>
				{
					if ( conventions.IsShellView( r.Contracts, r.Implementation ) )
					{
						builder.RegisterType( r.Implementation ).As( r.Contracts.ToArray() ).SingleInstance();
					}
					else
					{
						builder.RegisterType( r.Implementation ).As( r.Contracts.ToArray() ).InstancePerDependency();
					}
				} );
		}
		public void Install( IUnityContainer container, BootstrapConventions conventions, IEnumerable<Type> allTypes )
		{
			allTypes
				.Where( t => conventions.IsViewModel( t ) && !conventions.IsExcluded( t ) )
				.Select( type => new
				{
					TypeFrom = conventions.SelectViewModelContracts( type ).Single(),
					TypeTo = type
				} )
				.ForEach( r =>
				{
					if ( conventions.IsShellViewModel( new[] { r.TypeFrom }, r.TypeTo ) )
					{
						container.RegisterType( r.TypeFrom, r.TypeTo, new ContainerControlledLifetimeManager(), new CandidateConstructorSelector( container ) );
					}
					else
					{
						container.RegisterType( r.TypeFrom, r.TypeTo, new TransientLifetimeManager(), new CandidateConstructorSelector( container ) );
					}
				} );

			allTypes
				.Where( t => conventions.IsView( t ) && !conventions.IsExcluded( t ) )
				.Select( type => new
				{
					TypeFrom = conventions.SelectViewContracts( type ).Single(),
					TypeTo = type
				} )
				.ForEach( r =>
				{
					if ( conventions.IsShellView( new[] { r.TypeFrom }, r.TypeTo ) )
					{
						container.RegisterType( r.TypeFrom, r.TypeTo, new ContainerControlledLifetimeManager(), new CandidateConstructorSelector( container ) );
					}
					else
					{
						container.RegisterType( r.TypeFrom, r.TypeTo, new TransientLifetimeManager(), new CandidateConstructorSelector( container ) );
					}
				} );
		}
Exemple #3
0
        public void Install(IUnityContainer container, BootstrapConventions conventions, IEnumerable <Type> allTypes)
        {
            allTypes
            .Where(t => conventions.IsViewModel(t) && !conventions.IsExcluded(t))
            .Select(type => new
            {
                TypeFrom = conventions.SelectViewModelContracts(type).Single(),
                TypeTo   = type
            })
            .ForEach(r =>
            {
                if (conventions.IsShellViewModel(new[] { r.TypeFrom }, r.TypeTo))
                {
                    container.RegisterType(r.TypeFrom, r.TypeTo, new ContainerControlledLifetimeManager(), new CandidateConstructorSelector(container));
                }
                else
                {
                    container.RegisterType(r.TypeFrom, r.TypeTo, new TransientLifetimeManager(), new CandidateConstructorSelector(container));
                }
            });

            allTypes
            .Where(t => conventions.IsView(t) && !conventions.IsExcluded(t))
            .Select(type => new
            {
                TypeFrom = conventions.SelectViewContracts(type).Single(),
                TypeTo   = type
            })
            .ForEach(r =>
            {
                if (conventions.IsShellView(new[] { r.TypeFrom }, r.TypeTo))
                {
                    container.RegisterType(r.TypeFrom, r.TypeTo, new ContainerControlledLifetimeManager(), new CandidateConstructorSelector(container));
                }
                else
                {
                    container.RegisterType(r.TypeFrom, r.TypeTo, new TransientLifetimeManager(), new CandidateConstructorSelector(container));
                }
            });
        }
        public void Configure(ContainerBuilder builder, BootstrapConventions conventions, IEnumerable <Assembly> assemblies)
        {
            var types = assemblies.SelectMany(a => a.GetTypes()).ToArray();

            types.Where(t => conventions.IsViewModel(t) && !conventions.IsExcluded(t))
            .Select(t => new
            {
                Contracts      = conventions.SelectViewModelContracts(t),
                Implementation = t
            })
            .ForEach(r =>
            {
                if (conventions.IsShellViewModel(r.Contracts, r.Implementation))
                {
                    builder.RegisterType(r.Implementation).As(r.Contracts.ToArray()).SingleInstance();
                }
                else
                {
                    builder.RegisterType(r.Implementation).As(r.Contracts.ToArray()).InstancePerDependency();
                }
            });

            types.Where(t => conventions.IsView(t) && !conventions.IsExcluded(t))
            .Select(t => new
            {
                Contracts      = conventions.SelectViewContracts(t),
                Implementation = t
            })
            .ForEach(r =>
            {
                if (conventions.IsShellView(r.Contracts, r.Implementation))
                {
                    builder.RegisterType(r.Implementation).As(r.Contracts.ToArray()).SingleInstance();
                }
                else
                {
                    builder.RegisterType(r.Implementation).As(r.Contracts.ToArray()).InstancePerDependency();
                }
            });
        }