internal ServiceDescription(string serviceName) { this.behaviors = new KeyedByTypeCollection <IServiceBehavior>(); this.endpoints = new ServiceEndpointCollection(); this.serviceNamespace = "http://tempuri.org/"; if (string.IsNullOrEmpty(serviceName)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("serviceName"); } this.Name = serviceName; }
public ServiceEndpointCollection ImportEndpoints(Service service) { var coll = new ServiceEndpointCollection(); foreach (Port port in service.Ports) { var sep = ImportEndpoint(port, false); if (sep != null) { coll.Add(sep); } } return(coll); }
private static ServiceEndpointModel[] GetServiceEndpoints(ServiceHostBase serviceHost) { ServiceEndpointCollection endpoints = serviceHost.Description?.Endpoints; List <ServiceEndpointModel> endpointList = new List <ServiceEndpointModel>(endpoints?.Count ?? 0); if (endpoints != null && endpoints.Count > 0) { foreach (var endpoint in endpoints) { endpointList.Add(new ServiceEndpointModel(endpoint)); } } return(endpointList.ToArray()); }
public ServiceEndpointCollection ImportEndpoints(PortType portType) { var coll = new ServiceEndpointCollection(); foreach (WSServiceDescription wsd in wsdl_documents) { foreach (WS.Binding binding in wsd.Bindings) { if (!binding.Type.Name.Equals(portType.Name)) { continue; } ImportEndpoints(coll, binding); } } return(coll); }
public void InitializeCounters(System.ServiceModel.Description.ServiceEndpointCollection endpoints) { List <string> names = new List <string>(); foreach (ServiceEndpoint endpoint in endpoints) { names.Add(string.Format("{0}@{1}", this.GetType().Name, endpoint.Address.ToString())); } while (true) { try { foreach (string name in names) { string condition = string.Format("SELECT * FROM Service WHERE Name=\"{0}\"", name); SelectQuery query = new SelectQuery(condition); ManagementScope managementScope = new ManagementScope(@"\\.\root\ServiceModel", new ConnectionOptions()); ManagementObjectSearcher searcher = new ManagementObjectSearcher(managementScope, query); ManagementObjectCollection instances = searcher.Get(); foreach (ManagementBaseObject instance in instances) { PropertyData data = instance.Properties["CounterInstanceName"]; this.totalCounter = new PerformanceCounter(CounterCategoryName, TotalCounterName, data.Value.ToString()); this.totalCounter.ReadOnly = false; this.totalCounter.RawValue = 0; this.microsoftCounter = new PerformanceCounter(CounterCategoryName, MicrosoftCounterName, data.Value.ToString()); this.microsoftCounter.ReadOnly = false; this.microsoftCounter.RawValue = 0; break; } } break; } catch (COMException) { } } Console.WriteLine("Counters initialized."); }
void ImportEndpoints(ServiceEndpointCollection coll, WSBinding binding) { foreach (WSServiceDescription wsd in wsdl_documents) { foreach (WS.Service service in wsd.Services) { foreach (WS.Port port in service.Ports) { if (!binding.Name.Equals(port.Binding.Name)) { continue; } var sep = ImportEndpoint(port, false); if (sep != null) { coll.Add(sep); } } } } }
private static ServiceEndpointCollection ImportEndpoints(MetadataSet metadataSet, IEnumerable <ContractDescription> contracts, MetadataExchangeClient client) { ServiceEndpointCollection endpoints = new ServiceEndpointCollection(); WsdlImporter importer = new WsdlImporter(metadataSet); importer.State.Add("MetadataExchangeClientKey", client); foreach (ContractDescription description in contracts) { importer.KnownContracts.Add(WsdlExporter.WsdlNamingHelper.GetPortTypeQName(description), description); } foreach (ContractDescription description2 in contracts) { foreach (ServiceEndpoint endpoint in importer.ImportEndpoints(description2)) { endpoints.Add(endpoint); } } if (importer.Errors.Count > 0) { TraceWsdlImportErrors(importer); } return(endpoints); }
private void HandleResult(IAsyncResult result) { MetadataSet metadataSet = this.client.EndGetMetadata(result); endpointCollection = ImportEndpoints(metadataSet, knownContracts, this.client); }
public ServiceDescription() { this.behaviors = new KeyedByTypeCollection <IServiceBehavior>(); this.endpoints = new ServiceEndpointCollection(); this.serviceNamespace = "http://tempuri.org/"; }