Cleaner WCF Facility registration

327 vues
Passer au premier message non lu

Mark Seemann

non lue,
12 févr. 2010, 11 h 04 min 28 s2010-02-12
à Castle Project Users
As far as I understand the Windsor WCF Facility, it requires me to
invoke the static WindsorServiceHostFactory.RegisterContainer method
from within Application_Start in a Global.asax(.cs?) file. I'm
referring to this documentation: http://www.castleproject.org/container/facilities/trunk/wcf/index.html

I find this... not as nice as it could be.

It smells of ASP.NET, of which I'm not a particularly big fan, but it
also makes me uneasy because I've never seen the combination of
Global.asax and WCF before. Does it require me to turn on ASP.NET
Compatibility mode before it will work?

This may simply be a severe case of FUD on my part, but I would
appreciate a cleaner API.

May I suggest something like this:

public abstract class WindsorServiceHostFactory : ServiceHostFactory
{
// ... other members

protected abstract IWindsorContainer CreateContainer();
}

This is basically just a ServiceHostFactory with a Template Method.
All I would need to do to wire up my own service would be to derive
from this class and implement the CreateContainer method. Registering
this derived ServiceHostFactory in my .svc file would enable Windsor
to wire up my service.

This approach requires me to edit/create the same number of files (2)
as the current approach, but has the added benefit that it will also
work outside of IIS, since I could simply use the derived
ServiceHostFactory directly to spin up a new service.

Craig Neuwirt

non lue,
12 févr. 2010, 11 h 10 min 19 s2010-02-12
à castle-pro...@googlegroups.com
Sorry, docs are out of date (in process of being updated).  You don't need to do anything besides register facility


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


Répondre à tous
Répondre à l'auteur
Transférer
0 nouveau message