AsymmetricAlgorithm.ToXmlString(Boolean) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
在衍生類別中覆寫時,建立並傳回目前 AsymmetricAlgorithm 物件的 XML 字串表示。 否則,擲回 NotImplementedException。
public:
virtual System::String ^ ToXmlString(bool includePrivateParameters);
public:
abstract System::String ^ ToXmlString(bool includePrivateParameters);
public virtual string ToXmlString (bool includePrivateParameters);
public abstract string ToXmlString (bool includePrivateParameters);
abstract member ToXmlString : bool -> string
override this.ToXmlString : bool -> string
abstract member ToXmlString : bool -> string
Public Overridable Function ToXmlString (includePrivateParameters As Boolean) As String
Public MustOverride Function ToXmlString (includePrivateParameters As Boolean) As String
參數
- includePrivateParameters
- Boolean
如果要包含私用參數,則為 true
;否則為 false
。
傳回
目前 AsymmetricAlgorithm 物件的 XML 字串編碼方式。
範例
下列程式代碼範例示範如何呼叫 ToXmlString 方法,以在目前 AsymmetricAlgorithm 物件中建立參數的 XML 表示法。 此程式代碼範例是針對 類別提供的較大範例的 AsymmetricAlgorithm 一部分。
public:
virtual String^ ToXmlString(bool includePrivateParameters) override
{
String^ keyContainerName = "";
String^ keyNumber = "";
String^ providerName = "";
String^ providerType = "";
if (cryptoServiceParameters != nullptr)
{
keyContainerName =
cryptoServiceParameters->KeyContainerName;
keyNumber = cryptoServiceParameters->KeyNumber.ToString();
providerName = cryptoServiceParameters->ProviderName;
providerType =
cryptoServiceParameters->ProviderType.ToString();
}
StringBuilder^ sb = gcnew StringBuilder();
sb->Append("<CustomCryptoKeyValue>");
sb->Append("<KeyContainerName>");
sb->Append(keyContainerName);
sb->Append("</KeyContainerName>");
sb->Append("<KeyNumber>");
sb->Append(keyNumber);
sb->Append("</KeyNumber>");
sb->Append("<ProviderName>");
sb->Append(providerName);
sb->Append("</ProviderName>");
sb->Append("<ProviderType>");
sb->Append(providerType);
sb->Append("</ProviderType>");
sb->Append("</CustomCryptoKeyValue>");
return(sb->ToString());
}
public override string ToXmlString(bool includePrivateParameters)
{
string keyContainerName = "";
string keyNumber = "";
string providerName = "";
string providerType = "";
if (cspParameters != null)
{
keyContainerName = cspParameters.KeyContainerName;
keyNumber = cspParameters.KeyNumber.ToString();
providerName = cspParameters.ProviderName;
providerType = cspParameters.ProviderType.ToString();
}
StringBuilder sb = new StringBuilder();
sb.Append("<CustomCryptoKeyValue>");
sb.Append("<KeyContainerName>");
sb.Append(keyContainerName);
sb.Append("</KeyContainerName>");
sb.Append("<KeyNumber>");
sb.Append(keyNumber);
sb.Append("</KeyNumber>");
sb.Append("<ProviderName>");
sb.Append(providerName);
sb.Append("</ProviderName>");
sb.Append("<ProviderType>");
sb.Append(providerType);
sb.Append("</ProviderType>");
sb.Append("</CustomCryptoKeyValue>");
return(sb.ToString());
}
Public Overrides Function ToXmlString( _
ByVal includePrivateParameters As Boolean) As String
Dim keyContainerName As String = ""
Dim keyNumber As String = ""
Dim providerName As String = ""
Dim providerType As String = ""
If Not cspParameters Is Nothing Then
keyContainerName = cspParameters.KeyContainerName
keyNumber = cspParameters.KeyNumber.ToString()
providerName = cspParameters.ProviderName
providerType = cspParameters.ProviderType.ToString()
End If
Dim xmlBuilder As New StringBuilder
xmlBuilder.Append("<CustomCryptoKeyValue>")
xmlBuilder.Append("<KeyContainerName>")
xmlBuilder.Append(keyContainerName)
xmlBuilder.Append("</KeyContainerName>")
xmlBuilder.Append("<KeyNumber>")
xmlBuilder.Append(keyNumber)
xmlBuilder.Append("</KeyNumber>")
xmlBuilder.Append("<ProviderName>")
xmlBuilder.Append(providerName)
xmlBuilder.Append("</ProviderName>")
xmlBuilder.Append("<ProviderType>")
xmlBuilder.Append(providerType)
xmlBuilder.Append("</ProviderType>")
xmlBuilder.Append("</CustomCryptoKeyValue>")
Return (xmlBuilder.ToString())
End Function