GacMembershipConditionとは何? わかりやすく解説 Weblio辞書

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

GacMembershipCondition クラス

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

グローバル アセンブリ キャッシュ メンバシップテストして、そのアセンブリコード グループ属しているかどうか判断します。このクラス継承できません。

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

<SerializableAttribute> _
<ComVisibleAttribute(True)> _
Public NotInheritable Class
 GacMembershipCondition
    Implements IMembershipCondition, ISecurityEncodable, ISecurityPolicyEncodable
Dim instance As GacMembershipCondition
[SerializableAttribute] 
[ComVisibleAttribute(true)] 
public sealed class GacMembershipCondition
 : IMembershipCondition, ISecurityEncodable, ISecurityPolicyEncodable
[SerializableAttribute] 
[ComVisibleAttribute(true)] 
public ref class GacMembershipCondition sealed
 : IMembershipCondition, ISecurityEncodable, ISecurityPolicyEncodable
/** @attribute SerializableAttribute() */ 
/** @attribute ComVisibleAttribute(true) */ 
public final class GacMembershipCondition implements
 IMembershipCondition, ISecurityEncodable, 
    ISecurityPolicyEncodable
SerializableAttribute 
ComVisibleAttribute(true) 
public final class GacMembershipCondition implements
 IMembershipCondition, ISecurityEncodable, 
    ISecurityPolicyEncodable
解説解説
使用例使用例

GacMembershipCondition クラス使用する例を次に示します

Imports System
Imports System.Security
Imports System.Security.Policy
Imports System.Collections

