SecurityElement 클래스

정의

보안 개체를 인코딩하기 위한 XML 개체 모델을 나타냅니다. 이 클래스는 상속될 수 없습니다.

public ref class SecurityElement sealed
public sealed class SecurityElement
[System.Serializable]
public sealed class SecurityElement
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class SecurityElement
type SecurityElement = class
[<System.Serializable>]
type SecurityElement = class
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type SecurityElement = class
Public NotInheritable Class SecurityElement
상속
SecurityElement
특성

예제

다음 예제에서는 클래스의 멤버를 사용하는 방법을 SecurityElement 보여줍니다.

using namespace System;
using namespace System::Security;
using namespace System::Collections;
ref class SecurityElementMembers
{
public:

   [STAThread]
   int TestSecurityElementMembers()
   {
      SecurityElement^ xmlRootElement = gcnew SecurityElement( L"RootTag",L"XML security tree" );

      AddAttribute( xmlRootElement, L"creationdate", DateTime::Now.ToString() );
      AddChildElement( xmlRootElement, L"destroytime", DateTime::Now.AddSeconds( 1.0 ).ToString() );
      
      SecurityElement^ windowsRoleElement = gcnew SecurityElement( L"WindowsMembership.WindowsRole" );

      windowsRoleElement->AddAttribute( L"version", L"1.00" );

      // Add a child element and a creationdate attribute.
      AddChildElement( windowsRoleElement, L"BabyElement", L"This is a child element" );
      AddAttribute( windowsRoleElement, L"creationdate", DateTime::Now.ToString() );
      
      xmlRootElement->AddChild( windowsRoleElement );

      CompareAttributes( xmlRootElement, L"creationdate" );
      ConvertToHashTable( xmlRootElement );
      DisplaySummary( xmlRootElement );

      // Determine if the security element is too old to keep.
      xmlRootElement = DestroyTree( xmlRootElement );
      if ( xmlRootElement != nullptr )
      {
         String^ elementInXml = xmlRootElement->ToString();

         Console::WriteLine( elementInXml );
      }

      Console::WriteLine( L"This sample completed successfully; "
      L"press Enter to exit." );
      Console::ReadLine();
      return 1;
   }


private:

   // Add an attribute to the specified security element.
   static SecurityElement^ AddAttribute( SecurityElement^ xmlElement, String^ attributeName, String^ attributeValue )
   {
      if ( xmlElement != nullptr )
      {
         // Verify that the attribute name and value are valid XML formats.
         if ( SecurityElement::IsValidAttributeName( attributeName ) &&
                SecurityElement::IsValidAttributeValue( attributeValue ) )
         {
            // Add the attribute to the security element.
            xmlElement->AddAttribute( attributeName, attributeValue );
         }
      }

      return xmlElement;
   }


   // Add a child element to the specified security element.
   static SecurityElement^ AddChildElement( SecurityElement^ parentElement, String^ tagName, String^ tagText )
   {
      if ( parentElement != nullptr )
      {
         // Ensure that the tag text is in valid XML format.
         if (  !SecurityElement::IsValidText( tagText ) )
         {
            // Replace invalid text with valid XML text 
            // to enforce proper XML formatting.
            tagText = SecurityElement::Escape( tagText );
         }

         // Determine whether the tag is in valid XML format.
         if ( SecurityElement::IsValidTag( tagName ) )
         {
            SecurityElement^ childElement;
            childElement = parentElement->SearchForChildByTag( tagName );
            if ( childElement != nullptr )
            {
               String^ elementText;
               elementText = parentElement->SearchForTextOfTag( tagName );
               if (  !elementText->Equals( tagText ) )
               {
                  // Add child element to the parent security element.
                  parentElement->AddChild( gcnew SecurityElement( tagName,tagText ) );
               }
            }
            else
            {
               // Add child element to the parent security element.
               parentElement->AddChild( gcnew SecurityElement( tagName,tagText ) );
            }
         }
      }

      return parentElement;
   }


   // Create and display a summary sentence 
   // about the specified security element.
   static void DisplaySummary( SecurityElement^ xmlElement )
   {
      // Retrieve tag name for the security element.
      String^ xmlTreeName = xmlElement->Tag->ToString();
      // Retrieve tag text for the security element.
      String^ xmlTreeDescription = xmlElement->Text;
      // Retrieve value of the creationdate attribute.
      String^ xmlCreationDate = xmlElement->Attribute(L"creationdate");
      // Retrieve the number of children under the security element.
      String^ childrenCount = xmlElement->Children->Count.ToString();
      String^ outputMessage = String::Format( L"The security XML tree named {0}", xmlTreeName );
      outputMessage = String::Concat( outputMessage, String::Format( L"({0})", xmlTreeDescription ) );
      outputMessage = String::Concat( outputMessage, String::Format( L" was created on {0} and ", xmlCreationDate ) );
      outputMessage = String::Concat( outputMessage, String::Format( L"contains {0} child elements.", childrenCount ) );
      Console::WriteLine( outputMessage );
   }

   // Compare the first two occurrences of an attribute 
   // in the specified security element.
   static void CompareAttributes( SecurityElement^ xmlElement, String^ attributeName )
   {
      // Create a hash table containing the security element's attributes.
      Hashtable^ attributeKeys = xmlElement->Attributes;
      String^ attributeValue = attributeKeys[ attributeName ]->ToString();
      IEnumerator^ myEnum = xmlElement->Children->GetEnumerator();
      while ( myEnum->MoveNext() )
      {
         SecurityElement^ xmlChild = safe_cast<SecurityElement^>(myEnum->Current);
         if ( attributeValue->Equals( xmlChild->Attribute(attributeName) ) )
         {
            // The security elements were created at the exact same time.
         }
      }
   }

   // Convert the contents of the specified security element 
   // to hash codes stored in a hash table.
   static void ConvertToHashTable( SecurityElement^ xmlElement )
   {
      // Create a hash table to hold hash codes of the security elements.
      Hashtable^ xmlAsHash = gcnew Hashtable;
      int rootIndex = xmlElement->GetHashCode();
      xmlAsHash->Add( rootIndex, L"root" );
      int parentNum = 0;
      IEnumerator^ myEnum1 = xmlElement->Children->GetEnumerator();
      while ( myEnum1->MoveNext() )
      {
         SecurityElement^ xmlParent = safe_cast<SecurityElement^>(myEnum1->Current);
         parentNum++;
         xmlAsHash->Add( xmlParent->GetHashCode(), String::Format( L"parent{0}", parentNum ) );
         if ( (xmlParent->Children != nullptr) && (xmlParent->Children->Count > 0) )
         {
            int childNum = 0;
            IEnumerator^ myEnum2 = xmlParent->Children->GetEnumerator();
            while ( myEnum2->MoveNext() )
            {
               SecurityElement^ xmlChild = safe_cast<SecurityElement^>(myEnum2->Current);
               childNum++;
               xmlAsHash->Add( xmlChild->GetHashCode(), String::Format( L"child{0}", childNum ) );
            }
         }
      }
   }

   // Delete the specified security element if the current time is past
   // the time stored in the destroytime tag.
   static SecurityElement^ DestroyTree( SecurityElement^ xmlElement )
   {
      SecurityElement^ localXmlElement = xmlElement;
      SecurityElement^ destroyElement = localXmlElement->SearchForChildByTag( L"destroytime" );
      
      // Verify that a destroytime tag exists.
      if ( localXmlElement->SearchForChildByTag( L"destroytime" ) != nullptr )
      {
         // Retrieve the destroytime text to get the time 
         // the tree can be destroyed.
         String^ storedDestroyTime = localXmlElement->SearchForTextOfTag( L"destroytime" );
         DateTime destroyTime = DateTime::Parse( storedDestroyTime );
         if ( DateTime::Now > destroyTime )
         {
            localXmlElement = nullptr;
            Console::WriteLine( L"The XML security tree has been deleted." );
         }
      }

      
      // Verify that xmlElement is of type SecurityElement.
      if ( xmlElement->GetType()->Equals( System::Security::SecurityElement::typeid ) )
      {
         // Determine whether the localXmlElement object 
         // differs from xmlElement.
         if ( xmlElement->Equals( localXmlElement ) )
         {
            // Verify that the tags, attributes and children of the
            // two security elements are identical.
            if ( xmlElement->Equal( localXmlElement ) )
            {
               // Return the original security element.
               return xmlElement;
            }
         }
      }

      // Return the modified security element.
      return localXmlElement;
   }

};

int main()
{
   SecurityElementMembers^ sem = gcnew SecurityElementMembers;
   sem->TestSecurityElementMembers();
}

//
// This sample produces the following output:
// 
// The security XML tree named RootTag(XML security tree) 
// was created on 2/23/2004 1:23:00 PM and contains 2 child elements.
//<RootTag creationdate="2/23/2004 1:23:00 PM">XML security tree
//   <destroytime>2/23/2004 1:23:01 PM</destroytime>
//   <WindowsMembership.WindowsRole version="1.00"
//                                  creationdate="2/23/2004 1:23:00 PM">
//      <BabyElement>This is a child element.</BabyElement>
//
//This sample completed successfully; press Exit to continue.
using System;
using System.Security;
using System.Collections;

class SecurityElementMembers
{
    [STAThread]
    static void Main(string[] args)
    {
        SecurityElement xmlRootElement =
            new SecurityElement("RootTag", "XML security tree");

        AddAttribute(xmlRootElement,"creationdate",DateTime.Now.ToString());
        AddChildElement(xmlRootElement,"destroytime",
            DateTime.Now.AddSeconds(1.0).ToString());

        SecurityElement windowsRoleElement =
            new SecurityElement("WindowsMembership.WindowsRole");

        windowsRoleElement.AddAttribute("version","1.00");

        // Add a child element and a creationdate attribute.
        AddChildElement(windowsRoleElement,"BabyElement",
            "This is a child element");
        AddAttribute(windowsRoleElement,"creationdate",
            DateTime.Now.ToString());

        xmlRootElement.AddChild(windowsRoleElement);

        CompareAttributes(xmlRootElement, "creationdate");
        ConvertToHashTable(xmlRootElement);

        DisplaySummary(xmlRootElement);

        // Determine if the security element is too old to keep.
        xmlRootElement = DestroyTree(xmlRootElement);
        if (xmlRootElement != null)
        {
            string elementInXml = xmlRootElement.ToString();
            Console.WriteLine(elementInXml);
        }

        Console.WriteLine("This sample completed successfully; " +
            "press Enter to exit.");
        Console.ReadLine();
    }

