PrintPropertyDictionary PrintPropertyDictionary PrintPropertyDictionary PrintPropertyDictionary Class

Definition

Stellt eine Auflistung von Eigenschaften und Werten dar, die einem Objekt im System.Printing-Namespace zugeordnet sind.Represents a collection of properties and values that are associated with an object in the System.Printing namespace.

public ref class PrintPropertyDictionary : System::Collections::Hashtable, IDisposable
[System.Serializable]
public class PrintPropertyDictionary : System.Collections.Hashtable, IDisposable
type PrintPropertyDictionary = class
    inherit Hashtable
    interface ISerializable
    interface IDeserializationCallback
    interface IDisposable
Public Class PrintPropertyDictionary
Inherits Hashtable
Implements IDisposable
Vererbung
PrintPropertyDictionaryPrintPropertyDictionaryPrintPropertyDictionaryPrintPropertyDictionary
Attribute
Implementiert

Beispiele

Im folgenden Beispiel wird gezeigt, wie diese Klasse verwendet wird, um einen zweiten Drucker zu installieren, der sich in seinen Eigenschaften von einem vorhandenen Drucker nur an Speicherort, Port und freigegebenen Status unterscheidet.The following example shows how to use this class to install a second printer that differs in its properties from an existing printer only in location, port, and shared status.

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

Im folgenden Beispiel wird gezeigt, wie diese Klasse verwendet werden kann, um zur Laufzeit die Eigenschaften und die Typen dieser Eigenschaften eines Drucksystem Objekts ohne Reflektion zu ermitteln.The following example shows how to use this class to discover at run time the properties, and the types of those properties, of a print system object, without using reflection.


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

Hinweise

Die-Auflistung hat die Form Hashtable eines Wörterbuchs.The collection takes the form of a Hashtable dictionary. Die Value -Eigenschaft jedes DictionaryEntry in der-Auflistung ist eine Instanz einer Klasse, die von PrintPropertyabgeleitet wird.The Value property of each DictionaryEntry in the collection is an instance of a class that is derived from PrintProperty.

Konstruktoren

PrintPropertyDictionary() PrintPropertyDictionary() PrintPropertyDictionary() PrintPropertyDictionary()

Initialisiert eine neue Instanz der PrintPropertyDictionary-Klasse.Initializes a new instance of the PrintPropertyDictionary class.

PrintPropertyDictionary(SerializationInfo, StreamingContext) PrintPropertyDictionary(SerializationInfo, StreamingContext) PrintPropertyDictionary(SerializationInfo, StreamingContext) PrintPropertyDictionary(SerializationInfo, StreamingContext)

Initialisiert eine neue Instanz der PrintPropertyDictionary-Klasse und stellt sie mit den angegebenen SerializationInfo und dem angegebenen StreamingContext bereit.Initializes a new instance of the PrintPropertyDictionary class and provides it with the specified SerializationInfo and StreamingContext.

Methoden

Add(Object, Object) Add(Object, Object) Add(Object, Object) Add(Object, Object)

Fügt dem Hashtable ein Element mit dem angegebenen Schlüssel und Wert hinzu.Adds an element with the specified key and value into the Hashtable.

(Inherited from Hashtable)
Add(PrintProperty) Add(PrintProperty) Add(PrintProperty) Add(PrintProperty)

Fügt dem Wörterbuch das angegebene Objekt (aus einer Klasse, die von der PrintProperty abgeleitet ist) hinzu.Adds the specified object (of a class that is derived from PrintProperty) into the dictionary.

Clear() Clear() Clear() Clear()

Entfernt alle Elemente aus der Hashtable.Removes all elements from the Hashtable.

(Inherited from Hashtable)
Clone() Clone() Clone() Clone()

Erstellt eine flache Kopie von Hashtable.Creates a shallow copy of the Hashtable.

(Inherited from Hashtable)
Contains(Object) Contains(Object) Contains(Object) Contains(Object)

Stellt fest, ob der Hashtable einen bestimmten Schlüssel enthält.Determines whether the Hashtable contains a specific key.

