PrintPropertyDictionary Clase

Definición

Representa una colección de propiedades y valores que están asociados a un objeto del espacio de nombres System.Printing.

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
Herencia
PrintPropertyDictionary
Atributos
Implementaciones

Ejemplos

En el ejemplo siguiente se muestra cómo usar esta clase para instalar una segunda impresora que difiere en sus propiedades de una impresora existente solo en la ubicación, el puerto y el estado compartido.

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

En el ejemplo siguiente se muestra cómo usar esta clase para detectar en tiempo de ejecución las propiedades y los tipos de esas propiedades, de un objeto del sistema de impresión, sin usar la reflexión.


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

Comentarios

La colección adopta la forma de un Hashtable diccionario. La Value propiedad de cada DictionaryEntry una de las colecciones es una instancia de una clase derivada de PrintProperty.

Constructores

PrintPropertyDictionary()

Inicializa una nueva instancia de la clase PrintPropertyDictionary.

PrintPropertyDictionary(SerializationInfo, StreamingContext)

Inicializa una nueva instancia de la clase PrintPropertyDictionary y le proporciona los valores de SerializationInfo, StreamingContext especificados.

Propiedades

comparer
Obsoleto.
Obsoleto.

Obtiene o establece el IComparer que se utilizará para Hashtable.

(Heredado de Hashtable)
Count

Obtiene el número de pares clave-valor incluidos en Hashtable.

(Heredado de Hashtable)
EqualityComparer

Obtiene el IEqualityComparer que se va a utilizar para Hashtable.

(Heredado de Hashtable)
hcp
Obsoleto.
Obsoleto.

Obtiene o establece el objeto que puede dispensar códigos hash.

(Heredado de Hashtable)
IsFixedSize

Obtiene un valor que indica si la interfaz Hashtable tiene un tamaño fijo.

(Heredado de Hashtable)
IsReadOnly

Obtiene un valor que indica si Hashtable es de solo lectura.

(Heredado de Hashtable)
IsSynchronized

Obtiene un valor que indica si el acceso a la interfaz Hashtable está sincronizado (es seguro para subprocesos).

(Heredado de Hashtable)
Item[Object]

Obtiene o establece el valor asociado a la clave especificada.

(Heredado de Hashtable)
Keys

Obtiene una interfaz ICollection que contiene las claves de Hashtable.

(Heredado de Hashtable)
SyncRoot

Obtiene un objeto que se puede usar para sincronizar el acceso a Hashtable.

(Heredado de Hashtable)
Values

Obtiene una interfaz ICollection que contiene los valores de la interfaz Hashtable.

(Heredado de Hashtable)

Métodos

Add(Object, Object)

Agrega un elemento con la clave y el valor especificados a Hashtable.

(Heredado de Hashtable)
Add(PrintProperty)

Agrega el objeto especificado (de una clase derivada de PrintProperty) al diccionario.

Clear()

Quita todos los elementos de Hashtable.

(Heredado de Hashtable)
Clone()

Crea una copia superficial de la colección Hashtable.

(Heredado de Hashtable)
Contains(Object)

Determina si Hashtable contiene una clave específica.

(Heredado de Hashtable)
ContainsKey(Object)

Determina si Hashtable contiene una clave específica.

(Heredado de Hashtable)
ContainsValue(Object)

Determina si Hashtable contiene un valor específico.

(Heredado de Hashtable)
CopyTo(Array, Int32)

Copia los elementos de Hashtable a una instancia unidimensional de Array en el índice especificado.

(Heredado de Hashtable)
Dispose()

Libera todos los recursos utilizados por PrintPropertyDictionary.

Dispose(Boolean)

Libera los recursos no administrados utilizados por PrintPropertyDictionary y, de forma opcional, libera los recursos administrados.

Equals(Object)

Determina si el objeto especificado es igual que el objeto actual.

(Heredado de Object)
GetEnumerator()

Devuelve un objeto IDictionaryEnumerator que itera a través del objeto Hashtable.

(Heredado de Hashtable)
GetHash(Object)

Devuelve el código hash de la clave especificada.

(Heredado de Hashtable)
GetHashCode()

Sirve como la función hash predeterminada.

(Heredado de Object)
GetObjectData(SerializationInfo, StreamingContext)

Rellena un objeto SerializationInfo con los datos necesarios para serializar PrintPropertyDictionary.

GetProperty(String)

Obtiene el objeto (de una clase derivada de PrintProperty) que representa la propiedad especificada.

GetType()

Obtiene el Type de la instancia actual.

(Heredado de Object)
KeyEquals(Object, Object)

Compara un Object específico con una clave concreta en Hashtable.

(Heredado de Hashtable)
MemberwiseClone()

Crea una copia superficial del Object actual.

(Heredado de Object)
OnDeserialization(Object)

Implementa la interfaz ISerializable y genera el evento de deserialización cuando esta ha finalizado.

Remove(Object)

Quita el elemento con la clave especificada de Hashtable.

(Heredado de Hashtable)
SetProperty(String, PrintProperty)

Establece el valor del atributo especificado en un objeto de una clase derivada de PrintProperty.

ToString()

Devuelve una cadena que representa el objeto actual.

(Heredado de Object)

Implementaciones de interfaz explícitas

IEnumerable.GetEnumerator()

Devuelve un enumerador que recorre en iteración una colección.

(Heredado de Hashtable)

Métodos de extensión

Cast<TResult>(IEnumerable)

Convierte los elementos de IEnumerable en el tipo especificado.

OfType<TResult>(IEnumerable)

Filtra los elementos de IEnumerable en función de un tipo especificado.

AsParallel(IEnumerable)

Habilita la paralelización de una consulta.

AsQueryable(IEnumerable)

Convierte una interfaz IEnumerable en IQueryable.

Se aplica a