ISecurityEncodable.ToXml Methode
Definitie
Belangrijk
Bepaalde informatie heeft betrekking op een voorlopige productversie die aanzienlijk kan worden gewijzigd voordat deze wordt uitgebracht. Microsoft biedt geen enkele expliciete of impliciete garanties met betrekking tot de informatie die hier wordt verstrekt.
Hiermee maakt u een XML-codering van het beveiligingsobject en de huidige status.
public:
System::Security::SecurityElement ^ ToXml();
public System.Security.SecurityElement? ToXml();
public System.Security.SecurityElement ToXml();
abstract member ToXml : unit -> System.Security.SecurityElement
Public Function ToXml () As SecurityElement
Retouren
Een XML-codering van het beveiligingsobject, inclusief statusinformatie.
Voorbeelden
In het volgende codevoorbeeld ziet u hoe u de FromXml methode implementeert. Dit codevoorbeeld maakt deel uit van een groter voorbeeld voor de ISecurityEncodable klasse.
// Produce XML from the permission's fields.
public override SecurityElement ToXml()
{
// These first three lines create an element with the required format.
SecurityElement e = new SecurityElement("IPermission");
// Replace the double quotation marks ("") with single quotation marks ('')
// to remain XML compliant when the culture is not neutral.
e.AddAttribute("class", GetType().AssemblyQualifiedName.Replace('\"', '\''));
e.AddAttribute("version", "1");
if (!m_specifiedAsUnrestricted)
e.AddAttribute("Flags", Enum.Format(typeof(SoundPermissionState), m_flags, "G"));
else
e.AddAttribute("Unrestricted", "true");
return e;
}
' Produce XML from the permission's fields.
Public Overrides Function ToXml() As SecurityElement
' These first three lines create an element with the required format.
Dim e As New SecurityElement("IPermission")
' Replace the double quotation marks ("") with single quotation marks ('')
' to remain XML compliant when the culture is not neutral.
e.AddAttribute("class", [GetType]().AssemblyQualifiedName.Replace(ControlChars.Quote, "'"c))
e.AddAttribute("version", "1")
If Not m_specifiedAsUnrestricted Then
e.AddAttribute("Flags", [Enum].Format(GetType(SoundPermissionState), m_flags, "G"))
Else
e.AddAttribute("Unrestricted", "true")
End If
Return e
End Function 'ToXml
Opmerkingen
Aangepaste code die beveiligingsobjecten uitbreidt, moet de ToXml en FromXml methoden implementeren om de objecten te beveiligen.