/// <summary>
/// Registers WCF services type mappings from the given configuration excluding specified endpoints if needed.
/// </summary>
public static IServiceCollection AddWcfServices(this IServiceCollection container, ContextInformation ctx, Func<ServiceEndpointElement, bool> exclEndpoints)
{
String servicesPath = "system.serviceModel/services";
ServicesSection services = (ServicesSection)(ctx != null ? ctx.GetSection(servicesPath) : ConfigurationManager.GetSection(servicesPath));
foreach (ServiceElement service in services.Services)
{
Type serviceType = GetType(service.Name);
if (serviceType == null) continue;
foreach (ServiceEndpointElement endpoint in service.Endpoints)
{
Type contractType = GetType(endpoint.Contract);
if (contractType == null || endpoint.IsSystemEndpoint || exclEndpoints != null && exclEndpoints(endpoint)) continue;
container.AddScoped(contractType, serviceType);
}
}
return container;
}