PrintPropertyDictionary Kelas

Definisi

Mewakili kumpulan properti dan nilai yang terkait dengan objek di System.Printing namespace.

public ref class PrintPropertyDictionary : System::Collections::Hashtable, IDisposable
public ref class PrintPropertyDictionary : System::Collections::Hashtable, IDisposable, System::Runtime::Serialization::IDeserializationCallback, System::Runtime::Serialization::ISerializable
[System.Serializable]
public class PrintPropertyDictionary : System.Collections.Hashtable, IDisposable
public class PrintPropertyDictionary : System.Collections.Hashtable, IDisposable, System.Runtime.Serialization.IDeserializationCallback, System.Runtime.Serialization.ISerializable
public class PrintPropertyDictionary : System.Collections.Hashtable, IDisposable
[<System.Serializable>]
type PrintPropertyDictionary = class
    inherit Hashtable
    interface ISerializable
    interface IDeserializationCallback
    interface IDisposable
type PrintPropertyDictionary = class
    inherit Hashtable
    interface IDisposable
    interface IDeserializationCallback
    interface ISerializable
Public Class PrintPropertyDictionary
Inherits Hashtable
Implements IDisposable
Public Class PrintPropertyDictionary
Inherits Hashtable
Implements IDeserializationCallback, IDisposable, ISerializable
Warisan
PrintPropertyDictionary
Atribut
Penerapan

Contoh

Contoh berikut menunjukkan cara menggunakan kelas ini untuk menginstal printer kedua yang berbeda dalam propertinya dari printer yang ada hanya di lokasi, port, dan status berbagi.

LocalPrintServer myLocalPrintServer = new LocalPrintServer(PrintSystemDesiredAccess.AdministrateServer);
PrintQueue sourcePrintQueue = myLocalPrintServer.DefaultPrintQueue;
PrintPropertyDictionary myPrintProperties = sourcePrintQueue.PropertiesCollection;

// Share the new printer using Remove/Add methods
PrintBooleanProperty shared = new PrintBooleanProperty("IsShared", true);
myPrintProperties.Remove("IsShared");
myPrintProperties.Add("IsShared", shared);

// Give the new printer its share name using SetProperty method
PrintStringProperty theShareName = new PrintStringProperty("ShareName", "\"Son of " + sourcePrintQueue.Name +"\"");
myPrintProperties.SetProperty("ShareName", theShareName);

// Specify the physical location of the new printer using Remove/Add methods
PrintStringProperty theLocation = new PrintStringProperty("Location", "the supply room");
myPrintProperties.Remove("Location");
myPrintProperties.Add("Location", theLocation);

// Specify the port for the new printer
String[] port = new String[] { "COM1:" };

// Install the new printer on the local print server
PrintQueue clonedPrinter = myLocalPrintServer.InstallPrintQueue("My clone of " + sourcePrintQueue.Name, "Xerox WCP 35 PS", port, "WinPrint", myPrintProperties);
myLocalPrintServer.Commit();

// Report outcome
Console.WriteLine("{0} in {1} has been installed and shared as {2}", clonedPrinter.Name, clonedPrinter.Location, clonedPrinter.ShareName);
Console.WriteLine("Press Return to continue ...");
Console.ReadLine();
Dim myLocalPrintServer As New LocalPrintServer(PrintSystemDesiredAccess.AdministrateServer)
Dim sourcePrintQueue As PrintQueue = myLocalPrintServer.DefaultPrintQueue
Dim myPrintProperties As PrintPropertyDictionary = sourcePrintQueue.PropertiesCollection

' Share the new printer using Remove/Add methods
Dim [shared] As New PrintBooleanProperty("IsShared", True)
myPrintProperties.Remove("IsShared")
myPrintProperties.Add("IsShared", [shared])

' Give the new printer its share name using SetProperty method
Dim theShareName As New PrintStringProperty("ShareName", """Son of " & sourcePrintQueue.Name & """")
myPrintProperties.SetProperty("ShareName", theShareName)

' Specify the physical location of the new printer using Remove/Add methods
Dim theLocation As New PrintStringProperty("Location", "the supply room")
myPrintProperties.Remove("Location")
myPrintProperties.Add("Location", theLocation)

' Specify the port for the new printer
Dim port() As String = { "COM1:" }


' Install the new printer on the local print server
Dim clonedPrinter As PrintQueue = myLocalPrintServer.InstallPrintQueue("My clone of " & sourcePrintQueue.Name, "Xerox WCP 35 PS", port, "WinPrint", myPrintProperties)
myLocalPrintServer.Commit()

' Report outcome
Console.WriteLine("{0} in {1} has been installed and shared as {2}", clonedPrinter.Name, clonedPrinter.Location, clonedPrinter.ShareName)
Console.WriteLine("Press Return to continue ...")
Console.ReadLine()

Contoh berikut menunjukkan cara menggunakan kelas ini untuk menemukan properti pada waktu proses, dan jenis properti tersebut, dari objek sistem cetak, tanpa menggunakan pantulan.


// Enumerate the properties, and their types, of a queue without using Reflection
LocalPrintServer localPrintServer = new LocalPrintServer();
PrintQueue defaultPrintQueue = LocalPrintServer.GetDefaultPrintQueue();

PrintPropertyDictionary printQueueProperties = defaultPrintQueue.PropertiesCollection;

Console.WriteLine("These are the properties, and their types, of {0}, a {1}", defaultPrintQueue.Name, defaultPrintQueue.GetType().ToString() +"\n");

foreach (DictionaryEntry entry in printQueueProperties)
{
    PrintProperty property = (PrintProperty)entry.Value;

    if (property.Value != null)
    {
        Console.WriteLine(property.Name + "\t(Type: {0})", property.Value.GetType().ToString());
    }
}
Console.WriteLine("\n\nPress Return to continue...");
Console.ReadLine();

' Enumerate the properties, and their types, of a queue without using Reflection
Dim localPrintServer As New LocalPrintServer()
Dim defaultPrintQueue As PrintQueue = LocalPrintServer.GetDefaultPrintQueue()

Dim printQueueProperties As PrintPropertyDictionary = defaultPrintQueue.PropertiesCollection

Console.WriteLine("These are the properties, and their types, of {0}, a {1}", defaultPrintQueue.Name, defaultPrintQueue.GetType().ToString() + vbLf)

For Each entry As DictionaryEntry In printQueueProperties
    Dim [property] As PrintProperty = CType(entry.Value, PrintProperty)

    If [property].Value IsNot Nothing Then
        Console.WriteLine([property].Name & vbTab & "(Type: {0})", [property].Value.GetType().ToString())
    End If
Next entry
Console.WriteLine(vbLf & vbLf & "Press Return to continue...")
Console.ReadLine()

Keterangan

Koleksi mengambil bentuk Hashtable kamus. Properti Value masing-masing DictionaryEntry dalam koleksi adalah instans kelas yang berasal dari PrintProperty.

Konstruktor

PrintPropertyDictionary()

Menginisialisasi instans baru kelas PrintPropertyDictionary.

PrintPropertyDictionary(SerializationInfo, StreamingContext)

Menginisialisasi instans PrintPropertyDictionary baru kelas dan menyediakannya dengan yang ditentukan SerializationInfo dan StreamingContext.

Properti

comparer
Kedaluwarsa.
Kedaluwarsa.

Mendapatkan atau mengatur IComparer untuk digunakan untuk Hashtable.

(Diperoleh dari Hashtable)
Count

Mendapatkan jumlah pasangan kunci/nilai yang terkandung dalam Hashtable.

(Diperoleh dari Hashtable)
EqualityComparer

IEqualityComparer Mendapatkan untuk digunakan untuk Hashtable.

(Diperoleh dari Hashtable)
hcp
Kedaluwarsa.
Kedaluwarsa.

Mendapatkan atau mengatur objek yang dapat mengeluarkan kode hash.

(Diperoleh dari Hashtable)
IsFixedSize

Mendapatkan nilai yang menunjukkan apakah Hashtable memiliki ukuran tetap.

(Diperoleh dari Hashtable)
IsReadOnly

Mendapatkan nilai yang menunjukkan apakah Hashtable bersifat baca-saja.

(Diperoleh dari Hashtable)
IsSynchronized

Mendapatkan nilai yang menunjukkan apakah akses ke disinkronkan Hashtable (utas aman).

(Diperoleh dari Hashtable)
Item[Object]

Mendapatkan atau mengatur nilai yang terkait dengan kunci yang ditentukan.

(Diperoleh dari Hashtable)
Keys

Mendapatkan yang ICollection berisi kunci di Hashtable.

(Diperoleh dari Hashtable)
SyncRoot

Mendapatkan objek yang dapat digunakan untuk menyinkronkan akses ke Hashtable.

(Diperoleh dari Hashtable)
Values

Mendapatkan yang ICollection berisi nilai dalam Hashtable.

(Diperoleh dari Hashtable)

Metode

Add(Object, Object)

Menambahkan elemen dengan kunci dan nilai yang ditentukan ke Hashtabledalam .

(Diperoleh dari Hashtable)
Add(PrintProperty)

Menambahkan objek yang ditentukan (dari kelas yang berasal dari PrintProperty) ke dalam kamus.

Clear()

Menghapus semua elemen dari Hashtable.

(Diperoleh dari Hashtable)
Clone()

Membuat salinan dangkal dari Hashtable.

(Diperoleh dari Hashtable)
Contains(Object)

Menentukan apakah berisi Hashtable kunci tertentu.

(Diperoleh dari Hashtable)
ContainsKey(Object)

Menentukan apakah berisi Hashtable kunci tertentu.

(Diperoleh dari Hashtable)
ContainsValue(Object)

Menentukan apakah Hashtable berisi nilai tertentu.

(Diperoleh dari Hashtable)
CopyTo(Array, Int32)

Hashtable Menyalin elemen ke instans satu dimensi Array pada indeks yang ditentukan.

(Diperoleh dari Hashtable)
Dispose()

Merilis semua sumber daya yang sedang digunakan oleh PrintPropertyDictionary.

Dispose(Boolean)

Merilis sumber daya tidak terkelola yang sedang digunakan oleh PrintPropertyDictionary dan secara opsional merilis sumber daya terkelola.

Equals(Object)

Menentukan apakah objek yang ditentukan sama dengan objek saat ini.

(Diperoleh dari Object)
GetEnumerator()

Mengembalikan IDictionaryEnumerator yang berulang melalui Hashtable.

(Diperoleh dari Hashtable)
GetHash(Object)

Mengembalikan kode hash untuk kunci yang ditentukan.

(Diperoleh dari Hashtable)
GetHashCode()

Berfungsi sebagai fungsi hash default.

(Diperoleh dari Object)
GetObjectData(SerializationInfo, StreamingContext)

Mengisi SerializationInfo dengan data yang diperlukan untuk menserialisasikan PrintPropertyDictionary.

GetProperty(String)

Mendapatkan objek (dari kelas yang berasal dari PrintProperty) yang mewakili properti yang ditentukan.

GetType()

Mendapatkan instans Type saat ini.

(Diperoleh dari Object)
KeyEquals(Object, Object)

Membandingkan spesifik Object dengan kunci tertentu di Hashtable.

(Diperoleh dari Hashtable)
MemberwiseClone()

Membuat salinan dangkal dari yang saat ini Object.

(Diperoleh dari Object)
OnDeserialization(Object)

ISerializable Mengimplementasikan antarmuka dan meningkatkan peristiwa deserialisasi saat deserialisasi selesai.

Remove(Object)

Menghapus elemen dengan kunci yang ditentukan dari Hashtable.

(Diperoleh dari Hashtable)
SetProperty(String, PrintProperty)

Mengatur nilai atribut yang ditentukan ke objek kelas yang berasal dari PrintProperty.

ToString()

Mengembalikan string yang mewakili objek saat ini.

(Diperoleh dari Object)

Implementasi Antarmuka Eksplisit

IEnumerable.GetEnumerator()

Mengembalikan enumerator yang melakukan iterasi melalui koleksi.

(Diperoleh dari Hashtable)

Metode Ekstensi

Cast<TResult>(IEnumerable)

Mentransmisikan elemen dari IEnumerable ke jenis yang ditentukan.

OfType<TResult>(IEnumerable)

Memfilter elemen berdasarkan IEnumerable jenis tertentu.

AsParallel(IEnumerable)

Mengaktifkan paralelisasi kueri.

AsQueryable(IEnumerable)

Mengonversi menjadi IEnumerableIQueryable.

Berlaku untuk