LCOV - code coverage report
Current view: top level - Cqrs.Ninject.ServiceHost - NinjectWcfServiceHostFactory.cs Hit Total Coverage
Test: doc-coverage.info Lines: 0 2 0.0 %
Date: 2017-07-26

          Line data    Source code
       1             : using System;
       2             : using System.Runtime.Serialization;
       3             : using System.ServiceModel.Description;
       4             : using Cqrs.Services;
       5             : using Ninject.Extensions.Wcf;
       6             : 
       7             : namespace Cqrs.Ninject.ServiceHost
       8             : {
       9             :         public class NinjectWcfServiceHostFactory<TServiceType> : NinjectServiceHostFactory
      10           0 :         {
      11           0 :                 protected override System.ServiceModel.ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses)
      12             :                 {
      13             :                         System.ServiceModel.ServiceHost host = base.CreateServiceHost(serviceType, baseAddresses);
      14             : 
      15             :                         foreach (ServiceEndpoint serviceEndpoint in host.Description.Endpoints)
      16             :                         {
      17             :                                 foreach (OperationDescription operationDescription in serviceEndpoint.Contract.Operations)
      18             :                                 {
      19             :                                         Type dataContractType = WcfDataContractResolverConfiguration.Current.GetDataContracts<TServiceType>(operationDescription.Name);
      20             :                                         if (dataContractType == null)
      21             :                                                 continue;
      22             :                                         DataContractSerializerOperationBehavior serializerBehavior = operationDescription.Behaviors.Find<DataContractSerializerOperationBehavior>();
      23             :                                         if (serializerBehavior == null)
      24             :                                                 operationDescription.Behaviors.Add(serializerBehavior = new DataContractSerializerOperationBehavior(operationDescription));
      25             :                                         serializerBehavior.DataContractResolver = (DataContractResolver)Activator.CreateInstance(AppDomain.CurrentDomain, dataContractType.Assembly.FullName, dataContractType.FullName).Unwrap();
      26             :                                 }
      27             :                         }
      28             : 
      29             :                         return host;
      30             :                 }
      31             :         }
      32             : }

Generated by: LCOV version 1.10