Files
docs-desktop/dotnet-desktop-guide/framework/wpf/advanced/how-to-get-print-system-object-properties-without-reflection.md
T
Andy De George da363692ff Initial WPF content migrated (#17)
* 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
2020-09-04 09:46:28 -07:00

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
csharp
vb
PrintSystemObject [WPF], getting properties
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.

  1. 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.

  2. 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.

  3. Enumerate the members of the dictionary. For each of them, do the following.

  4. 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.

  5. 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