Skip to content

Commit

Permalink
-Removed superfulous checks
Browse files Browse the repository at this point in the history
-Used explicit namespaces when registering views
  • Loading branch information
HEskandari committed Jul 24, 2010
1 parent 981d274 commit 6340bbd
Show file tree
Hide file tree
Showing 10 changed files with 109 additions and 87 deletions.
4 changes: 2 additions & 2 deletions .gitignore
@@ -1,5 +1,5 @@
bin [Bb]in
obj [Oo]bj
_ReSharper.* _ReSharper.*
*.csproj.user *.csproj.user
*.resharper *.resharper
Expand Down
150 changes: 88 additions & 62 deletions Silverlight/Windsor.SLExample.5.0.ReSharper.user

Large diffs are not rendered by default.

@@ -1,10 +1,14 @@
using System;
using Castle.Core; using Castle.Core;
using Castle.Windsor; using Castle.Windsor;
using Windsor.SLExample.Model; using Windsor.SLExample.Model;


namespace Windsor.SLExample.Services.Impl namespace Windsor.SLExample.Factories
{ {
public interface ICustomerFactory
{
Customer Create(string firstname, string lastname);
}

[Singleton] [Singleton]
public class CustomerFactory : ICustomerFactory public class CustomerFactory : ICustomerFactory
{ {
Expand Down
3 changes: 1 addition & 2 deletions Silverlight/Windsor.SLExample/Installers/ModelInstaller.cs
Expand Up @@ -15,8 +15,7 @@ public void Install(IWindsorContainer container, IConfigurationStore store)
.Where(t => t.Namespace.EndsWith("Model")) .Where(t => t.Namespace.EndsWith("Model"))
.Configure(c => c.LifeStyle.Transient .Configure(c => c.LifeStyle.Transient
.Proxy.AdditionalInterfaces(typeof(IEditableObject), typeof(INotifyPropertyChanged)) .Proxy.AdditionalInterfaces(typeof(IEditableObject), typeof(INotifyPropertyChanged))
.Interceptors(typeof(EditableBehavior), typeof(NotifyPropertyChangedBehavior)) .Interceptors(typeof(EditableBehavior), typeof(NotifyPropertyChangedBehavior))));
));
} }
} }
} }
Expand Up @@ -3,6 +3,7 @@
using Castle.Windsor; using Castle.Windsor;
using Microsoft.Practices.ServiceLocation; using Microsoft.Practices.ServiceLocation;
using Windsor.SLExample.Container; using Windsor.SLExample.Container;
using Windsor.SLExample.Factories;
using Windsor.SLExample.Services; using Windsor.SLExample.Services;
using Windsor.SLExample.Services.Impl; using Windsor.SLExample.Services.Impl;


Expand Down
10 changes: 3 additions & 7 deletions Silverlight/Windsor.SLExample/Installers/ViewInstaller.cs
@@ -1,3 +1,4 @@
using Castle.Facilities.FactorySupport;
using Castle.MicroKernel.Registration; using Castle.MicroKernel.Registration;
using Castle.MicroKernel.SubSystems.Configuration; using Castle.MicroKernel.SubSystems.Configuration;
using Castle.Windsor; using Castle.Windsor;
Expand All @@ -8,14 +9,9 @@ public class ViewInstaller : IWindsorInstaller
{ {
public void Install(IWindsorContainer container, IConfigurationStore store) public void Install(IWindsorContainer container, IConfigurationStore store)
{ {
//Register all types and filter by predicate //Register all types and filter by namespace

container.Register(AllTypes.FromThisAssembly() container.Register(AllTypes.FromThisAssembly()
.Where(t => t.Namespace != null && .Where(Component.IsInNamespace("Windsor.SLExample.Views")));
t.Namespace.EndsWith("Views") &&
t.IsClass &&
t.IsInterface == false &&
t.IsAbstract == false));
} }
} }
} }
9 changes: 0 additions & 9 deletions Silverlight/Windsor.SLExample/Services/ICustomerFactory.cs

This file was deleted.

@@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Windsor.SLExample.Factories;
using Windsor.SLExample.Model; using Windsor.SLExample.Model;
using System.Linq; using System.Linq;


Expand Down
7 changes: 6 additions & 1 deletion Silverlight/Windsor.SLExample/Startup/GuyWire.cs
Expand Up @@ -7,10 +7,15 @@ public class GuyWire
{ {
private IWindsorContainer _container; private IWindsorContainer _container;


public GuyWire() : this(new WindsorContainer()) public GuyWire() : this(CreateContainer())
{ {
} }


private static IWindsorContainer CreateContainer()
{
return new WindsorContainer();
}

public GuyWire(IWindsorContainer container) public GuyWire(IWindsorContainer container)
{ {
_container = container; _container = container;
Expand Down
3 changes: 1 addition & 2 deletions Silverlight/Windsor.SLExample/Windsor.SLExample.csproj
Expand Up @@ -95,9 +95,8 @@
<Compile Include="Interceptors\NotifyPropertyChangedBehavior.cs" /> <Compile Include="Interceptors\NotifyPropertyChangedBehavior.cs" />
<Compile Include="Model\Customer.cs" /> <Compile Include="Model\Customer.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Services\ICustomerFactory.cs" /> <Compile Include="Factories\CustomerFactory.cs" />
<Compile Include="Services\ICustomerRepository.cs" /> <Compile Include="Services\ICustomerRepository.cs" />
<Compile Include="Services\Impl\CustomerFactory.cs" />
<Compile Include="Services\Impl\CustomerRepository.cs" /> <Compile Include="Services\Impl\CustomerRepository.cs" />
<Compile Include="Services\IRepository.cs" /> <Compile Include="Services\IRepository.cs" />
<Compile Include="Startup\GuyWire.cs" /> <Compile Include="Startup\GuyWire.cs" />
Expand Down

0 comments on commit 6340bbd

Please sign in to comment.