| | | 1 | | // Licensed to the .NET Foundation under one or more agreements. |
| | | 2 | | // The .NET Foundation licenses this file to you under the MIT license. |
| | | 3 | | |
| | | 4 | | using System; |
| | | 5 | | using System.Collections.Generic; |
| | | 6 | | using System.Collections.ObjectModel; |
| | | 7 | | using System.Xml; |
| | | 8 | | using CoreWCF.Channels; |
| | | 9 | | using CoreWCF.Description; |
| | | 10 | | |
| | | 11 | | namespace CoreWCF.Dispatcher |
| | | 12 | | { |
| | | 13 | | internal class UniqueContractNameValidationBehavior : IServiceBehavior |
| | | 14 | | { |
| | 576 | 15 | | private readonly Dictionary<XmlQualifiedName, ContractDescription> _contracts = new Dictionary<XmlQualifiedName, |
| | | 16 | | |
| | 1152 | 17 | | public UniqueContractNameValidationBehavior() { } |
| | | 18 | | |
| | | 19 | | public void Validate(ServiceDescription description, ServiceHostBase serviceHostBase) |
| | | 20 | | { |
| | 576 | 21 | | if (description == null) |
| | | 22 | | { |
| | 0 | 23 | | throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(description)); |
| | | 24 | | } |
| | | 25 | | |
| | 576 | 26 | | if (serviceHostBase == null) |
| | | 27 | | { |
| | 0 | 28 | | throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(serviceHostBase)); |
| | | 29 | | } |
| | | 30 | | |
| | 2434 | 31 | | foreach (ServiceEndpoint endpoint in description.Endpoints) |
| | | 32 | | { |
| | 641 | 33 | | XmlQualifiedName qname = new XmlQualifiedName(endpoint.Contract.Name, endpoint.Contract.Namespace); |
| | | 34 | | |
| | 641 | 35 | | if (!_contracts.ContainsKey(qname)) |
| | | 36 | | { |
| | 577 | 37 | | _contracts.Add(qname, endpoint.Contract); |
| | | 38 | | } |
| | 64 | 39 | | else if (_contracts[qname] != endpoint.Contract) |
| | | 40 | | { |
| | 0 | 41 | | throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException( |
| | 0 | 42 | | SR.Format(SR.SFxMultipleContractsWithSameName, qname.Name, qname.Namespace))); |
| | | 43 | | } |
| | | 44 | | } |
| | 576 | 45 | | } |
| | | 46 | | |
| | | 47 | | public void AddBindingParameters(ServiceDescription description, ServiceHostBase serviceHostBase, Collection<Ser |
| | | 48 | | { |
| | 0 | 49 | | } |
| | | 50 | | |
| | | 51 | | public void ApplyDispatchBehavior(ServiceDescription description, ServiceHostBase serviceHostBase) |
| | | 52 | | { |
| | 0 | 53 | | } |
| | | 54 | | } |
| | | 55 | | } |