PrintPropertyDictionary Class
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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
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
- Inheritance
- Attributes
- Implements
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()
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()
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.
Print |
Initializes a new instance of the PrintPropertyDictionary class. |
Print |
Initializes a new instance of the PrintPropertyDictionary class and provides it with the specified SerializationInfo and StreamingContext. |
comparer |
Obsolete.
Obsolete.
Gets or sets the IComparer to use for the Hashtable. (Inherited from Hashtable) |
Count |
Gets the number of key/value pairs contained in the Hashtable. (Inherited from Hashtable) |
Equality |
Gets the IEqualityComparer to use for the Hashtable. (Inherited from Hashtable) |
hcp |
Obsolete.
Obsolete.
Gets or sets the object that can dispense hash codes. (Inherited from Hashtable) |
Is |
Gets a value indicating whether the Hashtable has a fixed size. (Inherited from Hashtable) |
Is |
Gets a value indicating whether the Hashtable is read-only. (Inherited from Hashtable) |
Is |
Gets a value indicating whether access to the Hashtable is synchronized (thread safe). (Inherited from Hashtable) |
Item[Object] |
Gets or sets the value associated with the specified key. (Inherited from Hashtable) |
Keys |
Gets an ICollection containing the keys in the Hashtable. (Inherited from Hashtable) |
Sync |
Gets an object that can be used to synchronize access to the Hashtable. (Inherited from Hashtable) |
Values |
Gets an ICollection containing the values in the Hashtable. (Inherited from Hashtable) |
Add(Object, Object) |
Adds an element with the specified key and value into the Hashtable. (Inherited from Hashtable) |
Add(Print |
Adds the specified object (of a class that is derived from PrintProperty) into the dictionary. |
Clear() |
Removes all elements from the Hashtable. (Inherited from Hashtable) |
Clone() |
Creates a shallow copy of the Hashtable. (Inherited from Hashtable) |
Contains(Object) |
Determines whether the Hashtable contains a specific key. (Inherited from Hashtable) |
Contains |
Determines whether the Hashtable contains a specific key. (Inherited from Hashtable) |
Contains |
Determines whether the Hashtable contains a specific value. (Inherited from Hashtable) |
Copy |
Copies the Hashtable elements to a one-dimensional Array instance at the specified index. (Inherited from Hashtable) |
Dispose() |
Releases all the resources that are being used by the PrintPropertyDictionary. |
Dispose(Boolean) |
Releases the unmanaged resources that are being used by the PrintPropertyDictionary and optionally releases the managed resources. |
Equals(Object) |
Determines whether the specified object is equal to the current object. (Inherited from Object) |
Get |
Returns an IDictionaryEnumerator that iterates through the Hashtable. (Inherited from Hashtable) |
Get |
Returns the hash code for the specified key. (Inherited from Hashtable) |
Get |
Serves as the default hash function. (Inherited from Object) |
Get |
Populates a SerializationInfo with the data that is needed to serialize the PrintPropertyDictionary. |
Get |
Gets the object (of a class that is derived from PrintProperty) that represents the specified property. |
Get |
Gets the Type of the current instance. (Inherited from Object) |
Key |
Compares a specific Object with a specific key in the Hashtable. (Inherited from Hashtable) |
Memberwise |
Creates a shallow copy of the current Object. (Inherited from Object) |
On |
Implements the ISerializable interface and raises the deserialization event when the deserialization is complete. |
Remove(Object) |
Removes the element with the specified key from the Hashtable. (Inherited from Hashtable) |
Set |
Sets the value of the specified attribute to an object of a class that is derived from PrintProperty. |
To |
Returns a string that represents the current object. (Inherited from Object) |
IEnumerable. |
Returns an enumerator that iterates through a collection. (Inherited from Hashtable) |
Cast<TResult>(IEnumerable) |
Casts the elements of an IEnumerable to the specified type. |
Of |
Filters the elements of an IEnumerable based on a specified type. |
As |
Enables parallelization of a query. |
As |
Converts an IEnumerable to an IQueryable. |
Produk | Versi |
---|---|
.NET Framework | 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
Windows Desktop | 3.0, 3.1, 5, 6, 7, 8, 9 |
.NET maklum balas
.NET ialah projek sumber terbuka. Pilih pautan untuk memberikan maklum balas: