ISecurityEncodable.ToXml Método
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Cria uma codificação XML do objeto de segurança e do seu estado atual.
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
Devoluções
Uma codificação XML do objeto de segurança, incluindo qualquer informação de estado.
Exemplos
O seguinte exemplo de código demonstra a implementação do FromXml método. Este exemplo de código faz parte de um exemplo maior fornecido para a ISecurityEncodable classe.
// 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
Observações
Código personalizado que estende objetos de segurança precisa de implementar os ToXml métodos and FromXml para tornar os objetos codificados em segurança.