Created
December 17, 2012 20:42
-
-
Save anonymous/4322027 to your computer and use it in GitHub Desktop.
ServiceHostFactory
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class ServiceHostFactory : ServiceHostFactoryBase | |
| { | |
| private static readonly ProxyGenerator Generator = new ProxyGenerator(); | |
| public override ServiceHostBase CreateServiceHost(string constructorString, Uri[] baseAddresses) | |
| { | |
| return this.CreateServiceHost(Type.GetType(constructorString), baseAddresses); | |
| } | |
| protected virtual ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses) | |
| { | |
| ServiceHost host = new ServiceHost(this.CreateService(), baseAddresses); | |
| host.Description.Behaviors.Find<ServiceBehaviorAttribute>().InstanceContextMode = InstanceContextMode.Single; | |
| host.AddServiceEndpoint(typeof(IServicioWeb), new BasicHttpBinding(), string.Empty); | |
| return host; | |
| } | |
| private ServicioWeb CreateService() | |
| { | |
| return Generator.CreateClassProxy<ServicioWeb>(this.CreateLogInterceptor()); | |
| } | |
| private IInterceptor CreateLogInterceptor() | |
| { | |
| return new ErrorLoggingInterceptor(); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <%@ ServiceHost | |
| Language="C#" | |
| Debug="true" | |
| CodeBehind="ServicioWeb.cs" | |
| Factory="EjemploAOPCastleWCF.ServiceHostFactory" %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment