PrintPropertyDictionary クラス

定義

System.Printing 名前空間内のオブジェクトに関連付けられているプロパティおよび値のコレクションを表します。

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
継承
PrintPropertyDictionary
属性
実装

次の例では、このクラスを使用して、場所、ポート、および共有状態でのみ、そのプロパティと既存のプリンターと異なる 2 番目のプリンターをインストールする方法を示します。

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

次の例では、このクラスを使用して、リフレクションを使用せずに、実行時に印刷システム オブジェクトのプロパティとそれらのプロパティの型を検出する方法を示します。


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

注釈

コレクションは辞書の形式を Hashtable とります。 Valueコレクション内の各 DictionaryEntry の プロパティは、 からPrintProperty派生したクラスのインスタンスです。

コンストラクター

PrintPropertyDictionary()

PrintPropertyDictionary クラスの新しいインスタンスを初期化します。

PrintPropertyDictionary(SerializationInfo, StreamingContext)

PrintPropertyDictionary クラスの新しいインスタンスを初期化し、指定した SerializationInfo および StreamingContext をこのインスタンスに提供します。

プロパティ

comparer
古い.
古い.

IComparer で使用する Hashtable を取得または設定します。

(継承元 Hashtable)
Count

Hashtable に格納されているキー/値ペアの数を取得します。

(継承元 Hashtable)
EqualityComparer

IEqualityComparer に使用する Hashtable を取得します。

(継承元 Hashtable)
hcp
古い.
古い.

ハッシュ コードを提供できるオブジェクトを取得または設定します。

(継承元 Hashtable)
IsFixedSize

Hashtable が固定サイズかどうかを示す値を取得します。

(継承元 Hashtable)
IsReadOnly

Hashtable が読み取り専用かどうかを示す値を取得します。

(継承元 Hashtable)
IsSynchronized

Hashtable へのアクセスが同期されている (スレッド セーフである) かどうかを示す値を取得します。

(継承元 Hashtable)
Item[Object]

指定されたキーに関連付けられている値を取得または設定します。

(継承元 Hashtable)
Keys

Hashtable 内のキーを格納している ICollection を取得します。

(継承元 Hashtable)
SyncRoot

Hashtable へのアクセスを同期するために使用できるオブジェクトを取得します。

(継承元 Hashtable)
Values

ICollection 内の値を格納している Hashtable を取得します。

(継承元 Hashtable)

メソッド

Add(Object, Object)

指定したキーおよび値を持つ要素を Hashtable に追加します。

(継承元 Hashtable)
Add(PrintProperty)

指定した (PrintProperty から派生したクラスの) オブジェクトをディクショナリに追加します。

Clear()

Hashtable からすべての要素を削除します。

(継承元 Hashtable)
Clone()

Hashtable の簡易コピーを作成します。

(継承元 Hashtable)
Contains(Object)

Hashtable に特定のキーが格納されているかどうかを判断します。

(継承元 Hashtable)
ContainsKey(Object)

Hashtable に特定のキーが格納されているかどうかを判断します。

(継承元 Hashtable)
ContainsValue(Object)

Hashtable に特定の値が格納されているかどうかを判断します。

(継承元 Hashtable)
CopyTo(Array, Int32)

1 次元の Hashtable インスタンスの指定したインデックスに Array の要素をコピーします。

(継承元 Hashtable)
Dispose()

PrintPropertyDictionary によって使用されているすべてのリソースを解放します。

Dispose(Boolean)

PrintPropertyDictionary によって使用されているアンマネージド リソースを解放します。オプションでマネージド リソースも解放できます。

Equals(Object)

指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判断します。

(継承元 Object)
GetEnumerator()

Hashtable を反復処理する IDictionaryEnumerator を返します。

(継承元 Hashtable)
GetHash(Object)

指定したキーのハッシュ コードを返します。

(継承元 Hashtable)
GetHashCode()

既定のハッシュ関数として機能します。

(継承元 Object)
GetObjectData(SerializationInfo, StreamingContext)

SerializationInfo に、PrintPropertyDictionary をシリアル化するために必要なデータを設定します。

GetProperty(String)

指定したプロパティを表す (PrintProperty から派生したクラスの) オブジェクトを取得します。

GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
KeyEquals(Object, Object)

特定の ObjectHashtable 内の特定のキーと比較します。

(継承元 Hashtable)
MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
OnDeserialization(Object)

ISerializable インターフェイスを実装し、逆シリアル化が完了したときに逆シリアル化イベントを発生させます。

Remove(Object)

指定したキーを持つ要素を Hashtable から削除します。

(継承元 Hashtable)
SetProperty(String, PrintProperty)

指定した属性の値を PrintProperty から派生したクラスのオブジェクトに設定します。

ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)

明示的なインターフェイスの実装

IEnumerable.GetEnumerator()

コレクションを反復処理する列挙子を返します。

(継承元 Hashtable)

拡張メソッド

Cast<TResult>(IEnumerable)

IEnumerable の要素を、指定した型にキャストします。

OfType<TResult>(IEnumerable)

指定された型に基づいて IEnumerable の要素をフィルター処理します。

AsParallel(IEnumerable)

クエリの並列化を有効にします。

AsQueryable(IEnumerable)

IEnumerableIQueryable に変換します。

適用対象