The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.
AsymmetricAlgorithm::FromXmlString Method (String^)
.NET Framework (current version)
When overridden in a derived class, reconstructs an AsymmetricAlgorithm object from an XML string. Otherwise, throws a NotImplementedException.
Assembly: mscorlib (in mscorlib.dll)
Parameters
- xmlString
-
Type:
System::String^
The XML string to use to reconstruct the AsymmetricAlgorithm object.
The following code example demonstrates how to implement the FromXmlString method to parse the specified XML string to populate the current CspParameters object. This code example is part of a larger example provided for the AsymmetricAlgorithm class.
// Expected XML schema:
// <CustomCryptoKeyValue>
// <ProviderName></ProviderName>
// <KeyContainerName></KeyContainerName>
// <KeyNumber></KeyNumber>
// <ProviderType></ProviderType>
// </CustomCryptoKeyValue>
public:
virtual void FromXmlString(String^ xmlString) override
{
if (xmlString != nullptr)
{
XmlDocument^ document = gcnew XmlDocument();
document->LoadXml(xmlString);
XmlNode^ firstNode = document->FirstChild;
XmlNodeList^ nodeList;
// Assemble parameters from values in each XML element.
cryptoServiceParameters = gcnew CspParameters();
// KeyContainerName is optional.
nodeList =
document->GetElementsByTagName("KeyContainerName");
if (nodeList->Count > 0)
{
cryptoServiceParameters->KeyContainerName =
nodeList->Item(0)->InnerText;
}
// KeyNumber is optional.
nodeList = document->GetElementsByTagName("KeyNumber");
if (nodeList->Count > 0)
{
cryptoServiceParameters->KeyNumber =
Int32::Parse(nodeList->Item(0)->InnerText);
}
// ProviderName is optional.
nodeList = document->GetElementsByTagName("ProviderName");
if (nodeList->Count > 0)
{
cryptoServiceParameters->ProviderName =
nodeList->Item(0)->InnerText;
}
// ProviderType is optional.
nodeList = document->GetElementsByTagName("ProviderType");
if (nodeList->Count > 0)
{
cryptoServiceParameters->ProviderType =
Int32::Parse(nodeList->Item(0)->InnerText);
}
}
else
{
throw gcnew ArgumentNullException("xmlString");
}
}
.NET Framework
Available since 1.1
Windows Phone Silverlight
Available since 7.1
Available since 1.1
Windows Phone Silverlight
Available since 7.1
Show: