Skip to content

Instantly share code, notes, and snippets.

@serdarb
Created December 20, 2011 19:58
Show Gist options
  • Save serdarb/1503001 to your computer and use it in GitHub Desktop.
Save serdarb/1503001 to your computer and use it in GitHub Desktop.
Bootstrapper
public class Bootstrapper
{
public static IWindsorContainer Container { get; private set; }
public static void Initialize()
{
Container = new WindsorContainer();
Container.AddFacility<WcfFacility>();
Container.Register(
AllTypes.FromAssemblyNamed("DogmaticWcf.Server.Services")
.Pick().If(type => type.GetInterfaces().Any(i => i.IsDefined(typeof(ServiceContractAttribute), true)))
.Configure(configurer => configurer
.Named(configurer.Implementation.Name)
.LifeStyle.PerWcfOperation()
.AsWcfService(
new DefaultServiceModel()
.AddEndpoints(
WcfEndpoint.BoundTo(new NetTcpBinding { PortSharingEnabled = true }).At(string.Format("net.tcp://localhost:6969/{0}", configurer.Implementation.Name)),
WcfEndpoint.BoundTo(new NetNamedPipeBinding()).At(string.Format("net.pipe://localhost/{0}", configurer.Implementation.Name)))
.PublishMetadata()
)
)
.WithService.Select(
(type, baseTypes) => type.GetInterfaces().Where(i => i.IsDefined(typeof(ServiceContractAttribute), true)).Select(x => x as Type)
)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment