PrintProperty 类

定义

表示打印系统硬件或软件组件的属性(和属性的值)。

public ref class PrintProperty abstract : IDisposable, System::Runtime::Serialization::IDeserializationCallback
[System.Serializable]
public abstract class PrintProperty : IDisposable, System.Runtime.Serialization.IDeserializationCallback
[<System.Serializable>]
type PrintProperty = class
    interface IDisposable
    interface IDeserializationCallback
Public MustInherit Class PrintProperty
Implements IDeserializationCallback, IDisposable
继承
PrintProperty
派生
属性
实现

示例

以下示例演示如何使用此类在运行时发现打印系统对象的属性和这些属性的类型,而无需使用反射。


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

构造函数

名称 说明
PrintProperty(String)

初始化 PrintProperty 类的新实例。

属性

名称 说明
IsDisposed

获取或设置一个值,该值指示对象是否已释放。

IsInitialized

获取或设置一个值,该值指示对象是否已初始化。

Name

在派生类中重写时,获取对象所表示的属性的名称。

Value

在派生类中重写时,获取或设置对象所表示的属性的值。

方法

名称 说明
Dispose()

释放由 <a0/a0> 使用的所有资源。

Dispose(Boolean)

释放由 PrintProperty 托管资源使用的非托管资源,并选择性地释放托管资源。

Equals(Object)

确定指定的对象是否等于当前对象。

(继承自 Object)
Finalize()

PrintProperty允许在垃圾回收回收之前PrintProperty尝试释放资源并执行其他清理操作。

GetHashCode()

用作默认哈希函数。

(继承自 Object)
GetType()

获取当前实例的 Type

(继承自 Object)
InternalDispose(Boolean)

释放由 PrintProperty 托管资源使用的非托管资源,并选择性地释放托管资源。

MemberwiseClone()

创建当前 Object的浅表副本。

(继承自 Object)
OnDeserialization(Object)

在派生类中重写时,实现 ISerializable 接口并在反序列化完成时引发反序列化事件。

ToString()

返回一个表示当前对象的字符串。

(继承自 Object)

适用于