Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

PrintPropertyDictionary Class

Represents a collection of properties and values that are associated with an object in the System.Printing namespace.

System.Object
  System.Collections.Hashtable
    System.Printing.IndexedProperties.PrintPropertyDictionary

Namespace:  System.Printing.IndexedProperties
Assembly:  System.Printing (in System.Printing.dll)

[SerializableAttribute]
public class PrintPropertyDictionary : Hashtable, 
	ISerializable, IDeserializationCallback, IDisposable

The PrintPropertyDictionary type exposes the following members.

  NameDescription
Public methodPrintPropertyDictionary()Initializes a new instance of the PrintPropertyDictionary class.
Protected methodPrintPropertyDictionary(SerializationInfo, StreamingContext)Initializes a new instance of the PrintPropertyDictionary class and provides it with the specified SerializationInfo and StreamingContext.
Top

  NameDescription
Protected propertycomparer Obsolete. Gets or sets the IComparer to use for the Hashtable. (Inherited from Hashtable.)
Public propertyCountGets the number of key/value pairs contained in the Hashtable. (Inherited from Hashtable.)
Protected propertyEqualityComparerGets the IEqualityComparer to use for the Hashtable. (Inherited from Hashtable.)
Protected propertyhcp Obsolete. Gets or sets the object that can dispense hash codes. (Inherited from Hashtable.)
Public propertyIsFixedSizeGets a value indicating whether the Hashtable has a fixed size. (Inherited from Hashtable.)
Public propertyIsReadOnlyGets a value indicating whether the Hashtable is read-only. (Inherited from Hashtable.)
Public propertyIsSynchronizedGets a value indicating whether access to the Hashtable is synchronized (thread safe). (Inherited from Hashtable.)
Public propertyItemGets or sets the value associated with the specified key. (Inherited from Hashtable.)
Public propertyKeysGets an ICollection containing the keys in the Hashtable. (Inherited from Hashtable.)
Public propertySyncRootGets an object that can be used to synchronize access to the Hashtable. (Inherited from Hashtable.)
Public propertyValuesGets an ICollection containing the values in the Hashtable. (Inherited from Hashtable.)
Top

  NameDescription
Public methodAdd(PrintProperty)Adds the specified object (of a class that is derived from PrintProperty) into the dictionary.
Public methodAdd(Object, Object)Adds an element with the specified key and value into the Hashtable. (Inherited from Hashtable.)
Public methodClearRemoves all elements from the Hashtable. (Inherited from Hashtable.)
Public methodCloneCreates a shallow copy of the Hashtable. (Inherited from Hashtable.)
Public methodContainsDetermines whether the Hashtable contains a specific key. (Inherited from Hashtable.)
Public methodContainsKeyDetermines whether the Hashtable contains a specific key. (Inherited from Hashtable.)
Public methodContainsValueDetermines whether the Hashtable contains a specific value. (Inherited from Hashtable.)
Public methodCopyToCopies the Hashtable elements to a one-dimensional Array instance at the specified index. (Inherited from Hashtable.)
Public methodDispose()Releases all the resources that are being used by the PrintPropertyDictionary.
Protected methodDispose(Boolean)Releases the unmanaged resources that are being used by the PrintPropertyDictionary and optionally releases the managed resources.
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetEnumeratorReturns an IDictionaryEnumerator that iterates through the Hashtable. (Inherited from Hashtable.)
Protected methodGetHashReturns the hash code for the specified key. (Inherited from Hashtable.)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetObjectDataPopulates a SerializationInfo with the data that is needed to serialize the PrintPropertyDictionary. (Overrides Hashtable.GetObjectData(SerializationInfo, StreamingContext).)
Public methodGetPropertyGets the object (of a class that is derived from PrintProperty) that represents the specified property.
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodKeyEqualsCompares a specific Object with a specific key in the Hashtable. (Inherited from Hashtable.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodOnDeserializationImplements the ISerializable interface and raises the deserialization event when the deserialization is complete. (Overrides Hashtable.OnDeserialization(Object).)
Public methodRemoveRemoves the element with the specified key from the Hashtable. (Inherited from Hashtable.)
Public methodSetPropertySets the value of the specified attribute to an object of a class that is derived from PrintProperty.
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

  NameDescription
Explicit interface implemetationPrivate methodIEnumerable.GetEnumeratorReturns an enumerator that iterates through a collection. (Inherited from Hashtable.)
Top

The collection takes the form of a Hashtable dictionary. The Value property of each DictionaryEntry in the collection is an instance of a class that is derived from PrintProperty.

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

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

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2014 Microsoft