    // Add an attribute to the specified security element.
    private static SecurityElement AddAttribute(
        SecurityElement xmlElement,
        string attributeName,
        string attributeValue)
    {
        if (xmlElement != null)
        {
            // Verify that the attribute name and value are valid XML formats.
            if (SecurityElement.IsValidAttributeName(attributeName) &&
                SecurityElement.IsValidAttributeValue(attributeValue))
            {
                // Add the attribute to the security element.
                xmlElement.AddAttribute(attributeName, attributeValue);
            }
        }
        return xmlElement;
    }

    // Add a child element to the specified security element.
    private static SecurityElement AddChildElement(
        SecurityElement parentElement,
        string tagName,
        string tagText)
    {
        if (parentElement != null)
        {
            // Ensure that the tag text is in valid XML format.
            if (!SecurityElement.IsValidText(tagText))
            {
                // Replace invalid text with valid XML text
                // to enforce proper XML formatting.
                tagText = SecurityElement.Escape(tagText);
            }

            // Determine whether the tag is in valid XML format.
            if (SecurityElement.IsValidTag(tagName))
            {
                SecurityElement childElement;
                childElement = parentElement.SearchForChildByTag(tagName);

                if (childElement != null)
                {
                    String elementText;
                    elementText = parentElement.SearchForTextOfTag(tagName);

                    if (!elementText.Equals(tagText))
                    {
                        // Add child element to the parent security element.
                        parentElement.AddChild(
                            new SecurityElement(tagName, tagText));
                    }
                }
                else
                {
                    // Add child element to the parent security element.
                    parentElement.AddChild(
                        new SecurityElement(tagName, tagText));
                }
            }
        }
        return parentElement;
    }

    // Create and display a summary sentence
    // about the specified security element.
    private static void DisplaySummary(SecurityElement xmlElement)
    {
        // Retrieve tag name for the security element.
        string xmlTreeName = xmlElement.Tag.ToString();

        // Retrieve tag text for the security element.
        string xmlTreeDescription = xmlElement.Text;

        // Retrieve value of the creationdate attribute.
        string xmlCreationDate = xmlElement.Attribute("creationdate");

        // Retrieve the number of children under the security element.
        string childrenCount = xmlElement.Children.Count.ToString();

        string outputMessage = "The security XML tree named " + xmlTreeName;
        outputMessage += "(" + xmlTreeDescription + ")";
        outputMessage += " was created on " + xmlCreationDate + " and ";
        outputMessage += "contains " + childrenCount + " child elements.";

        Console.WriteLine(outputMessage);
    }

    // Compare the first two occurrences of an attribute
    // in the specified security element.
    private static void CompareAttributes(
        SecurityElement xmlElement, string attributeName)
    {
        // Create a hash table containing the security element's attributes.
        Hashtable attributeKeys = xmlElement.Attributes;
        string attributeValue = attributeKeys[attributeName].ToString();

        foreach(SecurityElement xmlChild in xmlElement.Children)
        {
            if (attributeValue.Equals(xmlChild.Attribute(attributeName)))
            {
                // The security elements were created at the exact same time.
            }
        }
    }

    // Convert the contents of the specified security element
    // to hash codes stored in a hash table.
    private static void ConvertToHashTable(SecurityElement xmlElement)
    {
        // Create a hash table to hold hash codes of the security elements.
        Hashtable xmlAsHash = new Hashtable();
        int rootIndex = xmlElement.GetHashCode();
        xmlAsHash.Add(rootIndex, "root");

        int parentNum = 0;

        foreach(SecurityElement xmlParent in xmlElement.Children)
        {
            parentNum++;
            xmlAsHash.Add(xmlParent.GetHashCode(), "parent" + parentNum);
            if ((xmlParent.Children != null) &&
                (xmlParent.Children.Count > 0))
            {
                int childNum = 0;
                foreach(SecurityElement xmlChild in xmlParent.Children)
                {
                    childNum++;
                    xmlAsHash.Add(xmlChild.GetHashCode(), "child" + childNum);
                }
            }
        }
    }

    // Delete the specified security element if the current time is past
    // the time stored in the destroytime tag.
    private static SecurityElement DestroyTree(SecurityElement xmlElement)
    {
        SecurityElement localXmlElement = xmlElement;
        SecurityElement destroyElement =
            localXmlElement.SearchForChildByTag("destroytime");

        // Verify that a destroytime tag exists.
        if (localXmlElement.SearchForChildByTag("destroytime") != null)
        {
            // Retrieve the destroytime text to get the time
            // the tree can be destroyed.
            string storedDestroyTime =
                localXmlElement.SearchForTextOfTag("destroytime");

            DateTime destroyTime = DateTime.Parse(storedDestroyTime);
            if (DateTime.Now > destroyTime)
            {
                localXmlElement = null;
                Console.WriteLine("The XML security tree has been deleted.");
            }
        }

        // Verify that xmlElement is of type SecurityElement.
        if (xmlElement.GetType().Equals(
            typeof(System.Security.SecurityElement)))
        {
            // Determine whether the localXmlElement object
            // differs from xmlElement.
            if (xmlElement.Equals(localXmlElement))
            {
                // Verify that the tags, attributes and children of the
                // two security elements are identical.
                if (xmlElement.Equal(localXmlElement))
                {
                    // Return the original security element.
                    return xmlElement;
                }
            }
        }

        // Return the modified security element.
        return localXmlElement;
    }
}
//
// This sample produces the following output:
//
// The security XML tree named RootTag(XML security tree)
// was created on 2/23/2004 1:23:00 PM and contains 2 child elements.
//<RootTag creationdate="2/23/2004 1:23:00 PM">XML security tree
//   <destroytime>2/23/2004 1:23:01 PM</destroytime>
//   <WindowsMembership.WindowsRole version="1.00"
//                                  creationdate="2/23/2004 1:23:00 PM">
//      <BabyElement>This is a child element.</BabyElement>
//
//This sample completed successfully; press Exit to continue.
Imports System.Security
Imports System.Collections



Class SecurityElementMembers

    <STAThread()> _
    Shared Sub Main(ByVal args() As String)
        Dim xmlRootElement As New SecurityElement("RootTag", "XML security tree")
        AddAttribute(xmlRootElement, "creationdate", DateTime.Now.ToString())
        AddChildElement(xmlRootElement, "destroytime", DateTime.Now.AddSeconds(1.0).ToString())

        Dim windowsRoleElement As New SecurityElement("WindowsMembership.WindowsRole")
        windowsRoleElement.AddAttribute("version", "1.00")
        ' Add a child element and a creationdate attribute.
        AddChildElement(windowsRoleElement, "BabyElement", "This is a child element")
        AddAttribute(windowsRoleElement, "creationdate", DateTime.Now.ToString())

        xmlRootElement.AddChild(windowsRoleElement)
        CompareAttributes(xmlRootElement, "creationdate")
        ConvertToHashTable(xmlRootElement)

        DisplaySummary(xmlRootElement)

        ' Determine if the security element is too old to keep.
        xmlRootElement = DestroyTree(xmlRootElement)
        If Not (xmlRootElement Is Nothing) Then
            Dim elementInXml As String = xmlRootElement.ToString()
            Console.WriteLine(elementInXml)
        End If

        Console.WriteLine("This sample completed successfully; " + "press Enter to exit.")
        Console.ReadLine()

    End Sub


    ' Add an attribute to the specified security element.
    Private Shared Function AddAttribute(ByVal xmlElement As SecurityElement, ByVal attributeName As String, ByVal attributeValue As String) As SecurityElement
        If Not (xmlElement Is Nothing) Then
            ' Verify that the attribute name and value are valid XML formats.
            If SecurityElement.IsValidAttributeName(attributeName) AndAlso SecurityElement.IsValidAttributeValue(attributeValue) Then
                ' Add the attribute to the security element.
                xmlElement.AddAttribute(attributeName, attributeValue)
            End If
        End If
        Return xmlElement

    End Function 'AddAttribute


    ' Add a child element to the specified security element.
    Private Shared Function AddChildElement(ByVal parentElement As SecurityElement, ByVal tagName As String, ByVal tagText As String) As SecurityElement
        If Not (parentElement Is Nothing) Then
            ' Ensure that the tag text is in valid XML format.
            If Not SecurityElement.IsValidText(tagText) Then
                ' Replace invalid text with valid XML text 
                ' to enforce proper XML formatting.
                tagText = SecurityElement.Escape(tagText)
            End If

            ' Determine whether the tag is in valid XML format.
            If SecurityElement.IsValidTag(tagName) Then
                Dim childElement As SecurityElement
                childElement = parentElement.SearchForChildByTag(tagName)
                If Not (childElement Is Nothing) Then
                    Dim elementText As String
                    elementText = parentElement.SearchForTextOfTag(tagName)
                    If Not elementText.Equals(tagText) Then
                        ' Add child element to the parent security element.
                        parentElement.AddChild(New SecurityElement(tagName, tagText))
                    End If
                Else
                    ' Add child element to the parent security element.
                    parentElement.AddChild(New SecurityElement(tagName, tagText))
                End If
            End If
        End If
        Return parentElement

    End Function 'AddChildElement


    ' Create and display a summary sentence 
    ' about the specified security element.
    Private Shared Sub DisplaySummary(ByVal xmlElement As SecurityElement)
        ' Retrieve tag name for the security element.
        Dim xmlTreeName As String = xmlElement.Tag.ToString()
        ' Retrieve tag text for the security element.
        Dim xmlTreeDescription As String = xmlElement.Text
        ' Retrieve value of the creationdate attribute.
        Dim xmlCreationDate As String = xmlElement.Attribute("creationdate")
        ' Retrieve the number of children under the security element.
        Dim childrenCount As String = xmlElement.Children.Count.ToString()
        Dim outputMessage As String = "The security XML tree named " + xmlTreeName
        outputMessage += "(" + xmlTreeDescription + ")"
        outputMessage += " was created on " + xmlCreationDate + " and "
        outputMessage += "contains " + childrenCount + " child elements."

        Console.WriteLine(outputMessage)

    End Sub


    ' Compare the first two occurrences of an attribute 
    ' in the specified security element.
    Private Shared Sub CompareAttributes(ByVal xmlElement As SecurityElement, ByVal attributeName As String)
        ' Create a hash table containing the security element's attributes.
        Dim attributeKeys As Hashtable = xmlElement.Attributes
        Dim attributeValue As String = attributeKeys(attributeName).ToString()
        Dim xmlChild As SecurityElement
        For Each xmlChild In xmlElement.Children
            If attributeValue.Equals(xmlChild.Attribute(attributeName)) Then
            End If
        Next xmlChild
        ' The security elements were created at the exact same time.
    End Sub


    ' Convert the contents of the specified security element 
    ' to hash codes stored in a hash table.
    Private Shared Sub ConvertToHashTable(ByVal xmlElement As SecurityElement)
        ' Create a hash table to hold hash codes of the security elements.
        Dim xmlAsHash As New Hashtable()
        Dim rootIndex As Integer = xmlElement.GetHashCode()
        xmlAsHash.Add(rootIndex, "root")
        Dim parentNum As Integer = 0

        Dim xmlParent As SecurityElement
        For Each xmlParent In xmlElement.Children
            parentNum += 1
            xmlAsHash.Add(xmlParent.GetHashCode(), "parent" + parentNum.ToString())
            If Not (xmlParent.Children Is Nothing) AndAlso xmlParent.Children.Count > 0 Then
                Dim childNum As Integer = 0
                Dim xmlChild As SecurityElement
                For Each xmlChild In xmlParent.Children
                    childNum += 1
                    xmlAsHash.Add(xmlChild.GetHashCode(), "child" + childNum.ToString())
                Next xmlChild
            End If
        Next xmlParent

    End Sub


    ' Delete the specified security element if the current time is past
    ' the time stored in the destroytime tag.
    Private Shared Function DestroyTree(ByVal xmlElement As SecurityElement) As SecurityElement
        Dim localXmlElement As SecurityElement = xmlElement
        Dim destroyElement As SecurityElement = localXmlElement.SearchForChildByTag("destroytime")

        ' Verify that a destroytime tag exists.
        If Not (localXmlElement.SearchForChildByTag("destroytime") Is Nothing) Then
            ' Retrieve the destroytime text to get the time 
            ' the tree can be destroyed.
            Dim storedDestroyTime As String = localXmlElement.SearchForTextOfTag("destroytime")
            Dim destroyTime As DateTime = DateTime.Parse(storedDestroyTime)
            If DateTime.Now > destroyTime Then
                localXmlElement = Nothing
                Console.WriteLine("The XML security tree has been deleted.")
            End If
        End If

        ' Verify that xmlElement is of type SecurityElement.
        If xmlElement.GetType().Equals(GetType(System.Security.SecurityElement)) Then
            ' Determine whether the localXmlElement object 
            ' differs from xmlElement.
            If xmlElement.Equals(localXmlElement) Then
                ' Verify that the tags, attributes and children of the
                ' two security elements are identical.
                If xmlElement.Equal(localXmlElement) Then
                    ' Return the original security element.
                    Return xmlElement
                End If
            End If
        End If

        ' Return the modified security element.
        Return localXmlElement

    End Function 'DestroyTree
