I'm probably confused, but what happens when you register 
IDependency/Dependency in the container?  Do you get an error?

-craig

On Jun 15, 2012, at 2:16 AM, Mijo Thomas wrote:

> Hi,
> 
> I'm trying to host my WCF service in a windows service host. For managing 
> dependencies I'm using Castle WCF facility.
> 
> This is how my ContainerConfiguration(BootStrapper) looks like:
> 
>  public class ConfigureContainer : IConfigureContainer
>         {
>             private const string ServiceOne= "ServiceOne";
>             private const string ServiceTwo      = "ServiceTwo";
>             private const string ServiceThree = "ServiceThree";
>             private const string CurrentAssembly      = "MyAssembly";
> 
>             private readonly IWindsorContainer container;
> 
>             public ConfigureContainer(IWindsorContainer container)
>             {
>                 this.container = container;
>             }
> 
> 
>             public IWindsorContainer WindsorContainer { get { return 
> container; } }
> 
> 
>             public void AndRegisterComponents()
>             {
>                 container.Register(AllTypes.FromAssemblyNamed(CurrentAssembly)
>                        .Pick().If(type => type.GetInterfaces().Any(i => 
> i.IsDefined(typeof(ServiceContractAttribute), true)))
>                        .Configure(configurer => configurer
>                                                     
> .Named(configurer.Implementation.Name)
>                                                     .AsWcfService(
>                                                         new 
> DefaultServiceModel()
>                                                             .AddEndpoints(
>                                                                 
> WcfEndpoint.FromConfiguration(ServiceOne),
>                                                                 
> WcfEndpoint.FromConfiguration(ServiceTwo),
>                                                                 
> WcfEndpoint.FromConfiguration(ServiceThree))
>                                                                 
> .PublishMetadata()))
>                        .WithService.Select((type, baseTypes) => 
> type.GetInterfaces()
>                            .Where(i => 
> i.IsDefined(typeof(ServiceContractAttribute), true))));
> 
>             }
>         }
> 
> This is how I do my hosting inside the service host:
> partial class DataServicesHost : ServiceBase { private IWindsorContainer 
> windsorContainer; public DataServicesHost() { InitializeComponent(); }
> 
>         protected override void OnStart(string[] args)
>         {
>             var configure = new ConfigureContainer();
>             windsorContainer = configure.WindsorContainer;
>         }
> 
>         protected override void OnStop()
>         {
>            if(windsorContainer != null)
>            {
>              windsorContainer.Dispose();
>              windsorContainer = null;
>            }
>         }
>     }
> My ServiceOne is implemented as follows:
> 
> [ServiceContract]
>     internal interface IServiceOne
>     {
>         [OperationContract]
>         void DoSomething();
>     }
> 
>     public class ServiceOne : IServiceOne
>     {
>         private readonly IDependency dependency;
> 
>         public ServiceOne(IDependency dependency)
>         {
>             this.dependency = dependency;
>         }
> 
>         public void DoSomething()
>         {
>             dependency.GetSomething();
>             //do something
>         }
>     }
> 
>     public interface IDependency
>     {
>         void GetSomething();
>     }
> 
>     public class Dependency : IDependency
>     {
>         public void GetSomething()
>         {
>             //GetSomeThing
>         }
> }
> Now my question is: how do I pass the IDependency to the container? How will 
> I configure it so that while hosting it, it does't complain about not letting 
> the host know of the dependency and keeps looking and failing over the 
> default constructor implementation?
> 
> Thanks, -Mike
> 
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Castle Project Users" group.
> To view this discussion on the web visit 
> https://groups.google.com/d/msg/castle-project-users/-/oNA0FXNBI-sJ.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/castle-project-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en.

Reply via email to