Public Class GacMembershipConditionDemo

    ' Demonstrate the Copy method, which creates an identical 
    ' copy of the current permission.
    Private Function CopyDemo() As
 Boolean
        Console.WriteLine( _
            "*************************************************************")
        Dim Gac1 As New
 GacMembershipCondition
        Console.WriteLine("Original membership condition = ")
        Console.WriteLine(Gac1.ToXml().ToString())
        Try
            Dim membershipCondition As IMembershipCondition
 = Gac1.Copy()
            Console.WriteLine("Result of Copy = ")
            Console.WriteLine(CType(membershipCondition, _
                GacMembershipCondition).ToXml().ToString())
        Catch e As Exception
            Console.WriteLine(("Copy failed : " &
 Gac1.ToString() & _
                e.ToString()))
            Return False
        End Try

        Return True
    End Function 'CopyDemo

    ' Demonstrate the Check method, which determines whether the specified
 
    ' evidence satisfies the membership condition.
    Private Function CheckDemo() As
 Boolean
        Console.WriteLine( _
            "*************************************************************")
        Dim Gac1 As New
 GacMembershipCondition
        Dim myGac As New
 GacInstalled
        Try
            Dim hostEvidence() As Object
 = {myGac}
            Dim assemblyEvidence() As Object

            Dim myEvidence As New
 Evidence(hostEvidence, assemblyEvidence)
            Dim retCode As Boolean
 = Gac1.Check(myEvidence)
            Console.WriteLine(("Result of Check = "
 & retCode.ToString() _
                & ControlChars.Lf))
        Catch e As Exception
            Console.WriteLine(("Check failed : " &
 Gac1.ToString() & _ 
                e.ToString()))
            Return False
        End Try
        Return True
    End Function 'CheckDemo

    ' Demonstrate the GetHashCode method, which returns a hash code
    ' for the specified membership condition.
    Private Function GetHashCodeDemo() As
 Boolean
        Console.WriteLine( _
            "*************************************************************")
        Dim Gac1 As New
 GacMembershipCondition
        Try
            Console.WriteLine( _
                ("Result of GetHashCode for a GacMembershipCondition
 = " _
                & Gac1.GetHashCode().ToString() & ControlChars.Lf))
        Catch e As Exception
            Console.WriteLine(("GetHashCode failed : "
 & _
                Gac1.ToString() & e.ToString()))
            Return False
        End Try

        Return True
    End Function 'GetHashCodeDemo

    'Demonstrate the ToXml and FromXml methods, including the overloads.
 
    ' ToXml creates an XML encoding of the membership condition and
 its 
    ' current state; FromXml reconstructs a membership condition with
 the 
    ' specified state from the XML encoding.
    Private Function ToFromXmlDemo() As
 Boolean
        Console.WriteLine( _
            "*************************************************************")
        Try
            Dim Gac1 As New
 GacMembershipCondition
            Dim Gac2 As New
 GacMembershipCondition

            ' Roundtrip a GacMembershipCondition to and from an XML
 encoding.
            Gac2.FromXml(Gac1.ToXml())
            Dim result As Boolean
 = Gac2.Equals(Gac1)
            If result Then
                Console.WriteLine(("Result of ToXml() = "
 & _ 
                    Gac2.ToXml().ToString()))
                Console.WriteLine(("Result of ToFromXml roundtrip
 = " & _ 
                    Gac2.ToString()))
            Else
                Console.WriteLine(Gac2.ToString())
                Console.WriteLine(Gac1.ToString())
                Return False
            End If

            Dim Gac3 As New
 GacMembershipCondition
            Dim Gac4 As New
 GacMembershipCondition
            Dim policyEnumerator As IEnumerator
 = _
                SecurityManager.PolicyHierarchy()
            While policyEnumerator.MoveNext()
                Dim currentLevel As PolicyLevel
 = _
                    CType(policyEnumerator.Current, PolicyLevel)
                If currentLevel.Label = "Machine"
 Then
                    Console.WriteLine(("Result of ToXml(level)
 = " & _
                        Gac3.ToXml(currentLevel).ToString()))
                    Gac4.FromXml(Gac3.ToXml(), currentLevel)
                    Console.WriteLine(("Result of FromXml(element,
 level) = " _
                        & Gac4.ToString()))
                End If
            End While
        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 Copy demo.
        tempReturnCode = CopyDemo()
        If tempReturnCode = True Then
            Console.Out.WriteLine("Copy demo completed successfully.")
        Else
            Console.Out.WriteLine("Copy demo failed.")
        End If

        returnCode = tempReturnCode AndAlso returnCode

        ' Call the Check demo.
        tempReturnCode = CheckDemo()
        If tempReturnCode = True Then
            Console.Out.WriteLine("Check demo completed successfully.")
        Else
            Console.Out.WriteLine("Check demo failed.")
        End If

        returnCode = tempReturnCode AndAlso returnCode

        ' Call the GetHashCode demo.
        tempReturnCode = GetHashCodeDemo()
        If tempReturnCode = True Then
            Console.Out.WriteLine("GetHashCode demo completed
 successfully.")
        Else
            Console.Out.WriteLine("GetHashCode demo failed.")
        End If

        returnCode = tempReturnCode AndAlso returnCode

        ' Call the ToFromXml demo.
        tempReturnCode = ToFromXmlDemo()
        If tempReturnCode = True 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
 GacMembershipConditionDemo
            Dim returnCode As Boolean
 = testcase.RunDemo()
            If returnCode Then
                Console.Out.WriteLine( _
                    "The GacMembershipCondition 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 GacMembershipCondition
 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 'GacMembershipConditionDemo

using System;
using System.Security; 
using System.Security.Policy; 
using System.Collections;

public class GacMembershipConditionDemo
{
    // Demonstrate the Copy method, which creates an identical
    // copy of the current permission.
    private bool CopyDemo()
    {
        Console.WriteLine(
            "************************************************************");
        GacMembershipCondition Gac1 = new GacMembershipCondition();
        Console.WriteLine("Original membership condition = ");
        Console.WriteLine(Gac1.ToXml().ToString());
        try
        {
            IMembershipCondition membershipCondition = Gac1.Copy();
            Console.WriteLine("Result of Copy = ");
            Console.WriteLine(
                ((GacMembershipCondition)membershipCondition).ToXml().ToString()
                );
        }
        catch (Exception e)
        {
            Console.WriteLine("Copy failed : " + Gac1.ToString() + e);
            return false;
        }

        return true;

    }
    // Demonstrate the Check method, which determines whether the specified
 
    // evidence satisfies the membership condition.
    private bool CheckDemo()
    {
        Console.WriteLine(
            "************************************************************");
        GacMembershipCondition Gac1 = new GacMembershipCondition();
        GacInstalled myGac = new GacInstalled();
        try
        {
            Object [] hostEvidence = {myGac};
            Object [] assemblyEvidence = {};

            Evidence myEvidence = new Evidence(hostEvidence,assemblyEvidence);
            bool retCode = Gac1.Check(myEvidence);
            Console.WriteLine("Result of Check = " + retCode.ToString()
 + "\n");
        }
        catch (Exception e)
        {
            Console.WriteLine("Check failed : " + Gac1.ToString() + e);
            return false;
        }

        return true;
    }

    // Demonstrate the GetHashCode method, which returns a hash code
    // for the specified membership condition.
    private bool GetHashCodeDemo()
    {
        Console.WriteLine(
            "************************************************************");
        GacMembershipCondition Gac1 = new GacMembershipCondition();
        try
        {
            Console.WriteLine(
                "Result of GetHashCode for a GacMembershipCondition
 = " + 
                Gac1.GetHashCode().ToString() + "\n");
        }
        catch (Exception e)
        {
            Console.WriteLine("GetHashCode failed : " + Gac1.ToString()
 + e);
            return false;
        }

        return true;
    }

    // Demonstrate the ToXml and FromXml methods, including the overloads.
    // ToXml creates an XML encoding of the membership condition and
 its 
    // current state; FromXml reconstructs a membership condition with
 the 
    // specified state from the XML encoding.
    private bool ToFromXmlDemo()
    {
        Console.WriteLine(
            "************************************************************");
        try
        {
            GacMembershipCondition Gac1 = new GacMembershipCondition();
            GacMembershipCondition Gac2 = new GacMembershipCondition();

            // Roundtrip a GacMembershipCondition to and from an XML
 encoding.
            Gac2.FromXml(Gac1.ToXml());
            bool result = Gac2.Equals(Gac1);
            if (result)
            {
                Console.WriteLine(
                    "Result of ToXml() = " + Gac2.ToXml().ToString());
                Console.WriteLine(
                    "Result of ToFromXml roundtrip = " + Gac2.ToString());
            }
            else
            {
                Console.WriteLine(Gac2.ToString());
                Console.WriteLine(Gac1.ToString());
                return false;
            }

            GacMembershipCondition Gac3 = new GacMembershipCondition();
            GacMembershipCondition Gac4 = new GacMembershipCondition();
            IEnumerator policyEnumerator = SecurityManager.PolicyHierarchy();
            while (policyEnumerator.MoveNext())
            {
                PolicyLevel currentLevel = 
                    (PolicyLevel)policyEnumerator.Current;
                if (currentLevel.Label == "Machine")
                {
                    Console.WriteLine("Result of ToXml(level) = " + 
                        Gac3.ToXml(currentLevel));
                    Gac4.FromXml(Gac3.ToXml(), currentLevel);
                    Console.WriteLine("Result of FromXml(element, level) = "
 + 
                        Gac4.ToString());
                }
            }
        }
        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 Copy demo.
        if (tempReturnCode = CopyDemo())
            Console.Out.WriteLine("Copy demo completed successfully.");
        else 
            Console.Out.WriteLine("Copy demo failed.");

        returnCode = tempReturnCode && returnCode;

        // Call the Check demo.
        if (tempReturnCode = CheckDemo())
            Console.Out.WriteLine("Check demo completed successfully.");
        else 
            Console.Out.WriteLine("Check demo failed.");

        returnCode = tempReturnCode && returnCode;

        // Call the GetHashCode demo.
        if (tempReturnCode = GetHashCodeDemo())
            Console.Out.WriteLine("GetHashCode demo completed successfully.");
        else 
            Console.Out.WriteLine("GetHashCode 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
        {
            GacMembershipConditionDemo testcase = 
                new GacMembershipConditionDemo();
            bool returnCode = testcase.RunDemo();
            if (returnCode)
            {
                Console.Out.WriteLine(
                    "The GacMembershipCondition 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 GacMembershipCondition 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::Policy;
using namespace System::Collections;
public ref class GacMembershipConditionDemo
{
private:

    // Demonstrate the Copy method, which creates an identical 
    // copy of the current permission.
    bool CopyDemo()
    {
        Console::WriteLine(
            "************************************************************");
        GacMembershipCondition ^ Gac1 = gcnew GacMembershipCondition;
        Console::WriteLine("Original membership condition = ");
        Console::WriteLine(Gac1->ToXml());
        try
        {
            IMembershipCondition^ membershipCondition = Gac1->Copy();
            Console::WriteLine("Result of Copy = ");
            Console::WriteLine(
                (dynamic_cast<GacMembershipCondition^>(membershipCondition))
                ->ToXml());
        }
        catch (Exception^ e) 
        {
             Console::WriteLine("Copy failed : {0}{1}", Gac1, e);
             return false;
        }

        return true;
    }

    // Demonstrate the Check method, which determines whether the specified
 
    // evidence satisfies the membership condition.
    bool CheckDemo()
    {
        Console::WriteLine(
            "************************************************************");
        GacMembershipCondition ^ Gac1 = gcnew GacMembershipCondition;
        GacInstalled ^ myGac = gcnew GacInstalled;
        try
        {
             array<Object^>^hostEvidence = {myGac};
             array<Object^>^assemblyEvidence = {};
             Evidence^ myEvidence = 
                 gcnew Evidence(hostEvidence,assemblyEvidence);
             bool retCode = Gac1->Check(myEvidence);
             Console::WriteLine("Result of Check = {0}\n", retCode);
        }
        catch (Exception^ e) 
        {
             Console::WriteLine("Check failed : {0}{1}", Gac1, e);
             return false;
        }

        return true;
    }

    // Demonstrate the GetHashCode method, which returns a hash code
 
    // for the specified membership condition.
    bool GetHashCodeDemo()
    {
        Console::WriteLine(
            "************************************************************");
        GacMembershipCondition ^ Gac1 = gcnew GacMembershipCondition;
        try
        {
            Console::WriteLine(
                "Result of GetHashCode for a GacMembershipCondition
 = {0}\n",
                Gac1->GetHashCode());
        }
        catch (Exception^ e) 
        {
             Console::WriteLine("GetHashCode failed : {0}{1}", Gac1, e);
             return false;
        }

        return true;
    }

    // Demonstrate the ToXml and FromXml methods, including the overloads.
 
    // ToXml creates an XML encoding of the membership condition and
 its 
    // current state; FromXml reconstructs a membership condition with
 the 
    // specified state from the XML encoding.
    bool ToFromXmlDemo()
    {
        Console::WriteLine(
            "************************************************************");
        try
        {
            GacMembershipCondition ^ Gac1 = gcnew GacMembershipCondition;
            GacMembershipCondition ^ Gac2 = gcnew GacMembershipCondition;

            // Roundtrip a GacMembershipCondition to and from an XML
 encoding.
            Gac2->FromXml(Gac1->ToXml());
            bool result = Gac2->Equals(Gac1);
            if (result)
            {
                Console::WriteLine("Result of ToXml() = {0}", Gac2->ToXml());
                Console::WriteLine(
                    "Result of ToFromXml roundtrip = {0}", Gac2);
            }
            else
            {
                Console::WriteLine(Gac2->ToString());
                Console::WriteLine(Gac1->ToString());
                return false;
            }

            GacMembershipCondition ^ Gac3 = gcnew GacMembershipCondition;
            GacMembershipCondition ^ Gac4 = gcnew GacMembershipCondition;
            IEnumerator^ policyEnumerator = SecurityManager::PolicyHierarchy();
            while (policyEnumerator->MoveNext())
            {
                PolicyLevel^ currentLevel = 
                    dynamic_cast<PolicyLevel^>(policyEnumerator->Current);
                if (currentLevel->Label->Equals("Machine"))
                {
                    Console::WriteLine("Result of ToXml(level) = {0}",
 
                        Gac3->ToXml(currentLevel));
                    Gac4->FromXml(Gac3->ToXml(), currentLevel);
                    Console::WriteLine(
                        "Result of FromXml(element, level) = {0}", Gac4);
                }
            }
        }
        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 Copy demo.
        if (tempReturnCode = CopyDemo())
            Console::WriteLine("Copy demo completed successfully.");
        else
            Console::WriteLine("Copy demo failed.");

        returnCode = tempReturnCode && returnCode;

        // Call the Check demo.
        if (tempReturnCode = CheckDemo())
            Console::WriteLine("Check demo completed successfully.");
        else
            Console::WriteLine("Check demo failed.");

        returnCode = tempReturnCode && returnCode;

        // Call the GetHashCode demo.
        if (tempReturnCode = GetHashCodeDemo())
            Console::WriteLine("GetHashCode demo completed successfully.");
        else
            Console::WriteLine("GetHashCode 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
    {
        GacMembershipConditionDemo^ testcase = 
            gcnew GacMembershipConditionDemo;
        bool returnCode = testcase->RunDemo();
        if (returnCode)
        {
            Console::WriteLine(
                "The GacMembershipCondition demo completed successfully.");
            Console::WriteLine("Press the Enter key to exit.");
            Console::ReadLine();
            System::Environment::ExitCode = 100;
        }
        else
        {
            Console::WriteLine("The GacMembershipCondition 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.Policy.*;
import System.Collections.*;
import System.Security.SecurityManager;

public class GacMembershipConditionDemo
{
    // Demonstrate the Copy method, which creates an identical copy
 of the
    // current permission.
    private boolean CopyDemo()
    {
        Console.WriteLine("********************************************"
            + "*******");

        GacMembershipCondition gac1 = new GacMembershipCondition();
        Console.WriteLine("Original membership condition = ");
        Console.WriteLine(gac1.ToXml().ToString());
        try {
            IMembershipCondition membershipCondition = gac1.Copy();
            Console.WriteLine("Result of Copy = ");
            Console.WriteLine(((GacMembershipCondition)(membershipCondition)).
                ToXml().ToString());
        }
        catch (System.Exception e) {
            Console.WriteLine(("Copy failed : " + gac1.ToString() + e));
            return false;
        }
        return true;
    } //CopyDemo

    // Demonstrate the Check method, which determines whether the specified
 
    // evidence satisfies the membership condition.
    private boolean CheckDemo()
    {
        Console.WriteLine("*******************************************"
            + "********");

        GacMembershipCondition gac1 = new GacMembershipCondition();
        GacInstalled myGac = new GacInstalled();

        try {
            Object hostEvidence[] = new Object[] { myGac };
            Object assemblyEvidence[] = null;
            Evidence myEvidence = new Evidence(hostEvidence, assemblyEvidence);
            boolean retCode = gac1.Check(myEvidence);
            Console.WriteLine(("Result of Check = " + 
                System.Convert.ToString(retCode) 
                + "\n"));
        }
        catch (System.Exception e) {
            Console.WriteLine(("Check failed : " + gac1.ToString() + e));
            return false;
        }
        return true;
    } //CheckDemo

    // Demonstrate the GetHashCode method which returns a hash code
 for 
    // the specified membership condition.
    private boolean GetHashCodeDemo()
    {
        Console.WriteLine("*********************************************"
            + "******");

        GacMembershipCondition gac1 = new GacMembershipCondition();

        try {
            Console.WriteLine(
                ("Result of GetHashCode for a GacMembershipCondition
 = " 
                + gac1.GetHashCode() + "\n"));
        }
        catch (System.Exception e) {
            Console.WriteLine(("GetHashCode failed : " + gac1.ToString()
 + e));
            return false;
        }
        return true;
    } //GetHashCodeDemo

    // Demonstrate the ToXml and FromXml methods, including the overloads.
 
    // ToXml creates an XML encoding of  the membership condition and
 its 
    // current state; FromXml reconstructs a membership condition with
 the 
    // specified state from the XML encoding.
    private boolean ToFromXmlDemo()
    {
        Console.WriteLine("********************************************"
            + "*******");
        
        try {
            GacMembershipCondition gac1 = new GacMembershipCondition();
            GacMembershipCondition gac2 = new GacMembershipCondition();

            // Roundtrip a GacMembershipCondition to and from an XML
 encoding.
            gac2.FromXml(gac1.ToXml());
            boolean result = gac2.Equals(gac1);
            if (result) {
                Console.WriteLine(("Result of ToXml() = " 
                    + gac2.ToXml().ToString()));
                Console.WriteLine(("Result of ToFromXml roundtrip = " 
                    + gac2.ToString()));
            }
            else {
                Console.WriteLine(gac2.ToString());
                Console.WriteLine(gac1.ToString());
                return false;
            }

            GacMembershipCondition gac3 = new GacMembershipCondition();
            GacMembershipCondition gac4 = new GacMembershipCondition();
            IEnumerator policyEnumerator = SecurityManager.PolicyHierarchy();

            while (policyEnumerator.MoveNext()) {
                PolicyLevel currentLevel = ((PolicyLevel)(policyEnumerator.
                    get_Current()));
                if (currentLevel.get_Label().Equals("Machine"))
 {
                    Console.WriteLine(("Result of ToXml(level) = " 
                        + gac3.ToXml(currentLevel)));
                    gac4.FromXml(gac3.ToXml(), currentLevel);
                    Console.WriteLine(("Result of FromXml(element, level) =
 " 
                        + gac4.ToString()));
                }
            }
        }
        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 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 Check demo.
        if (tempReturnCode = CheckDemo()) {
            Console.get_Out().WriteLine("Check demo completed successfully.");
        }
        else {
            Console.get_Out().WriteLine("Check demo failed.");
        }
        returnCode = tempReturnCode && returnCode;

        // Call the GetHashCode demo.
        if (tempReturnCode = GetHashCodeDemo()) {
            Console.get_Out().WriteLine(
                "GetHashCode demo completed successfully.");
        }
        else {
            Console.get_Out().WriteLine("GetHashCode 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 {
            GacMembershipConditionDemo testcase = 
                new GacMembershipConditionDemo();
            boolean returnCode = testcase.RunDemo();

            if (returnCode) {
                Console.get_Out().WriteLine(
                    "The GacMembershipCondition demo" 
                    + " completed successfully.");
                Console.get_Out().WriteLine("Press the Enter key to exit.");
                String consoleInput = Console.ReadLine();
                Environment.set_ExitCode(100);
            }
            else {
                Console.get_Out().WriteLine("The GacMembershipCondition "
 
                    + " demo failed.");
                Console.get_Out().WriteLine("Press the ENTER key to exit.");
                String consoleInput = Console.ReadLine();
                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();
            Environment.set_ExitCode(101);
        }
    } //main
} //GacMembershipConditionDemo
継承階層継承階層
System.Object
  System.Security.Policy.GacMembershipCondition
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
GacMembershipCondition メンバ
System.Security.Policy 名前空間

GacMembershipCondition コンストラクタ

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

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

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

Dim instance As New GacMembershipCondition
public GacMembershipCondition ()
public:
GacMembershipCondition ()
public GacMembershipCondition ()
public function GacMembershipCondition ()
解説解説
使用例使用例

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

Dim Gac1 As New GacMembershipCondition
Try
    Console.WriteLine( _
        ("Result of GetHashCode for a GacMembershipCondition =
 " _
        & Gac1.GetHashCode().ToString() & ControlChars.Lf))
Catch e As Exception
    Console.WriteLine(("GetHashCode failed : " &
 _
        Gac1.ToString() & e.ToString()))
    Return False
End Try

GacMembershipCondition Gac1 = new GacMembershipCondition();
try
{
    Console.WriteLine(
        "Result of GetHashCode for a GacMembershipCondition
 = " + 
        Gac1.GetHashCode().ToString() + "\n");
}
catch (Exception e)
{
    Console.WriteLine("GetHashCode failed : " + Gac1.ToString() + e);
    return false;
}
GacMembershipCondition ^ Gac1 = gcnew GacMembershipCondition;
try
{
    Console::WriteLine(
        "Result of GetHashCode for a GacMembershipCondition
 = {0}\n",
        Gac1->GetHashCode());
}
catch (Exception^ e) 
{
     Console::WriteLine("GetHashCode failed : {0}{1}", Gac1, e);
     return false;
}
GacMembershipCondition gac1 = new GacMembershipCondition();

try {
    Console.WriteLine(
        ("Result of GetHashCode for a GacMembershipCondition
 = " 
        + gac1.GetHashCode() + "\n"));
}
catch (System.Exception e) {
    Console.WriteLine(("GetHashCode failed : " + gac1.ToString() + e));
    return false;
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
GacMembershipCondition クラス
GacMembershipCondition メンバ
System.Security.Policy 名前空間

GacMembershipCondition メソッド


GacMembershipCondition メンバ

グローバル アセンブリ キャッシュ メンバシップテストして、そのアセンブリコード グループ属しているかどうか判断します。このクラス継承できません。

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


パブリック コンストラクタパブリック コンストラクタ
  名前 説明
パブリック メソッド GacMembershipCondition GacMembershipCondition クラス新しインスタンス初期化します。
パブリック メソッドパブリック メソッド
参照参照

関連項目

GacMembershipCondition クラス
System.Security.Policy 名前空間



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

辞書ショートカット

すべての辞書の索引

「GacMembershipCondition」の関連用語

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

   

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



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

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

©2024 GRAS Group, Inc.RSS