ISecurityEncodable.ToXml Metoda
Definicja
Ważny
Niektóre informacje dotyczą produktów przedpremierowych, które mogą zostać znacznie zmodyfikowane przed premierą. Microsoft nie udziela żadnych gwarancji, ani wyraźnych, ani domniemanych, dotyczących informacji podanych tutaj.
Tworzy kodowanie XML obiektu zabezpieczeń i jego bieżącego stanu.
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
Zwraca
Kodowanie XML obiektu zabezpieczeń, w tym informacje o stanie.
Przykłady
Poniższy przykład kodu przedstawia implementację FromXml metody. Ten przykład kodu jest częścią większego przykładu podanego ISecurityEncodable dla klasy.
// 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
Uwagi
Niestandardowy kod, który rozszerza obiekty zabezpieczeń, musi zaimplementować ToXml metody i FromXml , aby obiekty zabezpieczeń można było enododable.