GacIdentityPermissionとは? わかりやすく解説

GacIdentityPermission クラス

メモ : このクラスは、.NET Framework version 2.0新しく追加されたものです。

グローバル アセンブリ キャッシュ作成されファイルID アクセス許可定義します。このクラス継承できません。

名前空間: System.Security.Permissions
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

<SerializableAttribute> _
<ComVisibleAttribute(True)> _
Public NotInheritable Class
 GacIdentityPermission
    Inherits CodeAccessPermission
Dim instance As GacIdentityPermission
[SerializableAttribute] 
[ComVisibleAttribute(true)] 
public sealed class GacIdentityPermission :
 CodeAccessPermission
[SerializableAttribute] 
[ComVisibleAttribute(true)] 
public ref class GacIdentityPermission sealed
 : public CodeAccessPermission
/** @attribute SerializableAttribute() */ 
/** @attribute ComVisibleAttribute(true) */ 
public final class GacIdentityPermission extends
 CodeAccessPermission
SerializableAttribute 
ComVisibleAttribute(true) 
public final class GacIdentityPermission extends
 CodeAccessPermission
解説解説
使用例使用例

GacIdentityPermission クラス使用方法を示すコード例次に示します

Imports System
Imports System.Security
Imports System.Security.Permissions
Imports Microsoft.VisualBasic



Public Class GacIdentityPermissionDemo

    ' IsSubsetOf determines whether the current permission is a subset
 of the specified permission.
    Private Function IsSubsetOfDemo() As
 Boolean
        Try
            Dim Gac1 As New
 GacIdentityPermission
            Dim Gac2 As New
 GacIdentityPermission(PermissionState.None)
            If (Gac1.Equals(Gac2)) Then
                Console.WriteLine("GacIdentityPermission() equals
 GacIdentityPermission(PermissionState.None).")
            End If
            If Gac1.IsSubsetOf(Gac2) Then
                Console.WriteLine((Gac1.ToString() & " is
 a subset of " & Gac2.ToString()))
            Else
                Console.WriteLine((Gac1.ToString() & " is
 not a subset of " & Gac2.ToString()))
            End If
        Catch e As Exception
            Console.WriteLine(("An exception was thrown : "
 & e.ToString().ToString()))
            Return False
        End Try
        Return True
    End Function 'IsSubsetOfDemo

    ' Union creates a new permission that is the union of the current
 permission 
    ' and the specified permission.
    Private Function UnionDemo() As
 Boolean
        Dim Gac1 As New
 GacIdentityPermission(PermissionState.None)
        Dim Gac2 As New
 GacIdentityPermission
        Try
            Dim p3 As GacIdentityPermission
 = CType(Gac1.Union(Gac2), GacIdentityPermission)

            If Not (p3 Is
 Nothing) Then
                Console.WriteLine("The union of two GacIdentityPermissions
 was successful.")

            Else
                Console.WriteLine("The union of two GacIdentityPermissions
 failed.")
                Return False
            End If
        Catch e As Exception
            Console.WriteLine(("An exception was thrown : "
 & e.ToString()))
            Return False
        End Try

        Return True
    End Function 'UnionDemo

    ' Intersect creates and returns a new permission that is the intersection
 of the 
    ' current permission and the specified permission.
    Private Function IntersectDemo() As
 Boolean
        Dim Gac1 As New
 GacIdentityPermission
        Dim Gac2 As New
 GacIdentityPermission
        Try
            Dim p3 As GacIdentityPermission
 = CType(Gac1.Intersect(Gac2), GacIdentityPermission)
            If Not (p3 Is
 Nothing) Then
                Console.WriteLine(("The intersection of the two
 permissions = " & p3.ToString() & ControlChars.Lf))

            Else
                Console.WriteLine("The intersection of the two
 permissions is null." & ControlChars.Lf)
            End If
        Catch e As Exception
            Console.WriteLine(("An exception was thrown : "
 & e.ToString()))
            Return False
        End Try

        Return True
    End Function 'IntersectDemo

    'Copy creates and returns an identical copy of the current permission.
    Private Function CopyDemo() As
 Boolean

        Dim Gac1 As New
 GacIdentityPermission
        Dim Gac2 As New
 GacIdentityPermission
        Console.WriteLine("**************************************************************************")
        Try
            Gac2 = CType(Gac1.Copy(), GacIdentityPermission)
            If Not (Gac2 Is
 Nothing) Then
                Console.WriteLine(("Result of copy = "
 & Gac2.ToString() & ControlChars.Lf))
            End If

        Catch e As Exception
            Console.WriteLine(("Copy failed : " &
 Gac1.ToString() & e.ToString()))
            Return False
        End Try

        Return True
    End Function 'CopyDemo

    ' ToXml creates an XML encoding of the permission and its current
 state; FromXml reconstructs a 
    ' permission with the specified state from the XML encoding. 
    Private Function ToFromXmlDemo() As
 Boolean
        Dim Gac1 As New
 GacIdentityPermission
        Dim Gac2 As New
 GacIdentityPermission
        Console.WriteLine("**************************************************************************")
        Try
            Gac2 = New GacIdentityPermission(PermissionState.None)
            Gac2.FromXml(Gac1.ToXml())
            Dim result As Boolean
 = Gac2.Equals(Gac1)
            If Gac2.IsSubsetOf(Gac1) AndAlso
 Gac1.IsSubsetOf(Gac2) Then
                Console.WriteLine(("Result of ToFromXml = "
 & Gac2.ToString()))
            Else
                Console.WriteLine(Gac2.ToString())
                Console.WriteLine(Gac1.ToString())
                Return False
            End If
        Catch e As Exception
            Console.WriteLine(("ToFromXml failed. "
 & e.ToString()))
            Return False
        End Try

        Return True
    End Function 'ToFromXmlDemo

    ' Invoke all demos.
    Public Function RunDemo() As
 Boolean

        Dim returnCode As Boolean
 = True
        Dim tempReturnCode As Boolean
        ' Call the IsSubsetOf demo.
        tempReturnCode = IsSubsetOfDemo()
        If tempReturnCode Then
            Console.Out.WriteLine("IsSubsetOf demo completed successfully.")
        Else
            Console.Out.WriteLine("Subset demo failed.")
        End If
        returnCode = tempReturnCode AndAlso returnCode

        ' Call the Union demo.
        tempReturnCode = UnionDemo()
        If tempReturnCode Then
            Console.Out.WriteLine("Union demo completed successfully.")
        Else
            Console.Out.WriteLine("Union demo failed.")
        End If
        returnCode = tempReturnCode AndAlso returnCode

        ' Call the Intersect demo.    
        tempReturnCode = IntersectDemo()
        If tempReturnCode Then
            Console.Out.WriteLine("Intersect demo completed successfully.")
        Else
            Console.Out.WriteLine("Intersect demo failed.")
        End If
        returnCode = tempReturnCode AndAlso returnCode


        ' Call the Copy demo.    
        tempReturnCode = CopyDemo()
        If tempReturnCode Then
            Console.Out.WriteLine("Copy demo completed successfully.")
        Else
            Console.Out.WriteLine("Copy demo failed.")
        End If
        returnCode = tempReturnCode AndAlso returnCode

        ' Call the ToFromXML demo.    
        tempReturnCode = ToFromXmlDemo()
        If tempReturnCode Then
            Console.Out.WriteLine("ToFromXML demo completed successfully.")
        Else
            Console.Out.WriteLine("ToFromXml demo failed.")
        End If
        returnCode = tempReturnCode AndAlso returnCode

        Return returnCode
    End Function 'RunDemo

    ' Test harness.
    Public Overloads Shared
 Sub Main(ByVal args() As
 [String])
        Try
            Dim testcase As New
 GACIdentityPermissionDemo
            Dim returnCode As Boolean
 = testcase.RunDemo()
            If returnCode Then
                Console.Out.WriteLine("The GacIdentityPermission
 demo completed successfully.")
                Console.Out.WriteLine("Press the Enter key to
 exit.")
                Dim consoleInput As String
 = Console.ReadLine()
                System.Environment.ExitCode = 100
            Else
                Console.Out.WriteLine("The GacIdentityPermission
 demo failed.")
                Console.Out.WriteLine("Press the Enter key to
 exit.")
                Dim consoleInput As String
 = Console.ReadLine()
                System.Environment.ExitCode = 101
            End If
        Catch e As Exception
            Console.Out.WriteLine("The GacIdentityPermission demo
 failed.")
            Console.WriteLine(e.ToString())
            Console.Out.WriteLine("Press the Enter key to exit.")
            Dim consoleInput As String
 = Console.ReadLine()
            System.Environment.ExitCode = 101
        End Try
    End Sub 'Main
End Class 'GacIdentityPermissionDemo



using System;
using System.Security;
using System.Security.Permissions;

public class GacIdentityPermissionDemo
{
    // IsSubsetOf determines whether the current permission is a subset
 of the specified permission.
    private bool IsSubsetOfDemo()
    {
        try
        {
            GacIdentityPermission Gac1 = new GacIdentityPermission();
            GacIdentityPermission Gac2 = new GacIdentityPermission(PermissionState.None);
            if (Gac1.Equals(Gac2))
                Console.WriteLine("GacIdentityPermission() equals GacIdentityPermission(PermissionState.None).");
            if (Gac1.IsSubsetOf(Gac2))
            {
                Console.WriteLine(Gac1 + " is a subset of " + Gac2);
            }
            else
            {
                Console.WriteLine(Gac1 + " is not a subset of " + Gac2);
            }
        }
        catch (Exception e)
        {
            Console.WriteLine ("An exception was thrown : " + e);
            return false;
        }
        return true;
    }
    // Union creates a new permission that is the union of the current
 permission
    // and the specified permission.
    private bool UnionDemo()
    {
        GacIdentityPermission Gac1 = new GacIdentityPermission(PermissionState.None);
        GacIdentityPermission Gac2 = new GacIdentityPermission();
        try
        {
            GacIdentityPermission p3 = (GacIdentityPermission)Gac1.Union(Gac2);

            if (p3 != null)
            {
                Console.WriteLine("The union of two GacIdentityPermissions was
 successful.");

            }
            else
            {
                Console.WriteLine("The union of two GacIdentityPermissions failed.");
                return false;
            }
        }
        catch (Exception e)
        {
            Console.WriteLine("An exception was thrown : " + e);
            return false;

        }

        return true;

    }
    // Intersect creates and returns a new permission that is the intersection
 of the
    // current permission and the specified permission.
    private bool IntersectDemo()
    {
        GacIdentityPermission Gac1 = new GacIdentityPermission();
        GacIdentityPermission Gac2 = new GacIdentityPermission();
        try
        {
            GacIdentityPermission p3 = (GacIdentityPermission)Gac1.Intersect(Gac2);
            if (p3 != null)
            {
                Console.WriteLine("The intersection of the two permissions =
 " + p3.ToString() + "\n");

            }
            else
            {
                Console.WriteLine("The intersection of the two permissions is
 null.\n");
            }
        }
        catch (Exception e)
        {
            Console.WriteLine("An exception was thrown : " + e);
            return false;

        }

        return true;

    }
    //Copy creates and returns an identical copy of the current permission.
    private bool CopyDemo()
    {

        GacIdentityPermission Gac1 = new GacIdentityPermission();
        GacIdentityPermission Gac2 = new GacIdentityPermission();
        Console.WriteLine("**************************************************************************");
        try
        {
            Gac2 = (GacIdentityPermission)Gac1.Copy();
            if (Gac2 != null)
            {
                Console.WriteLine("Result of copy = " + Gac2.ToString()
 + "\n");
            }

        }
        catch (Exception e)
        {
            Console.WriteLine("Copy failed : " + Gac1.ToString() + e);
            return false;
        }

        return true;

    }
    // ToXml creates an XML encoding of the permission and its current
 state; FromXml reconstructs a
    // permission with the specified state from the XML encoding.
    private bool ToFromXmlDemo()
    {
        GacIdentityPermission Gac1 = new GacIdentityPermission();
        GacIdentityPermission Gac2 = new GacIdentityPermission();
        Console.WriteLine("**************************************************************************");
        try
        {
            Gac2 = new GacIdentityPermission(PermissionState.None);
            Gac2.FromXml(Gac1.ToXml());
            bool result = Gac2.Equals(Gac1);
            if (Gac2.IsSubsetOf(Gac1) && Gac1.IsSubsetOf(Gac2))
            {
                Console.WriteLine("Result of ToFromXml = " + Gac2.ToString());
            }
            else
            {
                Console.WriteLine(Gac2.ToString());
                Console.WriteLine(Gac1.ToString());
                return false;
            }
        }
        catch (Exception e)
        {
            Console.WriteLine("ToFromXml failed. " + e);
            return false;
        }

        return true;

    }
    // Invoke all demos.
    public bool RunDemo()
    {

        bool returnCode =true;
        bool tempReturnCode;
        // Call the IsSubsetOf demo.
        if (tempReturnCode = IsSubsetOfDemo())Console.Out.WriteLine("IsSubsetOf
 demo completed successfully.");
        else Console.Out.WriteLine("Subset demo failed.");
        returnCode = tempReturnCode && returnCode;

        // Call the Union demo.
        if (tempReturnCode = UnionDemo())Console.Out.WriteLine("Union
 demo completed successfully.");
        else Console.Out.WriteLine("Union demo failed.");
        returnCode = tempReturnCode && returnCode;

        // Call the Intersect demo.
        if (tempReturnCode = IntersectDemo())Console.Out.WriteLine("Intersect
 demo completed successfully.");
        else Console.Out.WriteLine("Intersect demo failed.");
        returnCode = tempReturnCode && returnCode;


        // Call the Copy demo.
        if (tempReturnCode = CopyDemo())Console.Out.WriteLine("Copy
 demo completed successfully.");
        else Console.Out.WriteLine("Copy demo failed.");
        returnCode = tempReturnCode && returnCode;

        // Call the ToFromXML demo.
        if (tempReturnCode = ToFromXmlDemo())Console.Out.WriteLine("ToFromXML
 demo completed successfully.");
        else Console.Out.WriteLine("ToFromXml demo failed.");
        returnCode = tempReturnCode && returnCode;

        return (returnCode);

    }
    // Test harness.
    public static void Main(String[]
 args)
    {
        try
        {
            GacIdentityPermissionDemo testcase = new GacIdentityPermissionDemo();
            bool returnCode = testcase.RunDemo();
            if (returnCode)
            {
                Console.Out.WriteLine("The GacIdentityPermission demo completed
 successfully.");
                Console.Out.WriteLine("Press the Enter key to exit.");
                string consoleInput = Console.ReadLine();
                System.Environment.ExitCode = 100;
            }
            else
            {
                Console.Out.WriteLine("The GacIdentityPermission demo failed.");
                Console.Out.WriteLine("Press the Enter key to exit.");
                string consoleInput = Console.ReadLine();
                System.Environment.ExitCode = 101;
            }
        }
        catch (Exception e)
        {
            Console.Out.WriteLine("The GacIdentityPermission demo failed.");
            Console.WriteLine(e.ToString());
            Console.Out.WriteLine("Press the Enter key to exit.");
            string consoleInput = Console.ReadLine();
            System.Environment.ExitCode = 101;
        }
    }
}



using namespace System;
using namespace System::Security;
using namespace System::Security::Permissions;
public ref class GacIdentityPermissionDemo
{
private:

   // IsSubsetOf determines whether the current permission is a subset
 of the specified permission.
   bool IsSubsetOfDemo()
   {
      try
      {
         
         GacIdentityPermission ^ Gac1 = gcnew GacIdentityPermission;
         GacIdentityPermission ^ Gac2 = gcnew GacIdentityPermission( PermissionState::None
 );
         if ( Gac1->Equals( Gac2 ) )
                  Console::WriteLine( "GacIdentityPermission() equals GacIdentityPermission(PermissionState.None)."
 );

         
         if ( Gac1->IsSubsetOf( Gac2 ) )
         {
            Console::WriteLine( "{0} is a subset of {1}", Gac1, Gac2 );
         }
         else
         {
            Console::WriteLine( "{0} is not a subset of {1}", Gac1, Gac2
 );
         }
      }
      catch ( Exception^ e ) 
      {
         Console::WriteLine( "An exception was thrown : {0}", e );
         return false;
      }

      return true;
   }


   // Union creates a new permission that is the union of the current
 permission 
   // and the specified permission.
   bool UnionDemo()
   {
      
      GacIdentityPermission ^ Gac1 = gcnew GacIdentityPermission( PermissionState::None
 );
      
      GacIdentityPermission ^ Gac2 = gcnew GacIdentityPermission;
      
      try
      {
         GacIdentityPermission ^ p3 = dynamic_cast<GacIdentityPermission^>(Gac1->Union(
 Gac2 ));
         if ( p3 != nullptr )
         {
            Console::WriteLine( "The union of two GacIdentityPermissions was
 successful." );
         }
         else
         {
            Console::WriteLine( "The union of two GacIdentityPermissions failed."
 );
            return false;
         }
      }
      catch ( Exception^ e ) 
      {
         Console::WriteLine( "An exception was thrown : {0}", e );
         return false;
      }

      return true;
   }


   // Intersect creates and returns a new permission that is the intersection
 of the 
   // current permission and the specified permission.
   bool IntersectDemo()
   {
      GacIdentityPermission ^ Gac1 = gcnew GacIdentityPermission;
      GacIdentityPermission ^ Gac2 = gcnew GacIdentityPermission;
      try
      {
         GacIdentityPermission ^ p3 = dynamic_cast<GacIdentityPermission^>(Gac1->Intersect(
 Gac2 ));
         if ( p3 != nullptr )
         {
            Console::WriteLine( "The intersection of the two permissions = {0}\n",
 p3 );
         }
         else
         {
            Console::WriteLine( "The intersection of the two permissions is
 null.\n" );
         }
      }
      catch ( Exception^ e ) 
      {
         Console::WriteLine( "An exception was thrown : {0}", e );
         return false;
      }

      return true;
   }


   //Copy creates and returns an identical copy of the current permission.
   bool CopyDemo()
   {
      GacIdentityPermission ^ Gac1 = gcnew GacIdentityPermission;
      GacIdentityPermission ^ Gac2 = gcnew GacIdentityPermission;
      Console::WriteLine( "**************************************************************************"
 );
      try
      {
         Gac2 = dynamic_cast<GacIdentityPermission^>(Gac1->Copy());
         if ( Gac2 != nullptr )
         {
            Console::WriteLine( "Result of copy = {0}\n", Gac2 );
         }
      }
      catch ( Exception^ e ) 
      {
         Console::WriteLine( "Copy failed : {0}{1}", Gac1, e );
         return false;
      }

      return true;
   }


   // ToXml creates an XML encoding of the permission and its current
 state; FromXml reconstructs a 
   // permission with the specified state from the XML encoding. 
   bool ToFromXmlDemo()
   {
      GacIdentityPermission ^ Gac1 = gcnew GacIdentityPermission;
      GacIdentityPermission ^ Gac2 = gcnew GacIdentityPermission;
      Console::WriteLine( "**************************************************************************"
 );
      try
      {
         Gac2 = gcnew GacIdentityPermission( PermissionState::None );
         Gac2->FromXml( Gac1->ToXml() );
         bool result = Gac2->Equals( Gac1 );
         if ( Gac2->IsSubsetOf( Gac1 ) && Gac1->IsSubsetOf(
 Gac2 ) )
         {
            Console::WriteLine( "Result of ToFromXml = {0}", Gac2 );
         }
         else
         {
            Console::WriteLine( Gac2 );
            Console::WriteLine( Gac1 );
            return false;
         }
      }
      catch ( Exception^ e ) 
      {
         Console::WriteLine( "ToFromXml failed. {0}", e );
         return false;
      }

      return true;
   }


public:

   // Invoke all demos.
   bool RunDemo()
   {
      bool returnCode = true;
      bool tempReturnCode;
      
      // Call the IsSubsetOf demo.
      if ( tempReturnCode = IsSubsetOfDemo() )
            Console::WriteLine( "IsSubsetOf demo completed successfully."
 );
      else
            Console::WriteLine( "Subset demo failed." );

      returnCode = tempReturnCode && returnCode;
      
      // Call the Union demo.
      if ( tempReturnCode = UnionDemo() )
            Console::WriteLine( "Union demo completed successfully." );
      else
            Console::WriteLine( "Union demo failed." );

      returnCode = tempReturnCode && returnCode;
      
      // Call the Intersect demo. 
      if ( tempReturnCode = IntersectDemo() )
            Console::WriteLine( "Intersect demo completed successfully."
 );
      else
            Console::WriteLine( "Intersect demo failed." );

      returnCode = tempReturnCode && returnCode;
      
      // Call the Copy demo. 
      if ( tempReturnCode = CopyDemo() )
            Console::WriteLine( "Copy demo completed successfully." );
      else
            Console::WriteLine( "Copy demo failed." );

      returnCode = tempReturnCode && returnCode;
      
      // Call the ToFromXML demo. 
      if ( tempReturnCode = ToFromXmlDemo() )
            Console::WriteLine( "ToFromXML demo completed successfully."
 );
      else
            Console::WriteLine( "ToFromXml demo failed." );

      returnCode = tempReturnCode && returnCode;
      return (returnCode);
   }

};


// Test harness.
int main()
{
   try
   {
      GacIdentityPermissionDemo^ testcase = gcnew GacIdentityPermissionDemo;
      bool returnCode = testcase->RunDemo();
      if ( returnCode )
      {
         Console::WriteLine( "The GacIdentityPermission demo completed successfully."
 );
         Console::WriteLine( "Press the Enter key to exit." );
         Console::ReadLine();
         System::Environment::ExitCode = 100;
      }
      else
      {
         Console::WriteLine( "The GacIdentityPermission demo failed." );
         Console::WriteLine( "Press the Enter key to exit." );
         Console::ReadLine();
         System::Environment::ExitCode = 101;
      }
   }
   catch ( Exception^ e ) 
   {
      Console::WriteLine( "The GacIdentityPermission demo failed." );
      Console::WriteLine( e );
      Console::WriteLine( "Press the Enter key to exit." );
      Console::ReadLine();
      System::Environment::ExitCode = 101;
   }

}

import System.* ;
import System.Security.* ;
import System.Security.Permissions.*;

public class GacIdentityPermissionDemo
{
    // IsSubsetOf determines whether the current permission is a subset
 
    // of the specified permission.
    private boolean IsSubsetOfDemo()
    {
        try {
            GacIdentityPermission gac1 = new GacIdentityPermission();
            GacIdentityPermission gac2 = new GacIdentityPermission(
                PermissionState.None);
            if (gac1.Equals(gac2)) {
                Console.WriteLine("GacIdentityPermission() " 
                    + "equals GacIdentityPermission(PermissionState.None).");
            }

            if (gac1.IsSubsetOf(gac2)) {
                Console.WriteLine((gac1 + " is a subset of " + gac2));
            }
            else {
                Console.WriteLine((gac1 + " is not a subset of " + gac2));
            }
        }
        catch (System.Exception e) {
            Console.WriteLine(("An exception was thrown : " + e));
            return false;
        }
        return true;
    } //IsSubsetOfDemo

    // Union creates a new permission that is the union of the current
 
    // permission and the specified permission.
    private boolean UnionDemo()
    {
        GacIdentityPermission gac1 = new GacIdentityPermission(
            PermissionState.None);

        GacIdentityPermission gac2 = new GacIdentityPermission();

        try {
            GacIdentityPermission p3 = 
                ((GacIdentityPermission)(gac1.Union(gac2)));
            if (p3 != null) {
                Console.WriteLine("The union of two GacIdentityPermissions "
 
                    + "was successful.");
            }
            else {
                Console.WriteLine("The union of two " 
                    + "GacIdentityPermissions failed.");
                return false;
            }
        }
        catch (System.Exception e) {
            Console.WriteLine(("An exception was thrown : " + e));
            return false;
        }
        return true;
    } //UnionDemo

    // Intersect creates and returns a new permission that is the 
    // intersection of the current permission and the specified permission.
    private boolean IntersectDemo()
    {
        GacIdentityPermission gac1 = new GacIdentityPermission();
        GacIdentityPermission gac2 = new GacIdentityPermission();

        try {
            GacIdentityPermission p3 = 
                ((GacIdentityPermission)(gac1.Intersect(gac2)));
            if (p3 != null) {
                Console.WriteLine(("The intersection of the two permissions
 = " 
                    + p3.ToString() + "\n"));
            }
            else {
                Console.WriteLine("The intersection of the two permissions "
 
                    + "is null.\n");
            }
        }
        catch (System.Exception e) {
            Console.WriteLine(("An exception was thrown : " + e));
            return false;
        }
        return true;
    } //IntersectDemo    

    // Copy creates and returns an identical copy of the current permission.
    private boolean CopyDemo()
    {
        GacIdentityPermission gac1 = new GacIdentityPermission();
        GacIdentityPermission gac2 = new GacIdentityPermission();
        Console.WriteLine("****************************************" 
            + "**********************************");
        
        try {
            gac2 = ((GacIdentityPermission)(gac1.Copy()));
            if (gac2 != null) {
                Console.WriteLine(("Result of copy = " 
                    + gac2.ToString() + "\n"));
            }
        }
        catch (System.Exception e) {
            Console.WriteLine(("Copy failed : " + gac1.ToString() + e));
            return false;
        }
        return true;
    } //CopyDemo

    // ToXml creates an XML encoding of the permission and its current
 state; 
    // FromXml reconstructs a permission with the specified state from
 the 
    // XML encoding.
    private boolean ToFromXmlDemo()
    {
        GacIdentityPermission gac1 = new GacIdentityPermission();
        GacIdentityPermission gac2 = new GacIdentityPermission();
        Console.WriteLine("***************************************" 
            + "***********************************");
        
        try {
            gac2 = new GacIdentityPermission(PermissionState.None);
            gac2.FromXml(gac1.ToXml());

            boolean result = gac2.Equals(gac1);

            if (gac2.IsSubsetOf(gac1) && gac1.IsSubsetOf(gac2))
 {
                Console.WriteLine(("Result of ToFromXml = " + gac2.ToString()));
            }
            else {
                Console.WriteLine(gac2.ToString());
                Console.WriteLine(gac1.ToString());
                return false;
            }
        }
        catch (System.Exception e) {
            Console.WriteLine(("ToFromXml failed. " + e));
            return false;
        }
        return true;
    } //ToFromXmlDemo    

    // Invoke all demos.
    public boolean RunDemo()
    {
        boolean returnCode = true;
        boolean tempReturnCode;

        // Call the IsSubsetOf demo.
        if (tempReturnCode = IsSubsetOfDemo()) {
            Console.get_Out().WriteLine("IsSubsetOf demo " 
                + "completed successfully.");
        }
        else {
            Console.get_Out().WriteLine("Subset demo failed.");
        }
        returnCode = tempReturnCode && returnCode;

        // Call the Union demo.
        if (tempReturnCode = UnionDemo()) {
            Console.get_Out().WriteLine("Union demo completed successfully.");
        }
        else {
            Console.get_Out().WriteLine("Union demo failed.");
        }
        returnCode = tempReturnCode && returnCode;

        // Call the Intersect demo.
        if (tempReturnCode = IntersectDemo()) {
            Console.get_Out().WriteLine("Intersect demo " 
                + "completed successfully.");
        }
        else {
            Console.get_Out().WriteLine("Intersect demo failed.");
        }
        returnCode = tempReturnCode && returnCode;

        // Call the Copy demo.
        if (tempReturnCode = CopyDemo()) {
            Console.get_Out().WriteLine("Copy demo completed successfully.");
        }
        else {
            Console.get_Out().WriteLine("Copy demo failed.");
        }
        returnCode = tempReturnCode && returnCode;

        // Call the ToFromXML demo.
        if (tempReturnCode = ToFromXmlDemo()) {
            Console.get_Out().WriteLine("ToFromXML demo " 
                + "completed successfully.");
        }
        else {
            Console.get_Out().WriteLine("ToFromXml demo failed.");
        }
        returnCode = tempReturnCode && returnCode;
        return returnCode;
    } //RunDemo    

    // Test harness.
    public static void main(String[]
 args)
    {
        try {
            GacIdentityPermissionDemo testcase = 
                new GacIdentityPermissionDemo();
            boolean returnCode = testcase.RunDemo();
            if (returnCode) {
                Console.get_Out().WriteLine("The GacIdentityPermission demo
 " 
                    + "completed successfully.");
                Console.get_Out().WriteLine("Press the Enter key to exit.");
                String consoleInput = Console.ReadLine();
                System.Environment.set_ExitCode(100);
            }
            else {
                Console.get_Out().WriteLine("The GacIdentityPermission "
 
                    + "demo failed.");
                Console.get_Out().WriteLine("Press the Enter key to exit.");
                String consoleInput = Console.ReadLine();
                System.Environment.set_ExitCode(101);
            }
        }
        catch (System.Exception e) {
            Console.get_Out().WriteLine("The GacIdentityPermission " 
                + "demo failed.");
            Console.WriteLine(e.ToString());
            Console.get_Out().WriteLine("Press the Enter key to exit.");
            String consoleInput = Console.ReadLine();
            System.Environment.set_ExitCode(101);
        }
    } //main
} //GacIdentityPermissionDemo
継承階層継承階層
System.Object
   System.Security.CodeAccessPermission
    System.Security.Permissions.GacIdentityPermission
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
GacIdentityPermission メンバ
System.Security.Permissions 名前空間

GacIdentityPermission コンストラクタ ()

メモ : このコンストラクタは、.NET Framework version 2.0新しく追加されたものです。

GacIdentityPermission クラス新しインスタンス初期化します。

名前空間: System.Security.Permissions
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Dim instance As New GacIdentityPermission
public GacIdentityPermission ()
public:
GacIdentityPermission ()
public GacIdentityPermission ()
public function GacIdentityPermission ()
解説解説

このコンストラクタは、PermissionState 値が None の GacIdentityPermission作成します

使用例使用例

GacIdentityPermission コンストラクタ使用するコード例次に示します。このコード例は、GacIdentityPermission クラストピック取り上げているコード例一部分です。

Dim Gac1 As New GacIdentityPermission
Dim Gac2 As New GacIdentityPermission(PermissionState.None)
If (Gac1.Equals(Gac2)) Then
    Console.WriteLine("GacIdentityPermission() equals GacIdentityPermission(PermissionState.None).")
End If
GacIdentityPermission Gac1 = new GacIdentityPermission();
GacIdentityPermission Gac2 = new GacIdentityPermission(PermissionState.None);
if (Gac1.Equals(Gac2))
    Console.WriteLine("GacIdentityPermission() equals GacIdentityPermission(PermissionState.None).");
GacIdentityPermission ^ Gac1 = gcnew GacIdentityPermission;
GacIdentityPermission ^ Gac2 = gcnew GacIdentityPermission( PermissionState::None
 );
if ( Gac1->Equals( Gac2 ) )
         Console::WriteLine( "GacIdentityPermission() equals GacIdentityPermission(PermissionState.None)."
 );


GacIdentityPermission gac1 = new GacIdentityPermission();
GacIdentityPermission gac2 = new GacIdentityPermission(
    PermissionState.None);
if (gac1.Equals(gac2)) {
    Console.WriteLine("GacIdentityPermission() " 
        + "equals GacIdentityPermission(PermissionState.None).");
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
GacIdentityPermission クラス
GacIdentityPermission メンバ
System.Security.Permissions 名前空間

GacIdentityPermission コンストラクタ (PermissionState)

メモ : このコンストラクタは、.NET Framework version 2.0新しく追加されたものです。

完全に制限した PermissionState指定して、GacIdentityPermission クラス新しインスタンス初期化します。

名前空間: System.Security.Permissions
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Public Sub New ( _
    state As PermissionState _
)
Dim state As PermissionState

Dim instance As New GacIdentityPermission(state)
public GacIdentityPermission (
    PermissionState state
)
public:
GacIdentityPermission (
    PermissionState state
)
public GacIdentityPermission (
    PermissionState state
)
public function GacIdentityPermission (
    state : PermissionState
)

パラメータ

state

PermissionState 値の 1 つ

例外例外
例外種類条件

ArgumentException

state有効な PermissionState 値ではありません。

解説解説
使用例使用例

GacIdentityPermission(PermissionState) コンストラクタ使用するコード例次に示します。このコード例は、GacIdentityPermission クラストピック取り上げているコード例一部分です。

Dim Gac1 As New GacIdentityPermission(PermissionState.None)
GacIdentityPermission Gac1 = new GacIdentityPermission(PermissionState.None);
GacIdentityPermission ^ Gac1 = gcnew GacIdentityPermission( PermissionState::None
 );

GacIdentityPermission gac1 = new GacIdentityPermission(
    PermissionState.None);
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
GacIdentityPermission クラス
GacIdentityPermission メンバ
System.Security.Permissions 名前空間

GacIdentityPermission コンストラクタ

GacIdentityPermission クラス新しインスタンス初期化します。
オーバーロードの一覧オーバーロードの一覧

名前 説明
GacIdentityPermission () GacIdentityPermission クラス新しインスタンス初期化します。
GacIdentityPermission (PermissionState) 完全に制限した PermissionState を指定してGacIdentityPermission クラス新しインスタンス初期化します。
参照参照

関連項目

GacIdentityPermission クラス
GacIdentityPermission メンバ
System.Security.Permissions 名前空間

GacIdentityPermission メソッド


パブリック メソッドパブリック メソッド

  名前 説明
パブリック メソッド Assert  アクセス許可要求によって保護されているリソースへのアクセス許可が、スタックの上位にある呼び出し元に与えられていない場合でも、呼び出しコードが、このメソッド呼び出すコード通じてリソースアクセスできるように宣言しますAssert使用すると、セキュリティ上の問題発生することがあります。 ( CodeAccessPermission から継承されます。)
パブリック メソッド Copy オーバーライドされます現在のアクセス許可コピー作成して返します
パブリック メソッド Demand  コール スタック内の上位にあるすべての呼び出し元に現在のインスタンスによって指定されているアクセス許可与えられていない場合は、実行時SecurityException強制します。 ( CodeAccessPermission から継承されます。)
パブリック メソッド Deny  コール スタックの上位の呼び出し元が、このメソッド呼び出すコード使用して現在のインスタンスによって指定されるリソースアクセスできないようにします。 ( CodeAccessPermission から継承されます。)
パブリック メソッド Equals  オーバーロードされます。 ( CodeAccessPermission から継承されます。)
パブリック メソッド FromXml オーバーライドされますXML エンコーディングからアクセス許可作成します
パブリック メソッド GetHashCode  ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用適した CodeAccessPermission オブジェクトハッシュ コード取得します。 ( CodeAccessPermission から継承されます。)
パブリック メソッド GetType  現在のインスタンスType取得します。 ( Object から継承されます。)
パブリック メソッド Intersect オーバーライドされます現在のアクセス許可指定したアクセス許可積集合を表すアクセス許可作成して返します
パブリック メソッド IsSubsetOf オーバーライドされます現在のアクセス許可が、指定したアクセス許可サブセットかどうか示します
パブリック メソッド PermitOnly  コール スタックの上位の呼び出し元が、このメソッド呼び出すコード使用して現在のインスタンスによって指定されるリソース以外のすべてのリソースアクセスできないようにします。 ( CodeAccessPermission から継承されます。)
パブリック メソッド ReferenceEquals  指定した複数Object インスタンス同一かどうか判断します。 ( Object から継承されます。)
パブリック メソッド RevertAll  現在のフレーム対す以前オーバーライドをすべて削除し無効にます。 ( CodeAccessPermission から継承されます。)
パブリック メソッド RevertAssert  現在のフレーム対す以前Assert をすべて削除し無効にます。 ( CodeAccessPermission から継承されます。)
パブリック メソッド RevertDeny  現在のフレーム対す以前Deny をすべて削除し無効にます。 ( CodeAccessPermission から継承されます。)
パブリック メソッド RevertPermitOnly  現在のフレーム対す以前の PermitOnly をすべて削除し無効にます。 ( CodeAccessPermission から継承されます。)
パブリック メソッド ToString  現在のアクセス許可オブジェクト文字列形式作成して返します。 ( CodeAccessPermission から継承されます。)
パブリック メソッド ToXml オーバーライドされますアクセス許可とその現在の状態を表す XML エンコーディング作成します
パブリック メソッド Union オーバーライドされます現在のアクセス許可指定したアクセス許可和集合を表すアクセス許可作成して返します
参照参照

関連項目

GacIdentityPermission クラス
System.Security.Permissions 名前空間

GacIdentityPermission メンバ

グローバル アセンブリ キャッシュ作成されファイルID アクセス許可定義します。このクラス継承できません。

GacIdentityPermission データ型公開されるメンバを以下の表に示します


パブリック コンストラクタパブリック コンストラクタ
  名前 説明
パブリック メソッド GacIdentityPermission オーバーロードされます。 GacIdentityPermission クラス新しインスタンス初期化します。
パブリック メソッドパブリック メソッド
  名前 説明
パブリック メソッド Assert  アクセス許可要求によって保護されているリソースへのアクセス許可が、スタックの上位にある呼び出し元に与えられていない場合でも、呼び出しコードが、このメソッド呼び出すコード通じてリソースアクセスできるように宣言しますAssert使用すると、セキュリティ上の問題発生することがあります。 (CodeAccessPermission から継承されます。)
パブリック メソッド Copy オーバーライドされます現在のアクセス許可コピー作成して返します
パブリック メソッド Demand  コール スタック内の上位にあるすべての呼び出し元に現在のインスタンスによって指定されているアクセス許可与えられていない場合は、実行時SecurityException強制します。 (CodeAccessPermission から継承されます。)
パブリック メソッド Deny  コール スタックの上位の呼び出し元が、このメソッド呼び出すコード使用して現在のインスタンスによって指定されるリソースアクセスできないようにします。 (CodeAccessPermission から継承されます。)
パブリック メソッド Equals  オーバーロードされます。 ( CodeAccessPermission から継承されます。)
パブリック メソッド FromXml オーバーライドされますXML エンコーディングからアクセス許可作成します
パブリック メソッド GetHashCode  ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用適した CodeAccessPermission オブジェクトハッシュ コード取得します。 (CodeAccessPermission から継承されます。)
パブリック メソッド GetType  現在のインスタンスType取得します。 (Object から継承されます。)
パブリック メソッド Intersect オーバーライドされます現在のアクセス許可指定したアクセス許可積集合を表すアクセス許可作成して返します
パブリック メソッド IsSubsetOf オーバーライドされます現在のアクセス許可が、指定したアクセス許可サブセットかどうか示します
パブリック メソッド PermitOnly  コール スタックの上位の呼び出し元が、このメソッド呼び出すコード使用して現在のインスタンスによって指定されるリソース以外のすべてのリソースアクセスできないようにします。 (CodeAccessPermission から継承されます。)
パブリック メソッド ReferenceEquals  指定した複数Object インスタンス同一かどうか判断します。 (Object から継承されます。)
パブリック メソッド RevertAll  現在のフレーム対す以前オーバーライドをすべて削除し無効にます。 (CodeAccessPermission から継承されます。)
パブリック メソッド RevertAssert  現在のフレーム対す以前Assert をすべて削除し無効にます。 (CodeAccessPermission から継承されます。)
パブリック メソッド RevertDeny  現在のフレーム対す以前Deny をすべて削除し無効にます。 (CodeAccessPermission から継承されます。)
パブリック メソッド RevertPermitOnly  現在のフレーム対す以前の PermitOnly をすべて削除し無効にます。 (CodeAccessPermission から継承されます。)
パブリック メソッド ToString  現在のアクセス許可オブジェクト文字列形式作成して返します。 (CodeAccessPermission から継承されます。)
パブリック メソッド ToXml オーバーライドされますアクセス許可とその現在の状態を表す XML エンコーディング作成します
パブリック メソッド Union オーバーライドされます現在のアクセス許可指定したアクセス許可和集合を表すアクセス許可作成して返します
参照参照

関連項目

GacIdentityPermission クラス
System.Security.Permissions 名前空間



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「GacIdentityPermission」の関連用語

GacIdentityPermissionのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



GacIdentityPermissionのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS