DnsPermission.IsUnrestricted Metode
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Memeriksa status izin keseluruhan objek.
public:
virtual bool IsUnrestricted();
public bool IsUnrestricted ();
abstract member IsUnrestricted : unit -> bool
override this.IsUnrestricted : unit -> bool
Public Function IsUnrestricted () As Boolean
Mengembalikan
true
DnsPermission jika instans dibuat dengan Unrestricted; jika tidak, false
.
Penerapan
Contoh
Contoh berikut menggunakan IsUnrestricted metode untuk memeriksa status izin keseluruhan objek.
public:
void useDns()
{
// Create a DnsPermission instance.
DnsPermission^ permission = gcnew DnsPermission( PermissionState::Unrestricted );
// Check for permission.
permission->Demand();
Console::WriteLine( "Attributes and Values of DnsPermission instance :" );
// Print the attributes and values.
PrintKeysAndValues( permission->ToXml()->Attributes );
// Check the permission state.
if ( permission->IsUnrestricted() )
{
Console::WriteLine( "Overall permissions : Unrestricted" );
}
else
{
Console::WriteLine( "Overall permissions : Restricted" );
}
}
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 void useDns() {
// Create a DnsPermission instance.
DnsPermission permission = new DnsPermission(PermissionState.Unrestricted);
// Check for permission.
permission.Demand();
Console.WriteLine("Attributes and Values of DnsPermission instance :");
// Print the attributes and values.
PrintKeysAndValues(permission.ToXml().Attributes);
// Check the permission state.
if (permission.IsUnrestricted())
Console.WriteLine("Overall permissions : Unrestricted");
else
Console.WriteLine("Overall permissions : Restricted");
}
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.
Dim permission As New DnsPermission(PermissionState.Unrestricted)
' Check for permission.
permission.Demand()
Console.WriteLine("Attributes and Values of DnsPermission instance :")
' Print the attributes and values.
PrintKeysAndValues(permission.ToXml().Attributes)
' Check the permission state.
If permission.IsUnrestricted() Then
Console.WriteLine("Overall permissions : Unrestricted")
Else
Console.WriteLine("Overall permissions : Restricted")
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
Berlaku untuk
Berkolaborasi dengan kami di GitHub
Sumber untuk konten ini dapat ditemukan di GitHub, yang juga dapat Anda gunakan untuk membuat dan meninjau masalah dan menarik permintaan. Untuk informasi selengkapnya, lihat panduan kontributor kami.