Skip to content

Instantly share code, notes, and snippets.

@rarous
Created July 9, 2013 08:16
Show Gist options
  • Save rarous/5955605 to your computer and use it in GitHub Desktop.
Save rarous/5955605 to your computer and use it in GitHub Desktop.
public static ComponentRegistration<TService> RouteFromName<TService>(this ComponentRegistration<TService> registration)
where TService : class
{
return registration.Route(registration.Name);
}
public static ComponentRegistration<TService> Route<TService>(this ComponentRegistration<TService> registration, string name)
where TService : class
{
var factory = new DefaultServiceHostFactory();
var serviceContract = registration.Implementation.GetInterfaces().First();
var route = new ServiceRoute(name + ".svc", factory, serviceContract);
RouteTable.Routes.Add(name, route);
return registration;
}
static ComponentRegistration<TService> WcfService<TService, TImpl>(string name, Func<DefaultServiceModel, IWcfServiceModel> configServiceModel)
where TService : class
where TImpl : TService
{
return Component.
For<TService>().
ImplementedBy<TImpl>().
Named(name).
RouteFromName().
AsWcfService(configServiceModel(new DefaultServiceModel().Hosted()));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment