Early Preview
This is currently very much a preview. Please feel free to try things out,
but don't be upset if anything is not yet working. Feedback is welcome over on our
GitHub Dicussions page.
class System.​Security.​SecurityElement
Assembly: System.Runtime
Inheritance: object → SecurityElement
Represents the XML object model for encoding security objects. This class cannot be inherited.
Properties
Attributes
Gets or sets the attributes of an XML element as name/value pairs.
Children
Gets or sets the array of child elements of the XML element.
public
string
Tag
Gets or sets the tag name of an XML element.
public
string
Text
Gets or sets the text within an XML element.
Methods
public
void
AddAttribute​(string name,
string value)
Adds a name/value attribute to an XML element.
name
The name of the attribute.
value
The value of the attribute.
public
void
AddChild​(SecurityElement child)
Adds a child element to the XML element.
child
The child element to add.
public
string
Attribute​(string name)
Finds an attribute by name in an XML element.
Returns The value associated with the named attribute, or <see langword="null" /> if no attribute with <paramref name="name" /> exists.
name
The name of the attribute for which to search.
public
SecurityElement
Copy​()
Creates and returns an identical copy of the current <see cref="T:System.Security.SecurityElement" /> object.
Returns A copy of the current <see cref="T:System.Security.SecurityElement" /> object.
public
bool
Equal​(SecurityElement other)
Compares two XML element objects for equality.
Returns <see langword="true" /> if the tag, attribute names and values, child elements, and text fields in the current XML element are identical to their counterparts in the <paramref name="other" /> parameter; otherwise, <see langword="false" /> .
other
An XML element object to which to compare the current XML element object.
public static
string
Escape​(string str)
Replaces invalid XML characters in a string with their valid XML equivalent.
Returns The input string with invalid characters replaced.
str
The string within which to escape invalid characters.
public static
SecurityElement
FromString​(string xml)
Creates a security element from an XML-encoded string.
Returns A <see cref="T:System.Security.SecurityElement" /> created from the XML.
xml
The XML-encoded string from which to create the security element.
public static
bool
IsValidAttributeName​(string name)
Determines whether a string is a valid attribute name.
Returns <see langword="true" /> if the <paramref name="name" /> parameter is a valid XML attribute name; otherwise, <see langword="false" /> .
name
The attribute name to test for validity.
public static
bool
IsValidAttributeValue​(string value)
Determines whether a string is a valid attribute value.
Returns <see langword="true" /> if the <paramref name="value" /> parameter is a valid XML attribute value; otherwise, <see langword="false" /> .
value
The attribute value to test for validity.
public static
bool
IsValidTag​(string tag)
Determines whether a string is a valid tag.
Returns <see langword="true" /> if the <paramref name="tag" /> parameter is a valid XML tag; otherwise, <see langword="false" /> .
tag
The tag to test for validity.
public static
bool
IsValidText​(string text)
Determines whether a string is valid as text within an XML element.
Returns <see langword="true" /> if the <paramref name="text" /> parameter is a valid XML text element; otherwise, <see langword="false" /> .
text
The text to test for validity.
public
SecurityElement
SearchForChildByTag​(string tag)
Finds a child by its tag name.
Returns The first child XML element with the specified tag value, or <see langword="null" /> if no child element with <paramref name="tag" /> exists.
tag
The tag for which to search in child elements.
public
string
SearchForTextOfTag​(string tag)
Finds a child by its tag name and returns the contained text.
Returns The text contents of the first child element with the specified tag value.
tag
The tag for which to search in child elements.
public
string
ToString​()
Produces a string representation of an XML element and its constituent attributes, child elements, and text.
Returns The XML element and its contents.
public
bool
Equals​(object obj)
Inherited from object
Determines whether the specified object is equal to the current object.
Returns <see langword="true" /> if the specified object is equal to the current object; otherwise, <see langword="false" /> .
obj
The object to compare with the current object.
protected
void
Finalize​()
Inherited from object
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
public
int
GetHashCode​()
Inherited from object
Serves as the default hash function.
Returns A hash code for the current object.
public
Type
GetType​()
Inherited from object
Gets the <see cref="T:System.Type" /> of the current instance.
Returns The exact runtime type of the current instance.
protected
object
MemberwiseClone​()
Inherited from object
Creates a shallow copy of the current <see cref="T:System.Object" /> .
Returns A shallow copy of the current <see cref="T:System.Object" /> .