ServiceCredentials.Clone 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
创建当前实例的副本。
public:
System::ServiceModel::Description::ServiceCredentials ^ Clone();
public System.ServiceModel.Description.ServiceCredentials Clone ();
member this.Clone : unit -> System.ServiceModel.Description.ServiceCredentials
Public Function Clone () As ServiceCredentials
返回
一个 ServiceCredentials 实例。
示例
下面的代码演示如何调用此方法。
// Create a service host.
Uri httpUri = new Uri("http://localhost/Calculator");
ServiceHost sh = new ServiceHost(typeof(Calculator), httpUri);
// Create a binding that uses a WindowsServiceCredential .
WSHttpBinding b = new WSHttpBinding(SecurityMode.Message);
b.Security.Message.ClientCredentialType = MessageCredentialType.Windows;
// Add an endpoint.
sh.AddServiceEndpoint(typeof(ICalculator), b, "WindowsCalculator");
// Clone these credentials.
ServiceCredentials cloneCredential =
sh.Credentials.Clone();
' Create a service host.
Dim httpUri As New Uri("http://localhost/Calculator")
Dim sh As New ServiceHost(GetType(Calculator), httpUri)
' Create a binding that uses a WindowsServiceCredential .
Dim b As New WSHttpBinding(SecurityMode.Message)
b.Security.Message.ClientCredentialType = MessageCredentialType.Windows
' Add an endpoint.
sh.AddServiceEndpoint(GetType(ICalculator), b, "WindowsCalculator")
' Clone these credentials.
Dim cloneCredential As ServiceCredentials = sh.Credentials.Clone()