ServiceDescription Sınıf
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
Hizmetin tüm uç noktaları ve ilgili adresleri, bağlamaları, sözleşmeleri ve davranışları için belirtimler de dahil olmak üzere hizmetin eksiksiz, bellek içi açıklamasını temsil eder.
public ref class ServiceDescription
public class ServiceDescription
type ServiceDescription = class
Public Class ServiceDescription
- Devralma
-
ServiceDescription
Örnekler
Aşağıdaki örnekte, bir ServiceDescription nesnenin örneğini oluşturmanın çeşitli yolları gösterilmektedir.
Uri baseAddress = new Uri("http://localhost:8001/Simple");
ServiceHost serviceHost = new ServiceHost(typeof(CalculatorService), baseAddress);
serviceHost.AddServiceEndpoint(
typeof(ICalculator),
new WSHttpBinding(),
"CalculatorServiceObject");
// Enable Mex
ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
smb.HttpGetEnabled = true;
serviceHost.Description.Behaviors.Add(smb);
serviceHost.Open();
// Use Default constructor
ServiceDescription sd = new ServiceDescription();
// Create ServiceDescription from a collection of service endpoints
List<ServiceEndpoint> endpoints = new List<ServiceEndpoint>();
ContractDescription conDescr = new ContractDescription("ICalculator");
EndpointAddress endpointAddress = new EndpointAddress("http://localhost:8001/Basic");
ServiceEndpoint ep = new ServiceEndpoint(conDescr, new BasicHttpBinding(), endpointAddress);
endpoints.Add(ep);
ServiceDescription sd2 = new ServiceDescription(endpoints);
// Iterate through the list of behaviors in the ServiceDescription
ServiceDescription svcDesc = serviceHost.Description;
KeyedByTypeCollection<IServiceBehavior> sbCol = svcDesc.Behaviors;
foreach (IServiceBehavior behavior in sbCol)
{
Console.WriteLine("Behavior: {0}", behavior.ToString());
}
// svcDesc is a ServiceDescription.
svcDesc = serviceHost.Description;
string configName = svcDesc.ConfigurationName;
Console.WriteLine("Configuration name: {0}", configName);
// Iterate through the endpoints contained in the ServiceDescription
ServiceEndpointCollection sec = svcDesc.Endpoints;
foreach (ServiceEndpoint se in sec)
{
Console.WriteLine("Endpoint:");
Console.WriteLine("\tAddress: {0}", se.Address.ToString());
Console.WriteLine("\tBinding: {0}", se.Binding.ToString());
Console.WriteLine("\tContract: {0}", se.Contract.ToString());
KeyedByTypeCollection<IEndpointBehavior> behaviors = se.Behaviors;
foreach (IEndpointBehavior behavior in behaviors)
{
Console.WriteLine("Behavior: {0}", behavior.ToString());
}
}
string name = svcDesc.Name;
Console.WriteLine("Service Description name: {0}", name);
string namespc = svcDesc.Namespace;
Console.WriteLine("Service Description namespace: {0}", namespc);
Type serviceType = svcDesc.ServiceType;
Console.WriteLine("Service Type: {0}", serviceType.ToString());
// Instantiate a service description specifying a service object
// Note: Endpoints collection and other properties will be null since
// we have not specified them
CalculatorService svcObj = new CalculatorService();
ServiceDescription sd3 = ServiceDescription.GetService(svcObj);
String serviceName = sd3.Name;
Console.WriteLine("Service name: {0}", serviceName);
Dim baseAddress As New Uri("http://localhost:8001/Simple")
Dim serviceHost As New ServiceHost(GetType(CalculatorService), baseAddress)
serviceHost.AddServiceEndpoint(GetType(ICalculator), New WSHttpBinding(), "CalculatorServiceObject")
' Enable Mex
Dim smb As New ServiceMetadataBehavior()
smb.HttpGetEnabled = True
serviceHost.Description.Behaviors.Add(smb)
serviceHost.Open()
' Use Default constructor
Dim sd As New ServiceDescription()
' Create ServiceDescription from a collection of service endpoints
Dim endpoints As New List(Of ServiceEndpoint)()
Dim conDescr As New ContractDescription("ICalculator")
Dim endpointAddress As New EndpointAddress("http://localhost:8001/Basic")
Dim ep As New ServiceEndpoint(conDescr, New BasicHttpBinding(), endpointAddress)
endpoints.Add(ep)
Dim sd2 As New ServiceDescription(endpoints)
' Iterate through the list of behaviors in the ServiceDescription
Dim svcDesc As ServiceDescription = serviceHost.Description
Dim sbCol As KeyedByTypeCollection(Of IServiceBehavior) = svcDesc.Behaviors
For Each behavior As IServiceBehavior In sbCol
Console.WriteLine("Behavior: {0}", CType(behavior, Object).ToString())
Next behavior
' svcDesc is a ServiceDescription.
svcDesc = serviceHost.Description
Dim configName As String = svcDesc.ConfigurationName
Console.WriteLine("Configuration name: {0}", configName)
' Iterate through the endpoints contained in the ServiceDescription
Dim sec As ServiceEndpointCollection = svcDesc.Endpoints
For Each se As ServiceEndpoint In sec
Console.WriteLine("Endpoint:")
Console.WriteLine(Constants.vbTab & "Address: {0}", se.Address.ToString())
Console.WriteLine(Constants.vbTab & "Binding: {0}", se.Binding.ToString())
Console.WriteLine(Constants.vbTab & "Contract: {0}", se.Contract.ToString())
Dim behaviors As KeyedByTypeCollection(Of IEndpointBehavior) = se.Behaviors
For Each behavior As IEndpointBehavior In behaviors
Console.WriteLine("Behavior: {0}", CType(behavior, Object).ToString())
Next behavior
Next se
Dim name = svcDesc.Name
Console.WriteLine("Service Description name: {0}", name)
Dim namespc = svcDesc.Namespace
Console.WriteLine("Service Description namespace: {0}", namespc)
Dim serviceType As Type = svcDesc.ServiceType
Console.WriteLine("Service Type: {0}", serviceType.ToString())
' Instantiate a service description specifying a service object
' Note: Endpoints collection and other properties will be null since
' we have not specified them
Dim svcObj As New CalculatorService()
Dim sd3 As ServiceDescription = ServiceDescription.GetService(svcObj)
Dim serviceName = sd3.Name
Console.WriteLine("Service name: {0}", serviceName)
Açıklamalar
içinde ServiceDescription yer alan bilgiler, Windows Communication Foundation (WCF) sistemi tarafından hizmetin çalışma zamanı bileşenlerini oluşturmak için kullanılır.
genişletmek ServiceHostiçin özel davranışlar eklerken bu yöntemi kullanın. Program aracılığıyla, nesnesinde yöntemini çağırdığınızda öncekine Open göre özel hizmet davranışına ServiceHostBehaviors ihtiyacınız vardırAdd(T).
GetService(Object) ve GetService(Type) yöntemleri, kendi barındırma mekanizmanızla değiştirilirken Windows Communication Foundation (WCF) programlama modelini kullanan davranışları yansıtmak ServiceHostBase için kullanılabilir.
bir hizmet uç noktası hakkındaki meta verileri parametresi olarak geçirerek ServiceEndpoint dışarı aktarın ExportEndpoint(ServiceEndpoint). Bu yöntemi veya tarafından WsdlExportersağlanan diğer dışarı aktarma yöntemlerinden birini çağırdıktan sonra, nesne koleksiyonunu ServiceDescription döndürmek için özelliğini kullanınGeneratedWsdlDocuments.
Oluşturucular
| Name | Description |
|---|---|
| ServiceDescription() |
ServiceDescription sınıfının yeni bir örneğini başlatır. |
| ServiceDescription(IEnumerable<ServiceEndpoint>) |
Belirtilen hizmet uç noktaları numaralandırmasından sınıfının yeni bir örneğini ServiceDescription başlatır. |
Özellikler
| Name | Description |
|---|---|
| Behaviors |
Hizmetle ilişkili davranışları alır. |
| ConfigurationName |
Yapılandırma öğesinin adını < |
| Endpoints |
Hizmet açıklamasından uç nokta koleksiyonunu alır. |
| Name |
Hizmetin adını alır veya ayarlar. |
| Namespace |
Hizmetin ad alanını alır veya ayarlar. |
| ServiceType |
Hizmetin türünü alır. |
Yöntemler
| Name | Description |
|---|---|
| Equals(Object) |
Belirtilen nesnenin geçerli nesneye eşit olup olmadığını belirler. (Devralındığı yer: Object) |
| GetHashCode() |
Varsayılan karma işlevi işlevi görür. (Devralındığı yer: Object) |
| GetService(Object) |
Belirtilen hizmet nesnesiyle başlatılan bir hizmet açıklaması döndürür. |
| GetService(Type) |
Belirtilen hizmet türüyle başlatılan bir hizmet açıklaması döndürür. |
| GetType() |
Geçerli örneğin Type alır. (Devralındığı yer: Object) |
| MemberwiseClone() |
Geçerli Objectbasit bir kopyasını oluşturur. (Devralındığı yer: Object) |
| ToString() |
Geçerli nesneyi temsil eden bir dize döndürür. (Devralındığı yer: Object) |