* Reset branch for WPF changes * Convert BMP to PNG; fix link-out-of-scope err * Add snippets for WPF... 6794 files!!!! * Add missing snippets * update file updated between migration * Fix paths to include * update breadcrumb and toc * fix index links * fix index links * fix index links * fix markdown
2.6 KiB
title, ms.date, dev_langs, helpviewer_keywords, ms.assetid
| title | ms.date | dev_langs | helpviewer_keywords | ms.assetid | |||
|---|---|---|---|---|---|---|---|
| How to: Get Print System Object Properties Without Reflection | 03/30/2017 |
|
|
43560f28-183d-41c1-b9d1-de7c2552273e |
How to: Get Print System Object Properties Without Reflection
Using reflection to itemize the properties (and the types of those properties) on an object can slow application performance. The xref:System.Printing.IndexedProperties namespace provides a means to getting this information with using reflection.
Example
The steps for doing this are as follows.
-
Create an instance of the type. In the example below, the type is the xref:System.Printing.PrintQueue type that ships with Microsoft .NET Framework, but nearly identical code should work for types that you derive from xref:System.Printing.PrintSystemObject.
-
Create a xref:System.Printing.IndexedProperties.PrintPropertyDictionary from the type's xref:System.Printing.PrintSystemObject.PropertiesCollection%2A. The xref:System.Collections.DictionaryEntry.Value%2A property of each entry in this dictionary is an object of one of the types derived from xref:System.Printing.IndexedProperties.PrintProperty.
-
Enumerate the members of the dictionary. For each of them, do the following.
-
Up-cast the value of each entry to xref:System.Printing.IndexedProperties.PrintProperty and use it to create a xref:System.Printing.IndexedProperties.PrintProperty object.
-
Get the type of the xref:System.Printing.IndexedProperties.PrintProperty.Value%2A of each of the xref:System.Printing.IndexedProperties.PrintProperty object.
[!code-csharpGetPrintObjectPropertyTypesWithoutReflection#ShowPropertyTypesWithoutReflection] [!code-vbGetPrintObjectPropertyTypesWithoutReflection#ShowPropertyTypesWithoutReflection]
See also
- xref:System.Printing.IndexedProperties.PrintProperty
- xref:System.Printing.PrintSystemObject
- xref:System.Printing.IndexedProperties
- xref:System.Printing.IndexedProperties.PrintPropertyDictionary
- xref:System.Printing.LocalPrintServer
- xref:System.Printing.PrintQueue
- xref:System.Collections.DictionaryEntry
- Documents in WPF
- Printing Overview