GacMembershipCondition.Check(Evidence) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
指示指定的辨識項是否符合成員資格條件。
public:
virtual bool Check(System::Security::Policy::Evidence ^ evidence);
public bool Check (System.Security.Policy.Evidence evidence);
abstract member Check : System.Security.Policy.Evidence -> bool
override this.Check : System.Security.Policy.Evidence -> bool
Public Function Check (evidence As Evidence) As Boolean
參數
傳回
如果指定的辨識項符合成員資格條件,則為 true
,否則為 false
。
實作
範例
下列程式代碼範例示範 如何使用 Check 方法。 這個範例是提供給 類別之較大範例的 GacMembershipCondition 一部分。
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;
}
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;
}
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
備註
這個成員資格條件會測試 GacInstalled 辨識項。