DnsPermission.IsSubsetOf(IPermission) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
判斷目前使用權限執行個體是否為指定使用權限執行個體的子集。
public:
override bool IsSubsetOf(System::Security::IPermission ^ target);
public override bool IsSubsetOf (System.Security.IPermission target);
override this.IsSubsetOf : System.Security.IPermission -> bool
Public Overrides Function IsSubsetOf (target As IPermission) As Boolean
參數
- target
- IPermission
要為子集關係測試的第二個 DnsPermission 執行個體。
傳回
如果目前執行個體是不受限制的,而且 target
若不是 false
就是不受限制的,則為 null
,否則為 true
。
例外狀況
target
既不是 DnsPermission 也不是 null
。
範例
下列範例會 IsSubsetOf 使用 方法來判斷目前的許可權實例是否為指定許可權實例的子集。
public:
void useDns()
{
// Create a DnsPermission instance.
permission = gcnew DnsPermission( PermissionState::Unrestricted );
DnsPermission^ dnsPermission1 = gcnew DnsPermission( PermissionState::None );
// Check for permission.
permission->Demand();
dnsPermission1->Demand();
// Print the attributes and values.
Console::WriteLine( "Attributes and Values of 'DnsPermission' instance :" );
PrintKeysAndValues( permission->ToXml()->Attributes );
Console::WriteLine( "Attributes and Values of specified 'DnsPermission' instance :" );
PrintKeysAndValues( dnsPermission1->ToXml()->Attributes );
Subset( dnsPermission1 );
}
private:
void Subset( DnsPermission^ Permission1 )
{
if ( permission->IsSubsetOf( Permission1 ) )
{
Console::WriteLine( "Current 'DnsPermission' instance is a subset of specified 'DnsPermission' instance." );
}
else
{
Console::WriteLine( "Current 'DnsPermission' instance is not a subset of specified 'DnsPermission' instance." );
}
}
void PrintKeysAndValues( Hashtable^ myList )
{
// Get the enumerator that can iterate through the hash table.
IDictionaryEnumerator^ myEnumerator = myList->GetEnumerator();
Console::WriteLine( "\t-KEY-\t-VALUE-" );
while ( myEnumerator->MoveNext() )
{
Console::WriteLine( "\t {0}:\t {1}", myEnumerator->Key, myEnumerator->Value );
}
Console::WriteLine();
}
public void useDns() {
// Create a DnsPermission instance.
permission = new DnsPermission(PermissionState.Unrestricted);
DnsPermission dnsPermission1 = new DnsPermission(PermissionState.None);
// Check for permission.
permission.Demand();
dnsPermission1.Demand();
// Print the attributes and values.
Console.WriteLine("Attributes and Values of 'DnsPermission' instance :");
PrintKeysAndValues(permission.ToXml().Attributes);
Console.WriteLine("Attributes and Values of specified 'DnsPermission' instance :");
PrintKeysAndValues(dnsPermission1.ToXml().Attributes);
Subset(dnsPermission1);
}
private void Subset(DnsPermission Permission1)
{
if(permission.IsSubsetOf(Permission1))
Console.WriteLine("Current 'DnsPermission' instance is a subset of specified 'DnsPermission' instance.");
else
Console.WriteLine("Current 'DnsPermission' instance is not a subset of specified 'DnsPermission' instance.");
}
private void PrintKeysAndValues(Hashtable myList) {
// Get the enumerator that can iterate through the hash table.
IDictionaryEnumerator myEnumerator = myList.GetEnumerator();
Console.WriteLine("\t-KEY-\t-VALUE-");
while (myEnumerator.MoveNext())
Console.WriteLine("\t{0}:\t{1}", myEnumerator.Key, myEnumerator.Value);
Console.WriteLine();
}
Public Sub useDns()
' Create a DnsPermission instance.
permission = New DnsPermission(PermissionState.Unrestricted)
Dim dnsPermission1 As New DnsPermission(PermissionState.None)
' Check for permission.
permission.Demand()
dnsPermission1.Demand()
' Print the attributes and values.
Console.WriteLine("Attributes and Values of 'DnsPermission' instance :")
PrintKeysAndValues(permission.ToXml().Attributes)
Console.WriteLine("Attributes and Values of specified 'DnsPermission' instance :")
PrintKeysAndValues(dnsPermission1.ToXml().Attributes)
Subset(dnsPermission1)
End Sub
Private Sub Subset(Permission1 As DnsPermission)
If permission.IsSubsetOf(Permission1) Then
Console.WriteLine("Current 'DnsPermission' instance is a subset of specified 'DnsPermission' instance.")
Else
Console.WriteLine("Current 'DnsPermission' instance is not a subset of specified 'DnsPermission' instance.")
End If
End Sub
Private Sub PrintKeysAndValues(myList As Hashtable)
' Get the enumerator that can iterate through the hash table.
Dim myEnumerator As IDictionaryEnumerator = myList.GetEnumerator()
Console.WriteLine(ControlChars.Tab + "-KEY-" + ControlChars.Tab + "-VALUE-")
While myEnumerator.MoveNext()
Console.WriteLine(ControlChars.Tab + "{0}:" + ControlChars.Tab + "{1}", myEnumerator.Key, myEnumerator.Value)
End While
Console.WriteLine()
End Sub
備註
如果目前實例指定一組完全由指定實例所包含的作業,則目前的DnsPermissionDnsPermission實例是指定DnsPermissionDnsPermission實例的子集。
IsSubsetOf如果方法傳true
回 ,則目前的DnsPermission實例不允許超過指定DnsPermission實例的 DNS 伺服器存取權。