Exemple #1
0
 public static IAppConfig UseWcfHost(
     this IAppConfig appConfig, WcfHostParams @params)
 {
     appConfig.AddAppRunnerAfter(() =>
     {
         var logger = appConfig.GetLogger("");
         try
         {
             new WcfHostRunner(@params, logger).Open();
         }
         catch (Exception ex)
         {
             logger.LogDebug(ex.ToString());
         }
     });
     return(appConfig);
 }
        public WcfHostRunner(WcfHostParams @params, ILogger logger)
        {
            this.logger  = logger;
            this.@params = @params;
            hosts        = new List <ServiceHost>();

            foreach (var service in @params.Services)
            {
                var host = new ServiceHost(service.Implementation, new Uri(@params.BaseAddress + service.Name));

                logger.LogDebug($"Starting ServiceHost at {@params.BaseAddress + service.Name}");

                host.Description.Behaviors.Add(service.Behavior ?? DefaultSettings.Behavior());

                var debug = host.Description.Behaviors.OfType <ServiceDebugBehavior>().First();
                debug.IncludeExceptionDetailInFaults = true;

                host.AddServiceEndpoint(service.Interface, service.Binding ?? DefaultSettings.Binding(), "");
                hosts.Add(host);
            }
        }