DIR Return Create A Forum - Home
---------------------------------------------------------
social facebook
HTML https://socialfacebook.createaforum.com
---------------------------------------------------------
*****************************************************
DIR Return to: Social Facebook
*****************************************************
#Post#: 84--------------------------------------------------
How to: Get Print System Object Properties Without Reflection
By: eyeconic Date: April 5, 2018, 9:48 am
---------------------------------------------------------
Using reflection to itemize the properties (and the types of
those properties) on an object can slow application performance.
The 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 PrintQueue type that ships with Microsoft .NET Framework,
but nearly identical code should work for types that you derive
from PrintSystemObject.
2.Create a PrintPropertyDictionary from the type's
PropertiesCollection. The Value property of each entry in this
dictionary is an object of one of the types derived from
PrintProperty.
3.Enumerate the members of the dictionary. For each of them, do
the following.
4.Up-cast the value of each entry to PrintProperty and use it to
create a PrintProperty object.
5.Get the type of the Value of each of the PrintProperty object.
C# Copy
// 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();
HTML https://www.youtube.com/watch?v=DG6jDNoLOJo
<script>
(function() {
var cx = '017846004531943245215:ntog6z4xfuc';
var gcse = document.createElement('script');
gcse.type = 'text/javascript';
gcse.async = true;
gcse.src = '
HTML https://cse.google.com/cse.js?cx='
+ cx;
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(gcse, s);
})();
</script>
<gcse:search></gcse:search>
*****************************************************