| | | 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.ObjectModel; |
| | | 6 | | using System.Xml; |
| | | 7 | | |
| | | 8 | | namespace CoreWCF.Description |
| | | 9 | | { |
| | | 10 | | public class ServiceEndpointCollection : Collection<ServiceEndpoint> |
| | | 11 | | { |
| | 591 | 12 | | internal ServiceEndpointCollection() |
| | | 13 | | { |
| | 591 | 14 | | } |
| | | 15 | | |
| | | 16 | | public ServiceEndpoint Find(Type contractType) |
| | | 17 | | { |
| | 0 | 18 | | if (contractType == null) |
| | | 19 | | { |
| | 0 | 20 | | throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(contractType)); |
| | | 21 | | } |
| | | 22 | | |
| | 0 | 23 | | foreach (ServiceEndpoint endpoint in this) |
| | | 24 | | { |
| | 0 | 25 | | if (endpoint != null && endpoint.Contract.ContractType == contractType) |
| | | 26 | | { |
| | 0 | 27 | | return endpoint; |
| | | 28 | | } |
| | | 29 | | } |
| | | 30 | | |
| | 0 | 31 | | return null; |
| | 0 | 32 | | } |
| | | 33 | | |
| | | 34 | | public ServiceEndpoint Find(XmlQualifiedName contractName) |
| | | 35 | | { |
| | 0 | 36 | | if (contractName == null) |
| | | 37 | | { |
| | 0 | 38 | | throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(contractName)); |
| | | 39 | | } |
| | | 40 | | |
| | 0 | 41 | | foreach (ServiceEndpoint endpoint in this) |
| | | 42 | | { |
| | 0 | 43 | | if (endpoint != null && endpoint.Contract.Name == contractName.Name && endpoint.Contract.Namespace == co |
| | | 44 | | { |
| | 0 | 45 | | return endpoint; |
| | | 46 | | } |
| | | 47 | | } |
| | | 48 | | |
| | 0 | 49 | | return null; |
| | 0 | 50 | | } |
| | | 51 | | |
| | | 52 | | public ServiceEndpoint Find(Type contractType, XmlQualifiedName bindingName) |
| | | 53 | | { |
| | 0 | 54 | | if (contractType == null) |
| | | 55 | | { |
| | 0 | 56 | | throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(contractType)); |
| | | 57 | | } |
| | 0 | 58 | | if (bindingName == null) |
| | | 59 | | { |
| | 0 | 60 | | throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(bindingName)); |
| | | 61 | | } |
| | | 62 | | |
| | 0 | 63 | | foreach (ServiceEndpoint endpoint in this) |
| | | 64 | | { |
| | 0 | 65 | | if (endpoint != null && endpoint.Contract.ContractType == contractType && |
| | 0 | 66 | | endpoint.Binding.Name == bindingName.Name && |
| | 0 | 67 | | endpoint.Binding.Namespace == bindingName.Namespace) |
| | | 68 | | { |
| | 0 | 69 | | return endpoint; |
| | | 70 | | } |
| | | 71 | | } |
| | | 72 | | |
| | 0 | 73 | | return null; |
| | 0 | 74 | | } |
| | | 75 | | |
| | | 76 | | public ServiceEndpoint Find(XmlQualifiedName contractName, XmlQualifiedName bindingName) |
| | | 77 | | { |
| | 0 | 78 | | if (contractName == null) |
| | | 79 | | { |
| | 0 | 80 | | throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(contractName)); |
| | | 81 | | } |
| | 0 | 82 | | if (bindingName == null) |
| | | 83 | | { |
| | 0 | 84 | | throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(bindingName)); |
| | | 85 | | } |
| | | 86 | | |
| | 0 | 87 | | foreach (ServiceEndpoint endpoint in this) |
| | | 88 | | { |
| | 0 | 89 | | if (endpoint != null && endpoint.Contract.Name == contractName.Name && |
| | 0 | 90 | | endpoint.Contract.Namespace == contractName.Namespace && |
| | 0 | 91 | | endpoint.Binding.Name == bindingName.Name && |
| | 0 | 92 | | endpoint.Binding.Namespace == bindingName.Namespace) |
| | | 93 | | { |
| | 0 | 94 | | return endpoint; |
| | | 95 | | } |
| | | 96 | | } |
| | | 97 | | |
| | 0 | 98 | | return null; |
| | 0 | 99 | | } |
| | | 100 | | |
| | | 101 | | public ServiceEndpoint Find(Uri address) |
| | | 102 | | { |
| | 0 | 103 | | if (address == null) |
| | | 104 | | { |
| | 0 | 105 | | throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(address)); |
| | | 106 | | } |
| | | 107 | | |
| | 0 | 108 | | foreach (ServiceEndpoint endpoint in this) |
| | | 109 | | { |
| | 0 | 110 | | if (endpoint != null && endpoint.Address.Uri == address) |
| | | 111 | | { |
| | 0 | 112 | | return endpoint; |
| | | 113 | | } |
| | | 114 | | } |
| | | 115 | | |
| | 0 | 116 | | return null; |
| | 0 | 117 | | } |
| | | 118 | | |
| | | 119 | | public Collection<ServiceEndpoint> FindAll(Type contractType) |
| | | 120 | | { |
| | 0 | 121 | | if (contractType == null) |
| | | 122 | | { |
| | 0 | 123 | | throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(contractType)); |
| | | 124 | | } |
| | | 125 | | |
| | 0 | 126 | | Collection<ServiceEndpoint> results = new Collection<ServiceEndpoint>(); |
| | | 127 | | |
| | 0 | 128 | | foreach (ServiceEndpoint endpoint in this) |
| | | 129 | | { |
| | 0 | 130 | | if (endpoint != null && endpoint.Contract.ContractType == contractType) |
| | | 131 | | { |
| | 0 | 132 | | results.Add(endpoint); |
| | | 133 | | } |
| | | 134 | | } |
| | | 135 | | |
| | 0 | 136 | | return results; |
| | | 137 | | } |
| | | 138 | | |
| | | 139 | | public Collection<ServiceEndpoint> FindAll(XmlQualifiedName contractName) |
| | | 140 | | { |
| | 0 | 141 | | if (contractName == null) |
| | | 142 | | { |
| | 0 | 143 | | throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(contractName)); |
| | | 144 | | } |
| | | 145 | | |
| | 0 | 146 | | Collection<ServiceEndpoint> results = new Collection<ServiceEndpoint>(); |
| | | 147 | | |
| | 0 | 148 | | foreach (ServiceEndpoint endpoint in this) |
| | | 149 | | { |
| | 0 | 150 | | if (endpoint != null && endpoint.Contract.Name == contractName.Name && endpoint.Contract.Namespace == co |
| | | 151 | | { |
| | 0 | 152 | | results.Add(endpoint); |
| | | 153 | | } |
| | | 154 | | } |
| | | 155 | | |
| | 0 | 156 | | return results; |
| | | 157 | | } |
| | | 158 | | |
| | | 159 | | protected override void InsertItem(int index, ServiceEndpoint item) |
| | | 160 | | { |
| | 641 | 161 | | if (item == null) |
| | | 162 | | { |
| | 0 | 163 | | throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(item)); |
| | | 164 | | } |
| | 641 | 165 | | base.InsertItem(index, item); |
| | 641 | 166 | | } |
| | | 167 | | |
| | | 168 | | protected override void SetItem(int index, ServiceEndpoint item) |
| | | 169 | | { |
| | 0 | 170 | | if (item == null) |
| | | 171 | | { |
| | 0 | 172 | | throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(item)); |
| | | 173 | | } |
| | 0 | 174 | | base.SetItem(index, item); |
| | 0 | 175 | | } |
| | | 176 | | } |
| | | 177 | | } |