<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: invoke code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Sat, 17 May 2008 20:43:09 GMT</pubDate>
    <description>DZone Snippets: invoke code</description>
    <item>
      <title>python : call an unknow method with named params</title>
      <link>http://snippets.dzone.com/posts/show/662</link>
      <description>myObject is an instance of a class&lt;br /&gt;myMethod is the name of the method (string)&lt;br /&gt;myArgs is a dict for named arguments&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;if hasattr(myObject,myMethod):&lt;br /&gt;    try:&lt;br /&gt;        retValue = getattr(myObject,myMethod)(*(),**(myArgs))&lt;br /&gt;    except TypeError:&lt;br /&gt;        # arguments mismatch&lt;br /&gt;else:&lt;br /&gt;    # there is no "myMethod" method in myObject&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Thu, 08 Sep 2005 15:51:49 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/662</guid>
      <author>manatlan (manatlan)</author>
    </item>
    <item>
      <title>call an unknow method with named params in csharp</title>
      <link>http://snippets.dzone.com/posts/show/648</link>
      <description>myObject is an instance of a class&lt;br /&gt;myMethod is the name of the method (string)&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;String [] argNames = new String[ 1 ];&lt;br /&gt;String [] argValues = new String[ 1 ];&lt;br /&gt;&lt;br /&gt;argNames[0]="param";&lt;br /&gt;argNames[1]="value";&lt;br /&gt;&lt;br /&gt;Type t = myObject.GetType();&lt;br /&gt;&lt;br /&gt;t.InvokeMember ( myMethod, BindingFlags.InvokeMethod, null, site, argValues, null, null, argNames);&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 07 Sep 2005 21:16:47 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/648</guid>
      <author>manatlan (manatlan)</author>
    </item>
  </channel>
</rss>
