PrintPropertyDictionary Klasa

Definicja

Reprezentuje kolekcję właściwości i wartości skojarzonych z obiektem System.Printing w przestrzeni nazw.

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
Dziedziczenie
PrintPropertyDictionary
Atrybuty
Implementuje

Przykłady

W poniższym przykładzie pokazano, jak użyć tej klasy do zainstalowania drugiej drukarki, która różni się w jego właściwościach od istniejącej drukarki tylko w lokalizacji, porcie i stanie udostępnionym.

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

W poniższym przykładzie pokazano, jak używać tej klasy do odnajdywania w czasie wykonywania właściwości oraz typów tych właściwości obiektu systemu wydruku bez użycia odbicia.


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

Uwagi

Kolekcja ma postać słownika Hashtable . Właściwość Value każdej DictionaryEntry z kolekcji jest wystąpieniem klasy, która pochodzi z PrintPropertyklasy .

Konstruktory

PrintPropertyDictionary()

Inicjuje nowe wystąpienie klasy PrintPropertyDictionary.

PrintPropertyDictionary(SerializationInfo, StreamingContext)

Inicjuje PrintPropertyDictionary nowe wystąpienie klasy i udostępnia je z określonymi SerializationInfo elementami i StreamingContext.

Właściwości

comparer
Przestarzałe.
Przestarzałe.

Pobiera lub ustawia parametr IComparer , który ma być używany dla polecenia Hashtable.

(Odziedziczone po Hashtable)
Count

Pobiera liczbę par klucz/wartość zawartych w elemecie Hashtable.

(Odziedziczone po Hashtable)
EqualityComparer

Pobiera element IEqualityComparer do użycia dla polecenia Hashtable.

(Odziedziczone po Hashtable)
hcp
Przestarzałe.
Przestarzałe.

Pobiera lub ustawia obiekt, który może wydać kody skrótów.

(Odziedziczone po Hashtable)
IsFixedSize

Pobiera wartość wskazującą, czy rozmiar Hashtable ma stały rozmiar.

(Odziedziczone po Hashtable)
IsReadOnly

Pobiera wartość wskazującą, czy kolekcja Hashtable jest przeznaczona tylko do odczytu.

(Odziedziczone po Hashtable)
IsSynchronized

Pobiera wartość wskazującą, czy dostęp do elementu Hashtable jest synchronizowany (bezpieczny wątek).

(Odziedziczone po Hashtable)
Item[Object]

Pobiera lub ustawia wartość skojarzona z określonym kluczem.

(Odziedziczone po Hashtable)
Keys

Pobiera element ICollection zawierający klucze w elemecie Hashtable.

(Odziedziczone po Hashtable)
SyncRoot

Pobiera obiekt, który może służyć do synchronizowania dostępu do obiektu Hashtable.

(Odziedziczone po Hashtable)
Values

Pobiera element ICollection zawierający wartości w obiekcie Hashtable.

(Odziedziczone po Hashtable)

Metody

Add(Object, Object)

Dodaje element z określonym kluczem i wartością do elementu Hashtable.

(Odziedziczone po Hashtable)
Add(PrintProperty)

Dodaje określony obiekt (klasy pochodzącej z PrintPropertyklasy ) do słownika.

Clear()

Usuwa wszystkie elementy z obiektu Hashtable.

(Odziedziczone po Hashtable)
Clone()

Tworzy płytkią kopię elementu Hashtable.

(Odziedziczone po Hashtable)
Contains(Object)

Określa, czy element Hashtable zawiera określony klucz.

(Odziedziczone po Hashtable)
ContainsKey(Object)

Określa, czy element Hashtable zawiera określony klucz.

(Odziedziczone po Hashtable)
ContainsValue(Object)

Określa, czy element Hashtable zawiera określoną wartość.

(Odziedziczone po Hashtable)
CopyTo(Array, Int32)

Kopiuje Hashtable elementy do wystąpienia jednowymiarowego Array w określonym indeksie.

(Odziedziczone po Hashtable)
Dispose()

Zwalnia wszystkie zasoby, które są używane przez PrintPropertyDictionaryprogram .

Dispose(Boolean)

Zwalnia niezarządzane zasoby, które są używane przez PrintPropertyDictionary program i opcjonalnie zwalnia zarządzane zasoby.

Equals(Object)

Określa, czy dany obiekt jest taki sam, jak bieżący obiekt.

(Odziedziczone po Object)
GetEnumerator()

IDictionaryEnumerator Zwraca iterowanie Hashtableprzez element .

(Odziedziczone po Hashtable)
GetHash(Object)

Zwraca kod skrótu dla określonego klucza.

(Odziedziczone po Hashtable)
GetHashCode()

Służy jako domyślna funkcja skrótu.

(Odziedziczone po Object)
GetObjectData(SerializationInfo, StreamingContext)

Wypełnia element SerializationInfo danymi wymaganymi do serializacji elementu PrintPropertyDictionary.

GetProperty(String)

Pobiera obiekt (klasy, która pochodzi z PrintPropertyklasy ), która reprezentuje określoną właściwość.

GetType()

Type Pobiera bieżące wystąpienie.

(Odziedziczone po Object)
KeyEquals(Object, Object)

Porównuje określony klucz Object z określonym kluczem w elemecie Hashtable.

(Odziedziczone po Hashtable)
MemberwiseClone()

Tworzy płytkią kopię bieżącego Objectelementu .

(Odziedziczone po Object)
OnDeserialization(Object)

Implementuje ISerializable interfejs i zgłasza zdarzenie deserializacji po zakończeniu deserializacji.

Remove(Object)

Usuwa element z określonym kluczem z elementu Hashtable.

(Odziedziczone po Hashtable)
SetProperty(String, PrintProperty)

Ustawia wartość określonego atrybutu na obiekt klasy, która pochodzi z PrintPropertyklasy .

ToString()

Zwraca ciąg reprezentujący bieżący obiekt.

(Odziedziczone po Object)

Jawne implementacje interfejsu

IEnumerable.GetEnumerator()

Zwraca moduł wyliczający, który iteruje po kolekcji.

(Odziedziczone po Hashtable)

Metody rozszerzania

Cast<TResult>(IEnumerable)

Rzutuje elementy elementu IEnumerable na określony typ.

OfType<TResult>(IEnumerable)

Filtruje elementy elementu IEnumerable na podstawie określonego typu.

AsParallel(IEnumerable)

Umożliwia równoległość zapytania.

AsQueryable(IEnumerable)

Konwertuje element IEnumerable na .IQueryable

Dotyczy