End Class
'
' This sample produces the following output:
' 
' The security XML tree named RootTag(XML security tree) 
' was created on 2/23/2004 1:23:00 PM and contains 2 child elements.
'<RootTag creationdate="2/23/2004 1:23:00 PM">XML security tree
'   <destroytime>2/23/2004 1:23:01 PM</destroytime>
'   <WindowsMembership.WindowsRole version="1.00"
'                                  creationdate="2/23/2004 1:23:00 PM">
'      <BabyElement>This is a child element.</BabyElement>
'
'This sample completed successfully; press Exit to continue.

설명

이 클래스는 보안 시스템 내에서 사용하기 위한 간단한 XML 개체 모델의 간단한 구현이며 일반 XML 개체 모델로는 사용되지 않습니다. 이 설명서에서는 XML에 대한 기본 지식을 가정합니다.

요소에 대한 간단한 XML 개체 모델은 다음 부분으로 구성됩니다.

  • 태그는 요소 이름입니다.

  • 특성은 요소에서 0개 이상의 이름/값 특성 쌍입니다.

  • 자식은 및 </tag>내에 <tag> 중첩된 0개 이상의 요소입니다.

특성 기반 XML 표현을 사용하여 보안 요소와 해당 값을 표현하는 것이 좋습니다. 즉, 요소의 속성은 특성으로 표현되고 속성 값은 특성 값으로 표현됩니다. 태그 내에서 텍스트를 중첩하지 않습니다. 모든 <tag>text</tag> 표현의 경우 형식 <tag value="text"/> 의 표현을 일반적으로 사용할 수 있습니다. 이 특성 기반 XML 표현을 사용하면 가독성이 향상되고 결과 XML serialization의 WMI 이식성이 용이합니다.

특성 이름은 한 문자 이상이어야 하며 이 될 null수 없습니다. 요소 기반 값 표현을 사용하는 경우 형식으로 표현되는 <tag/> 텍스트 문자열이 있는 null 요소가고, 그렇지 않으면 텍스트가 및 </tag> 토큰으로 <tag> 구분됩니다. 두 폼을 특성과 결합할 수 있습니다. 특성이 있는 경우 표시됩니다.

요소의 태그, 특성 및 텍스트(있는 경우)는 항상 대/소문자를 구분합니다. XML 양식에는 따옴표가 포함되어 있으며 필요한 경우 이스케이프됩니다. XML에 사용할 수 없는 문자가 포함된 문자열 값은 을 반환합니다 ArgumentException. 이러한 규칙은 모든 속성 및 메서드에 적용됩니다.

참고

성능상의 이유로 문자 유효성은 요소가 XML 텍스트 형식으로 인코딩된 경우에만 검사되며 속성 또는 메서드의 모든 집합에서는 검사되지 않습니다. 정적 메서드는 필요한 경우 명시적 검사를 허용합니다.

생성자

SecurityElement(String)

지정된 태그를 사용하여 SecurityElement 클래스의 새 인스턴스를 초기화합니다.

SecurityElement(String, String)

지정된 태그 및 텍스트를 사용하여 SecurityElement 클래스의 새 인스턴스를 초기화합니다.

속성

Attributes

XML 요소의 특성을 이름/값 쌍으로 가져오거나 설정합니다.

Children

XML 요소의 자식 요소 배열을 가져오거나 설정합니다.

Tag

XML 요소의 태그 이름을 가져오거나 설정합니다.

Text

XML 요소 안에 있는 텍스트를 가져오거나 설정합니다.

메서드

AddAttribute(String, String)

이름/값 특성을 XML 요소에 추가합니다.

AddChild(SecurityElement)

자식 요소를 XML 요소에 추가합니다.

Attribute(String)

XML 요소에서 특성을 이름으로 찾습니다.

Copy()

현재 SecurityElement 개체의 동일한 복사본을 만들어 반환합니다.

Equal(SecurityElement)

두 개의 XML 요소 개체가 일치하는지 비교합니다.

Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
Escape(String)

문자열에 있는 잘못된 XML 문자를 해당하는 올바른 XML로 바꿉니다.

FromString(String)

XML로 인코딩된 문자열에서 보안 요소를 만듭니다.

GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
IsValidAttributeName(String)

문자열이 유효한 특성 이름인지 여부를 확인합니다.

IsValidAttributeValue(String)

문자열이 유효한 특성 값인지 여부를 확인합니다.

IsValidTag(String)

문자열이 유효한 태그인지 여부를 확인합니다.

IsValidText(String)

문자열이 XML 요소 내의 텍스트로 유효한지 여부를 확인합니다.

MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
SearchForChildByTag(String)

태그 이름으로 자식을 찾습니다.

SearchForTextOfTag(String)

태그 이름으로 자식을 찾고 포함된 텍스트를 반환합니다.

ToString()

XML 요소의 문자열 표현과 구성 요소 특성, 자식 요소 및 텍스트를 만듭니다.

적용 대상