AsymmetricAlgorithm.ToXmlString Method (Boolean)

 

When overridden in a derived class, creates and returns an XML string representation of the current AsymmetricAlgorithm object. Otherwise, throws a NotImplementedException.

Namespace:   System.Security.Cryptography
Assembly:  mscorlib (in mscorlib.dll)

public virtual string ToXmlString(
	bool includePrivateParameters
)

Parameters

includePrivateParameters
Type: System.Boolean

true to include private parameters; otherwise, false.

Return Value

Type: System.String

An XML string encoding of the current AsymmetricAlgorithm object.

The following code example demonstrates how to call the ToXmlString method to create an XML representation of the parameters in the current AsymmetricAlgorithm object. This code example is part of a larger example provided for the AsymmetricAlgorithm class.

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());
}

.NET Framework
Available since 1.1
Windows Phone Silverlight
Available since 7.1
Return to top
Show: