PrintPropertyDictionary Class

 

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

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

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

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

NameDescription
System_CAPS_pubmethodPrintPropertyDictionary()

Initializes a new instance of the PrintPropertyDictionary class.

System_CAPS_protmethodPrintPropertyDictionary(SerializationInfo, StreamingContext)

Initializes a new instance of the PrintPropertyDictionary class and provides it with the specified SerializationInfo and StreamingContext.

NameDescription
System_CAPS_protpropertycomparer

Obsolete. Gets or sets the IComparer to use for the Hashtable.(Inherited from Hashtable.)

System_CAPS_pubpropertyCount

Gets the number of key/value pairs contained in the Hashtable.(Inherited from Hashtable.)

System_CAPS_protpropertyEqualityComparer

Gets the IEqualityComparer to use for the Hashtable.(Inherited from Hashtable.)

System_CAPS_protpropertyhcp

Obsolete. Gets or sets the object that can dispense hash codes.(Inherited from Hashtable.)

System_CAPS_pubpropertyIsFixedSize

Gets a value indicating whether the Hashtable has a fixed size.(Inherited from Hashtable.)

System_CAPS_pubpropertyIsReadOnly

Gets a value indicating whether the Hashtable is read-only.(Inherited from Hashtable.)

System_CAPS_pubpropertyIsSynchronized

Gets a value indicating whether access to the Hashtable is synchronized (thread safe).(Inherited from Hashtable.)

System_CAPS_pubpropertyItem[Object]

Gets or sets the value associated with the specified key.(Inherited from Hashtable.)

System_CAPS_pubpropertyKeys

Gets an ICollection containing the keys in the Hashtable.(Inherited from Hashtable.)

System_CAPS_pubpropertySyncRoot

Gets an object that can be used to synchronize access to the Hashtable.(Inherited from Hashtable.)

System_CAPS_pubpropertyValues

Gets an ICollection containing the values in the Hashtable.(Inherited from Hashtable.)

NameDescription
System_CAPS_pubmethodAdd(Object, Object)

Adds an element with the specified key and value into the Hashtable.(Inherited from Hashtable.)

System_CAPS_pubmethodAdd(PrintProperty)

Adds the specified object (of a class that is derived from PrintProperty) into the dictionary.

System_CAPS_pubmethodClear()

Removes all elements from the Hashtable.(Inherited from Hashtable.)

System_CAPS_pubmethodClone()

Creates a shallow copy of the Hashtable.(Inherited from Hashtable.)

System_CAPS_pubmethodContains(Object)

Determines whether the Hashtable contains a specific key.(Inherited from Hashtable.)

System_CAPS_pubmethodContainsKey(Object)

Determines whether the Hashtable contains a specific key.(Inherited from Hashtable.)

System_CAPS_pubmethodContainsValue(Object)

Determines whether the Hashtable contains a specific value.(Inherited from Hashtable.)

System_CAPS_pubmethodCopyTo(Array, Int32)

Copies the Hashtable elements to a one-dimensional Array instance at the specified index.(Inherited from Hashtable.)

System_CAPS_pubmethodDispose()

Releases all the resources that are being used by the PrintPropertyDictionary.

System_CAPS_protmethodDispose(Boolean)

Releases the unmanaged resources that are being used by the PrintPropertyDictionary and optionally releases the managed resources.

System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_protmethodFinalize()

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)

System_CAPS_pubmethodGetEnumerator()

Returns an IDictionaryEnumerator that iterates through the Hashtable.(Inherited from Hashtable.)

System_CAPS_protmethodGetHash(Object)

Returns the hash code for the specified key.(Inherited from Hashtable.)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetObjectData(SerializationInfo, StreamingContext)

Populates a SerializationInfo with the data that is needed to serialize the PrintPropertyDictionary.(Overrides Hashtable.GetObjectData(SerializationInfo, StreamingContext).)

System_CAPS_pubmethodGetProperty(String)

Gets the object (of a class that is derived from PrintProperty) that represents the specified property.

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_protmethodKeyEquals(Object, Object)

Compares a specific Object with a specific key in the Hashtable.(Inherited from Hashtable.)

System_CAPS_protmethodMemberwiseClone()

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_pubmethodOnDeserialization(Object)

Implements the ISerializable interface and raises the deserialization event when the deserialization is complete.(Overrides Hashtable.OnDeserialization(Object).)

System_CAPS_pubmethodRemove(Object)

Removes the element with the specified key from the Hashtable.(Inherited from Hashtable.)

System_CAPS_pubmethodSetProperty(String, PrintProperty)

Sets the value of the specified attribute to an object of a class that is derived from PrintProperty.

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

NameDescription
System_CAPS_pubinterfaceSystem_CAPS_privmethodIEnumerable.GetEnumerator()

Returns an enumerator that iterates through a collection.(Inherited from Hashtable.)

NameDescription
System_CAPS_pubmethodAsParallel()

Overloaded. Enables parallelization of a query.(Defined by ParallelEnumerable.)

System_CAPS_pubmethodAsQueryable()

Overloaded. Converts an IEnumerable to an IQueryable.(Defined by Queryable.)

System_CAPS_pubmethodCast<TResult>()

Casts the elements of an IEnumerable to the specified type.(Defined by Enumerable.)

System_CAPS_pubmethodOfType<TResult>()

Filters the elements of an IEnumerable based on a specified type.(Defined by Enumerable.)

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
Available since 3.0

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

Return to top
Show: