<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>Snipplr</title>
<link>http://snipplr.com/language/c-sharp/tags/Reflection</link>
<description>Recent snippets posted on Snipplr.com</description>
<language>en-us</language>
<pubDate>Sat, 18 May 2013 20:33:42 GMT</pubDate>
<item>
<title>(C#) Get Calling Method using Reflection - wallybh</title>
<link>http://snipplr.com/view/50743/get-calling-method-using-reflection/</link>
<description><![CDATA[ <p>Get the  calling method using reflection.</p> ]]></description>
<pubDate>Thu, 17 Mar 2011 02:08:06 GMT</pubDate>
<guid>http://snipplr.com/view/50743/get-calling-method-using-reflection/</guid>
</item>
<item>
<title>(C#) Get enum values by Reflection - ronklein</title>
<link>http://snipplr.com/view/48028/get-enum-values-by-reflection/</link>
<description><![CDATA[ <p>This code keeps the code order. For instance:

public enum Color
{
    Red = 100,
    Green = 0,
    Blue = 5        
}


-Will generate the names as Red, Green, Blue.
Using the Enum.GetNames approach won't make it.</p> ]]></description>
<pubDate>Fri, 28 Jan 2011 02:50:31 GMT</pubDate>
<guid>http://snipplr.com/view/48028/get-enum-values-by-reflection/</guid>
</item>
<item>
<title>(C#) Reflection convert all propperties - darkbaron1912</title>
<link>http://snipplr.com/view/37884/reflection-convert-all-propperties/</link>
<description><![CDATA[ <p>openpacs</p> ]]></description>
<pubDate>Sun, 25 Jul 2010 17:03:57 GMT</pubDate>
<guid>http://snipplr.com/view/37884/reflection-convert-all-propperties/</guid>
</item>
<item>
<title>(C#) Constructing Generics Through Reflection (List of Mixed Types Example) - bryanlyman</title>
<link>http://snipplr.com/view/33857/constructing-generics-through-reflection-list-of-mixed-types-example/</link>
<description><![CDATA[ <p>.net 2.0+ Generic classes make code size much smaller and casting objects (boxing) a cinch. However, currently there are some unsupported IDE options when trying to cast objects to and from generic objects that use mixed object types (inherited from a generic type specifier). Fear not, using reflection we can bypass the IDE and supply the users with strongly typed objects.</p> ]]></description>
<pubDate>Tue, 04 May 2010 16:58:15 GMT</pubDate>
<guid>http://snipplr.com/view/33857/constructing-generics-through-reflection-list-of-mixed-types-example/</guid>
</item>
<item>
<title>(C#) Converting MethodInfo into a delegate instance to improve performance - pckujawa</title>
<link>http://snipplr.com/view/29683/converting-methodinfo-into-a-delegate-instance-to-improve-performance/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Fri, 12 Mar 2010 10:13:43 GMT</pubDate>
<guid>http://snipplr.com/view/29683/converting-methodinfo-into-a-delegate-instance-to-improve-performance/</guid>
</item>
<item>
<title>(C#) GetProperties() - rtipton</title>
<link>http://snipplr.com/view/29029/getproperties/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Sun, 28 Feb 2010 17:48:50 GMT</pubDate>
<guid>http://snipplr.com/view/29029/getproperties/</guid>
</item>
<item>
<title>(C#) Get the Namespace, Class Name, and Method Name of the Currently Executing Method Via Reflection - rengber</title>
<link>http://snipplr.com/view/26471/get-the-namespace-class-name-and-method-name-of-the-currently-executing-method-via-reflection/</link>
<description><![CDATA[ <p>GetFrame(1) to avoid the last method being this property accessor.  
Note that in a child class inherited member, the Class name will be the name of the type containing the implementation.</p> ]]></description>
<pubDate>Thu, 14 Jan 2010 15:09:24 GMT</pubDate>
<guid>http://snipplr.com/view/26471/get-the-namespace-class-name-and-method-name-of-the-currently-executing-method-via-reflection/</guid>
</item>
<item>
<title>(C#) Dump an Arbitrary Object to XML (Bypassing Default Serialization) - rengber</title>
<link>http://snipplr.com/view/18836/dump-an-arbitrary-object-to-xml-bypassing-default-serialization/</link>
<description><![CDATA[ <p>Useful in cases where the object author has specified their own serialization that doesn't work for you.</p> ]]></description>
<pubDate>Tue, 25 Aug 2009 17:52:51 GMT</pubDate>
<guid>http://snipplr.com/view/18836/dump-an-arbitrary-object-to-xml-bypassing-default-serialization/</guid>
</item>
<item>
<title>(C#) C# structs, byte swapping for conversion from big to little endian using reflection to enumerate members - jimfred</title>
<link>http://snipplr.com/view/18354/c-structs-byte-swapping-for-conversion-from-big-to-little-endian-using-reflection-to-enumerate-members/</link>
<description><![CDATA[ <p>This example uses a Swap member to enumerate the struct&amp;#8217;s fields and swap multi-byte fields. It doesn&amp;#8217;t traverse nested structs.

It would be nice if dot.net has something equivalent to &amp;#8216;#pragma endian big&amp;#8217; as seen in some compilers. There might be a way to leverage marshaling to automatically endianize multi-byte values.

This example uses:
  *   System.Net.IPAddress.NetworkToHostOrder for byte swapping
  *   unchecked() to convert a value of, say, 0&amp;#8201;&amp;#215;&amp;#8201;87654321 to a Int32 without a runtime error
  *   foreach (System.Reflection.FieldInfo field in typeof(MyStruct).GetFields()) to enumerate structure members
  *   TypeCode typeCode = Type.GetTypeCode(fieldValue.GetType()); to get the underlying type enumeration (typeof of verbose).
  *   SetValue and GetValue to access struct members.
  *   Boxed object of struct - this was necessary only because SetValue didn&amp;#8217;t work on structs. It failed quietly.</p> ]]></description>
<pubDate>Sat, 15 Aug 2009 19:31:09 GMT</pubDate>
<guid>http://snipplr.com/view/18354/c-structs-byte-swapping-for-conversion-from-big-to-little-endian-using-reflection-to-enumerate-members/</guid>
</item>
<item>
<title>(C#) Copy All Object Values from Another Instance of the Same Type Using Reflection - rengber</title>
<link>http://snipplr.com/view/14594/copy-all-object-values-from-another-instance-of-the-same-type-using-reflection/</link>
<description><![CDATA[ <p>Say that you have a collection of objects empty but for IDs.  
You want to do a foreach loop through those objects and lookup detail one at a time.  
Unfortunately, in the foreach, you can't replace the references, you can only copy the new detail into the object.   
This technique will populate your current reference from an object instance returned by a lookup.</p> ]]></description>
<pubDate>Thu, 30 Apr 2009 00:51:06 GMT</pubDate>
<guid>http://snipplr.com/view/14594/copy-all-object-values-from-another-instance-of-the-same-type-using-reflection/</guid>
</item>
<item>
<title>(C#) Get Assembly Version - Anthony</title>
<link>http://snipplr.com/view/10536/get-assembly-version/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Tue, 16 Dec 2008 17:04:05 GMT</pubDate>
<guid>http://snipplr.com/view/10536/get-assembly-version/</guid>
</item>
<item>
<title>(C#) Adding Parameters to a Command Object Using Relection Over Matching Class Properties - rengber</title>
<link>http://snipplr.com/view/2619/adding-parameters-to-a-command-object-using-relection-over-matching-class-properties/</link>
<description><![CDATA[ <p>You could eliminate the ListDictionary if you created a simple method to map C# types to DbTypes.  Although this method also lets you skip over some object properties my using the ListDictionary to contain a subset of properties.  It could also be used to map properties to param names if they needed to differ.</p> ]]></description>
<pubDate>Wed, 09 May 2007 20:04:34 GMT</pubDate>
<guid>http://snipplr.com/view/2619/adding-parameters-to-a-command-object-using-relection-over-matching-class-properties/</guid>
</item>
<item>
<title>(C#) Scan Assemblies Using Reflection to Locate Performance Counter Installers - rengber</title>
<link>http://snipplr.com/view/2618/scan-assemblies-using-reflection-to-locate-performance-counter-installers/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Wed, 09 May 2007 15:43:53 GMT</pubDate>
<guid>http://snipplr.com/view/2618/scan-assemblies-using-reflection-to-locate-performance-counter-installers/</guid>
</item>
</channel>
</rss>