(Inherited from Hashtable)
ContainsKey(Object) ContainsKey(Object) ContainsKey(Object) ContainsKey(Object)

Stellt fest, ob der Hashtable einen bestimmten Schlüssel enthält.Determines whether the Hashtable contains a specific key.

(Inherited from Hashtable)
ContainsValue(Object) ContainsValue(Object) ContainsValue(Object) ContainsValue(Object)

Ermittelt, ob die Hashtable einen bestimmten Wert enthält.Determines whether the Hashtable contains a specific value.

(Inherited from Hashtable)
CopyTo(Array, Int32) CopyTo(Array, Int32) CopyTo(Array, Int32) CopyTo(Array, Int32)

Kopiert die Hashtable-Elemente an den angegebenen Index in einer eindimensionalen Array-Instanz.Copies the Hashtable elements to a one-dimensional Array instance at the specified index.

(Inherited from Hashtable)
Dispose() Dispose() Dispose() Dispose()

Gibt alle vom PrintPropertyDictionary verwendeten Ressourcen frei.Releases all the resources that are being used by the PrintPropertyDictionary.

Dispose(Boolean) Dispose(Boolean) Dispose(Boolean) Dispose(Boolean)

Gibt die vom PrintPropertyDictionary verwendeten nicht verwalteten Ressourcen und optional die verwalteten Ressourcen frei.Releases the unmanaged resources that are being used by the PrintPropertyDictionary and optionally releases the managed resources.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Bestimmt, ob das angegebene Objekt mit dem aktuellen Objekt identisch ist.Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetEnumerator() GetEnumerator() GetEnumerator() GetEnumerator()

Gibt einen IDictionaryEnumerator zurück, der das Hashtable durchläuft.Returns an IDictionaryEnumerator that iterates through the Hashtable.

(Inherited from Hashtable)
GetHash(Object) GetHash(Object) GetHash(Object) GetHash(Object)

Gibt den Hashcode für den angegebenen Schlüssel zurück.Returns the hash code for the specified key.

(Inherited from Hashtable)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Fungiert als Standardhashfunktion.Serves as the default hash function.

(Inherited from Object)
GetObjectData(SerializationInfo, StreamingContext) GetObjectData(SerializationInfo, StreamingContext) GetObjectData(SerializationInfo, StreamingContext) GetObjectData(SerializationInfo, StreamingContext)

Füllt eine SerializationInfo mit den zum Serialisieren des PrintPropertyDictionary erforderlichen Daten.Populates a SerializationInfo with the data that is needed to serialize the PrintPropertyDictionary.

GetProperty(String) GetProperty(String) GetProperty(String) GetProperty(String)

Ruft das Objekt (aus einer Klasse, die von der PrintProperty abgeleitet ist) ab, das die angegebene Eigenschaft darstellt.Gets the object (of a class that is derived from PrintProperty) that represents the specified property.

GetType() GetType() GetType() GetType()

Ruft den Type der aktuellen Instanz ab.Gets the Type of the current instance.

(Inherited from Object)
KeyEquals(Object, Object) KeyEquals(Object, Object) KeyEquals(Object, Object) KeyEquals(Object, Object)

Vergleicht ein bestimmtes Object mit einem bestimmten Schlüssel in Hashtable.Compares a specific Object with a specific key in the Hashtable.

(Inherited from Hashtable)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Erstellt eine flache Kopie des aktuellen Object.Creates a shallow copy of the current Object.

(Inherited from Object)
OnDeserialization(Object) OnDeserialization(Object) OnDeserialization(Object) OnDeserialization(Object)

Implementiert die ISerializable-Schnittstelle und löst das Deserialisierungsereignis aus, sobald die Deserialisierung abgeschlossen ist.Implements the ISerializable interface and raises the deserialization event when the deserialization is complete.

Remove(Object) Remove(Object) Remove(Object) Remove(Object)

Entfernt das Element mit dem angegebenen Schlüssel aus dem Hashtable.Removes the element with the specified key from the Hashtable.

(Inherited from Hashtable)
SetProperty(String, PrintProperty) SetProperty(String, PrintProperty) SetProperty(String, PrintProperty) SetProperty(String, PrintProperty)

Legt den Wert des angegebenen Attributs auf ein Objekt einer Klasse fest, die von der PrintProperty abgeleitet ist.Sets the value of the specified attribute to an object of a class that is derived from PrintProperty.

ToString() ToString() ToString() ToString()

Gibt eine Zeichenfolge zurück, die das aktuelle Objekt darstellt.Returns a string that represents the current object.

(Inherited from Object)

Eigenschaften

comparer comparer comparer comparer

Ruft den für die IComparer zu verwendenden Hashtable ab oder legt diesen fest.Gets or sets the IComparer to use for the Hashtable.

(Inherited from Hashtable)
Count Count Count Count

Ruft die Anzahl der Schlüssel-Wert-Paare im Hashtable ab.Gets the number of key/value pairs contained in the Hashtable.

(Inherited from Hashtable)
EqualityComparer EqualityComparer EqualityComparer EqualityComparer

Ruft den für die IEqualityComparer zu verwendenden Hashtable ab.Gets the IEqualityComparer to use for the Hashtable.

(Inherited from Hashtable)
hcp hcp hcp hcp

Ruft das Objekt ab, das Hashcodes verteilen kann, oder legt dieses fest.Gets or sets the object that can dispense hash codes.

(Inherited from Hashtable)
IsFixedSize IsFixedSize IsFixedSize IsFixedSize

Ruft einen Wert ab, der angibt, ob das Hashtable eine feste Größe aufweist.Gets a value indicating whether the Hashtable has a fixed size.

(Inherited from Hashtable)
IsReadOnly IsReadOnly IsReadOnly IsReadOnly

Ruft einen Wert ab, der angibt, ob das Hashtable schreibgeschützt ist.Gets a value indicating whether the Hashtable is read-only.

(Inherited from Hashtable)
IsSynchronized IsSynchronized IsSynchronized IsSynchronized

Ruft einen Wert ab, der angibt, ob der Zugriff auf die Hashtable synchronisiert (threadsicher) ist.Gets a value indicating whether access to the Hashtable is synchronized (thread safe).

(Inherited from Hashtable)
Item[Object] Item[Object] Item[Object] Item[Object]

Ruft den Wert ab, der dem angegebenen Schlüssel zugeordnet ist, oder legt diesen fest.Gets or sets the value associated with the specified key.

(Inherited from Hashtable)
Keys Keys Keys Keys

Ruft eine ICollection ab, die die Schlüssel im Hashtable enthält.Gets an ICollection containing the keys in the Hashtable.

(Inherited from Hashtable)
SyncRoot SyncRoot SyncRoot SyncRoot

Ruft ein Objekt ab, mit dem der Zugriff auf Hashtable synchronisiert werden kann.Gets an object that can be used to synchronize access to the Hashtable.

(Inherited from Hashtable)
Values Values Values Values

Ruft eine ICollection ab, die die Werte im Hashtable enthält.Gets an ICollection containing the values in the Hashtable.

(Inherited from Hashtable)

Explizite Schnittstellenimplementierungen

IEnumerable.GetEnumerator() IEnumerable.GetEnumerator() IEnumerable.GetEnumerator() IEnumerable.GetEnumerator()

Gibt einen Enumerator zurück, der eine Auflistung durchläuft.Returns an enumerator that iterates through a collection.

(Inherited from Hashtable)

Erweiterungsmethoden

Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable)

Wandelt die Elemente eines IEnumerable in den angegebenen Typ umCasts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable)

Filtert die Elemente eines IEnumerable anhand eines angegebenen TypsFilters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable)

Ermöglicht die Parallelisierung einer Abfrage.Enables parallelization of a query.

AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable)

Konvertiert einen IEnumerable in einen IQueryable.Converts an IEnumerable to an IQueryable.

Gilt für: