PrintPropertyDictionary Třída

Definice

Představuje kolekci vlastností a hodnot, které jsou přidruženy k objektu System.Printing v oboru názvů.

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
public class PrintPropertyDictionary : System.Collections.Hashtable, IDisposable, System.Runtime.Serialization.IDeserializationCallback, System.Runtime.Serialization.ISerializable
[<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
Dědičnost
PrintPropertyDictionary
Atributy
Implementuje

Příklady

Následující příklad ukazuje, jak pomocí této třídy nainstalovat druhou tiskárnu, která se liší ve svých vlastnostech od existující tiskárny pouze v umístění, portu a sdíleném stavu.

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()

Následující příklad ukazuje, jak pomocí této třídy zjistit za běhu vlastnosti a typy těchto vlastností tiskového systémového objektu bez použití reflexe.


// 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()

Poznámky

Kolekce má podobu slovníku Hashtable . Vlastnost Value každého DictionaryEntry v kolekci je instance třídy, která je odvozena z PrintProperty.

Konstruktory

Name Description
PrintPropertyDictionary()

Inicializuje novou instanci PrintPropertyDictionary třídy.

PrintPropertyDictionary(SerializationInfo, StreamingContext)

Inicializuje novou instanci PrintPropertyDictionary třídy a poskytuje ji se zadaným SerializationInfo a StreamingContext.

Vlastnosti

Name Description
comparer
Zastaralé.
Zastaralé.

Získá nebo nastaví IComparer použití pro Hashtable.

(Zděděno od Hashtable)
Count

Získá počet párů klíč/hodnota obsažených v objektu Hashtable.

(Zděděno od Hashtable)
EqualityComparer

IEqualityComparer Získá použít pro Hashtable.

(Zděděno od Hashtable)
hcp
Zastaralé.
Zastaralé.

Získá nebo nastaví objekt, který může vydávat kódy hash.

(Zděděno od Hashtable)
IsFixedSize

Získá hodnotu určující, zda Hashtable má pevnou velikost.

(Zděděno od Hashtable)
IsReadOnly

Získá hodnotu určující, zda je jen pro Hashtable čtení.

(Zděděno od Hashtable)
IsSynchronized

Získá hodnotu označující, zda je přístup k Hashtable této synchronizaci (bezpečné vlákno).

(Zděděno od Hashtable)
Item[Object]

Získá nebo nastaví hodnotu přidruženou k zadanému klíči.

(Zděděno od Hashtable)
Keys

ICollection Získá obsahující klíče v objektu Hashtable.

(Zděděno od Hashtable)
SyncRoot

Získá objekt, který lze použít k synchronizaci přístupu k Hashtable.

(Zděděno od Hashtable)
Values

ICollection Získá obsahující hodnoty v objektu Hashtable.

(Zděděno od Hashtable)

Metody

Name Description
Add(Object, Object)

Přidá prvek se zadaným klíčem a hodnotou do objektu Hashtable.

(Zděděno od Hashtable)
Add(PrintProperty)

Přidá zadaný objekt (třídy odvozené z PrintProperty) do slovníku.

Clear()

Odebere všechny prvky z objektu Hashtable.

(Zděděno od Hashtable)
Clone()

Vytvoří mělkou kopii Hashtable.

(Zděděno od Hashtable)
Contains(Object)

Určuje, zda Hashtable obsahuje konkrétní klíč.

(Zděděno od Hashtable)
ContainsKey(Object)

Určuje, zda Hashtable obsahuje konkrétní klíč.

(Zděděno od Hashtable)
ContainsValue(Object)

Určuje, zda Hashtable obsahuje konkrétní hodnotu.

(Zděděno od Hashtable)
CopyTo(Array, Int32)

Hashtable Zkopíruje prvky do jednorozměrné Array instance v zadaném indexu.

(Zděděno od Hashtable)
Dispose()

Uvolní všechny prostředky používané nástrojem PrintPropertyDictionary.

Dispose(Boolean)

Uvolní nespravované prostředky, které používají PrintPropertyDictionary a volitelně uvolní spravované prostředky.

Equals(Object)

Určuje, zda je zadaný objekt roven aktuálnímu objektu.

(Zděděno od Object)
GetEnumerator()

IDictionaryEnumerator Vrátí iteruje přes Hashtable.

(Zděděno od Hashtable)
GetHash(Object)

Vrátí kód hash pro zadaný klíč.

(Zděděno od Hashtable)
GetHashCode()

Slouží jako výchozí funkce hash.

(Zděděno od Object)
GetObjectData(SerializationInfo, StreamingContext)

Naplní SerializationInfo data, která jsou potřebná k serializaci PrintPropertyDictionary.

GetProperty(String)

Získá objekt (třídy, která je odvozena z PrintProperty), který představuje zadanou vlastnost.

GetType()

Získá Type aktuální instance.

(Zděděno od Object)
KeyEquals(Object, Object)

Porovná konkrétní Object klíč s konkrétním klíčem v sadě Hashtable.

(Zděděno od Hashtable)
MemberwiseClone()

Vytvoří mělkou kopii aktuálního Object.

(Zděděno od Object)
OnDeserialization(Object)

Implementuje ISerializable rozhraní a vyvolá deserializační událost po dokončení deserializace.

Remove(Object)

Odebere prvek se zadaným klíčem z objektu Hashtable.

(Zděděno od Hashtable)
SetProperty(String, PrintProperty)

Nastaví hodnotu zadaného atributu na objekt třídy, která je odvozena z PrintProperty.

ToString()

Vrátí řetězec, který představuje aktuální objekt.

(Zděděno od Object)

Explicitní implementace rozhraní

Name Description
IEnumerable.GetEnumerator()

Vrátí enumerátor, který iteruje kolekcí.

(Zděděno od Hashtable)

Metody rozšíření

Name Description
AsParallel(IEnumerable)

Umožňuje paralelizaci dotazu.

AsQueryable(IEnumerable)

Převede IEnumerable na IQueryable.

Cast<TResult>(IEnumerable)

Přetypuje prvky IEnumerable na zadaný typ.

OfType<TResult>(IEnumerable)

Filtruje prvky IEnumerable na základě zadaného typu.

Platí pro