<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>MindTrace</title>
	<atom:link href="http://suryagaddipati.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://suryagaddipati.wordpress.com</link>
	<description>Passion Over Process ..Intensity Over Talent...</description>
	<lastBuildDate>Wed, 14 Apr 2010 14:21:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='suryagaddipati.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>MindTrace</title>
		<link>http://suryagaddipati.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://suryagaddipati.wordpress.com/osd.xml" title="MindTrace" />
	<atom:link rel='hub' href='http://suryagaddipati.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Linq like DSL in java in few lines of code</title>
		<link>http://suryagaddipati.wordpress.com/2009/04/13/linq-like-dsl-in-java-in-few-lines-of-code/</link>
		<comments>http://suryagaddipati.wordpress.com/2009/04/13/linq-like-dsl-in-java-in-few-lines-of-code/#comments</comments>
		<pubDate>Mon, 13 Apr 2009 21:43:42 +0000</pubDate>
		<dc:creator>suryagaddipati</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://suryagaddipati.wordpress.com/?p=89</guid>
		<description><![CDATA[This is what happens when you are reading a great functional programming book , looking at imperative code makes you cry . Here is what I did to console myself out of my grief today ( whatever makes you happy right ? ) The code below wraps google collections , in a thin java DSL [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=suryagaddipati.wordpress.com&amp;blog=2167365&amp;post=89&amp;subd=suryagaddipati&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This is what happens when you are reading a great functional programming <a href="http://www.realworldhaskell.org">book </a>, looking at imperative code makes you cry . Here is what I did to console myself out of my grief today ( whatever makes you happy right ? )</p>
<p>The code below wraps<a href="http://code.google.com/p/google-collections/" target="_blank"> google collections </a>, in a thin java DSL like wrapper</p>
<p><pre class="brush: csharp;">
 public class IterableQuery {

   public static  Where from(Iterable originalCollection) {
      return  new Where( Iterables.transform(originalCollection, IterableQuery.SAME()));
   }

   private static  Function SAME() {
      return new Function(){
         public T apply(T arg0) {
            return arg0;
         }
      };
   }

   public static class SelectOrderBy{

      private final Iterable iterable;

      public SelectOrderBy(Iterable iteable) {
         this.iterable = iteable;
      }

      public  SelectOrderBy orderyBy( Comparator sort ){
          Ordering.forComparator(sort).sort((List) iterable);
          return new SelectOrderBy( iterable);
      }

      public   Iterable select(  Function function){
         return Iterables.transform(iterable, function);
      }
      public  Iterable selectEveryThing( ){
         return iterable;
      }
   }

   public static class Where{

      private final Iterable iterable;

      public Where(Iterable iterable) {
         this.iterable = iterable;
      }

      public    SelectOrderBy where(Predicate predicate) {
         return  new SelectOrderBy( Iterables.filter(iterable, predicate));
      }
   }

}

</pre></p>
<p>Now collections could be queried like</p>
<p><pre class="brush: csharp;">
 Iterable currentlyAssigned =
             IterableQuery.
              from(orders).
              where(placedInLast10Days).
              orderBy(lastName).
              select(orderToNewOrder);
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/suryagaddipati.wordpress.com/89/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/suryagaddipati.wordpress.com/89/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/suryagaddipati.wordpress.com/89/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/suryagaddipati.wordpress.com/89/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/suryagaddipati.wordpress.com/89/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/suryagaddipati.wordpress.com/89/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/suryagaddipati.wordpress.com/89/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/suryagaddipati.wordpress.com/89/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/suryagaddipati.wordpress.com/89/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/suryagaddipati.wordpress.com/89/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/suryagaddipati.wordpress.com/89/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/suryagaddipati.wordpress.com/89/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/suryagaddipati.wordpress.com/89/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/suryagaddipati.wordpress.com/89/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=suryagaddipati.wordpress.com&amp;blog=2167365&amp;post=89&amp;subd=suryagaddipati&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://suryagaddipati.wordpress.com/2009/04/13/linq-like-dsl-in-java-in-few-lines-of-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c5a248cded4b8de6ea69feab15a9b6e6?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">suryagaddipati</media:title>
		</media:content>
	</item>
		<item>
		<title>Code as Data in C# &#8211; Taking advantage of Expression Trees In Everyday Programming</title>
		<link>http://suryagaddipati.wordpress.com/2009/03/14/code-as-data-in-c-taking-advantage-of-expression-trees/</link>
		<comments>http://suryagaddipati.wordpress.com/2009/03/14/code-as-data-in-c-taking-advantage-of-expression-trees/#comments</comments>
		<pubDate>Sat, 14 Mar 2009 20:56:09 +0000</pubDate>
		<dc:creator>suryagaddipati</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://suryagaddipati.wordpress.com/?p=25</guid>
		<description><![CDATA[In C# 3.0 a lambda expression can be converted into either an expression tree or a delegate ..former of which lets you treat code as data ..this mechanism is source of all the coolness behind linq to sql . But this is doesnt have to be limited to frameworks, You can take advantage of this [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=suryagaddipati.wordpress.com&amp;blog=2167365&amp;post=25&amp;subd=suryagaddipati&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In C# 3.0 a lambda expression can be converted into either an expression tree or a delegate ..former of which lets you treat code as data ..this mechanism is source of all the coolness behind linq to sql .</p>
<p>But this is doesnt have to be  limited to frameworks,  You can take advantage of this mechanism in your day<br />
to day coding .. here are just two examples of the stuff  I&#8217;ve used this in the past ( examples below are made up equivalents)</p>
<p><strong>Builders </strong>:</p>
<p>Lets say you are writing a weekly activity recorder  , the traditional ( boring ..)  way of creating it would be</p>
<p><pre class="brush: csharp;">
  WeeklyActivityRecorder weeklyActivities = new WeeklyActivityRecorder ();
  weeklyActivities .AddActivity( new Activity{Day = DayOfWeek.Monday , Activity = &quot;Lawn Moving&quot; });
  weeklyActivities .AddActivity( new Activity{Day = DayOfWeek.Tuesday , Activity = &quot;Cooking&quot; });
</pre></p>
<p>The &#8221; Code as Data &#8221; way would be ..</p>
<p><pre class="brush: csharp;">
  WeeklyActivityRecorder weeklyActivities = new WeeklyActivityRecorder () .WithActivities( Monday =&gt; &quot;Lawn Moving&quot;,Tuesday =&gt; &quot;Cooking&quot;);
</pre></p>
<p>This looks more readable ( and fun <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  ).. and there is very little work involved to actually achieve this</p>
<p><pre class="brush: csharp;">
 public static WeeklyActivityRecorder WithActivities(this WeeklyActivityRecorder recorder, params   Expression&lt;Func&lt;DayOfWeek, string&gt;&gt;[] activities)
 {
  foreach( var activity in activities )
  {
     LambdaExpression expression = activity;
     ConstantExpression activity= expression.Body as ConstantExpression;
     DayOfWeek day =  expression.Parameters[0];
     recorder.AddActivity(new Activity {DayOfWeek = day , Activity = activity});
  }
 return recorder ;
}
</pre></p>
<p>Here I define a new extension method on  WeeklyActivityRecorder which takes varargs lambda expressions<br />
I then parse the lambda expression to create the appropriate activity , pretty straightforward stuff.</p>
<p>The second example is <strong>creating a hibernate criteria from expression tree</strong></p>
<p>Once again the *old*  way of querying  by property would be by passing in the property by string</p>
<p><pre class="brush: csharp;">
  protected IList&lt;T&gt; _FindByProperty(string propertyName , object value)
        {
            return _hibernateTemplate.Execute(
                            session =&gt; session.CreateCriteria(typeof(T)).
                            Add(Expression.Eq(propertyName, value)).List())
                            .Cast&lt;T&gt;().ToList();
        }

</pre></p>
<p>Code is obviously fragile since you have to use strings as property names which cannot be checked at compile time..</p>
<p>So instead of calling that method directly we could call it through a method which accepts an expression instead of string</p>
<p><pre class="brush: csharp;">&lt;/pre&gt;
protected IList&lt;T&gt; _FindByProperty&lt;TResult&gt;(Expression&lt;Func&lt;T, TResult&gt;&gt; expression, TResult value)
 {
 return _FindByProperty((expression.Body as MemberExpression).Member.Name, value);
 }
&lt;pre&gt;</pre></p>
<p>The Above method could now be called as</p>
<p><pre class="brush: csharp;">
 IList&lt;User&gt; costCenters = _FindByProperty( user=&gt; user.Name, &quot;surya&quot;);
</pre></p>
<p>Existence of property &#8220;Name&#8221; is now checked at compiled time ..Although this technique is powerful, it feels<br />
limited when compared to what you can do in LISP dialects.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/suryagaddipati.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/suryagaddipati.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/suryagaddipati.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/suryagaddipati.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/suryagaddipati.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/suryagaddipati.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/suryagaddipati.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/suryagaddipati.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/suryagaddipati.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/suryagaddipati.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/suryagaddipati.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/suryagaddipati.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/suryagaddipati.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/suryagaddipati.wordpress.com/25/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=suryagaddipati.wordpress.com&amp;blog=2167365&amp;post=25&amp;subd=suryagaddipati&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://suryagaddipati.wordpress.com/2009/03/14/code-as-data-in-c-taking-advantage-of-expression-trees/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c5a248cded4b8de6ea69feab15a9b6e6?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">suryagaddipati</media:title>
		</media:content>
	</item>
		<item>
		<title>Object Graph Retrival DSL ..</title>
		<link>http://suryagaddipati.wordpress.com/2009/03/11/object-graph-retrival-dsl/</link>
		<comments>http://suryagaddipati.wordpress.com/2009/03/11/object-graph-retrival-dsl/#comments</comments>
		<pubDate>Wed, 11 Mar 2009 22:49:19 +0000</pubDate>
		<dc:creator>suryagaddipati</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://suryagaddipati.wordpress.com/?p=68</guid>
		<description><![CDATA[Often in a query based api&#8217;s ( for example  REST based apis )  there is a need for providing a capability for the client to specify the field and depth  while retrieving an object graph .. For example, Windows Live contact Api let you specify Field and Depth Filtering via the query param Filter , [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=suryagaddipati.wordpress.com&amp;blog=2167365&amp;post=68&amp;subd=suryagaddipati&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Often in a query based api&#8217;s ( for example  REST based apis )  there is a need for providing a capability for the client to specify the field and depth  while retrieving an object graph ..</p>
<p>For example, <a title="Windows Live Contact Api" href="http://msdn.microsoft.com/en-us/library/bb463939.aspx" target="_blank">Windows Live contact Api </a></p>
<p>let you specify Field and Depth Filtering via the query param Filter , for example a request like</p>
<pre class="libCScode" style="white-space:pre-wrap;">https://livecontacts.services.live.com/users/@L@&lt;lid&gt;/rest/livecontacts&amp;Filter=LiveContacts(Contact(ID,CID),Tag)</pre>
<p>Would retrive live contacts contact with id , CID and tag for live contact .</p>
<p>You could make this infinitely recursive to pick and choose fields you want at any graph depth .</p>
<p>Here is the  <a title="ANTLR" href="http://www.antlr.org/" target="_blank">antlr </a>grammer for doing just that .. Instructions for how to generate code is available on antlr website</p>
<pre>grammar Response;

options {output=AST;}
tokens {
   FIELDSHORTCUT;
   STAR;
}
response:  root (',' root)* -&gt; root+ ;
root 	:fieldshortcut|'*'| (nodewithchildren);
nodewithchildren: (ID LPAREN response RPAREN) -&gt; ^(ID response)
	|ID -&gt; ^(ID STAR)
	|ID '()'-&gt; ^(ID) ;
fieldshortcut
	:	'{'ID'}' -&gt; ^(FIELDSHORTCUT ID);	

ID  :   ('a'..'z'|'A'..'Z')+ ;
INT :   '0'..'9'+ ;
LPAREN 	:	'(';
RPAREN 	:	')';

NEWLINE:'\r'? '\n' ;
WS  :   (' '|'\t')+ { $channel=HIDDEN;} ;</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/suryagaddipati.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/suryagaddipati.wordpress.com/68/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/suryagaddipati.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/suryagaddipati.wordpress.com/68/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/suryagaddipati.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/suryagaddipati.wordpress.com/68/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/suryagaddipati.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/suryagaddipati.wordpress.com/68/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/suryagaddipati.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/suryagaddipati.wordpress.com/68/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/suryagaddipati.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/suryagaddipati.wordpress.com/68/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/suryagaddipati.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/suryagaddipati.wordpress.com/68/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=suryagaddipati.wordpress.com&amp;blog=2167365&amp;post=68&amp;subd=suryagaddipati&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://suryagaddipati.wordpress.com/2009/03/11/object-graph-retrival-dsl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c5a248cded4b8de6ea69feab15a9b6e6?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">suryagaddipati</media:title>
		</media:content>
	</item>
		<item>
		<title>plugging in custom selector  in jquery</title>
		<link>http://suryagaddipati.wordpress.com/2009/02/12/plugging-in-custom-selector-in-jquery/</link>
		<comments>http://suryagaddipati.wordpress.com/2009/02/12/plugging-in-custom-selector-in-jquery/#comments</comments>
		<pubDate>Thu, 12 Feb 2009 00:36:06 +0000</pubDate>
		<dc:creator>suryagaddipati</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://suryagaddipati.wordpress.com/?p=64</guid>
		<description><![CDATA[A line on code speaks for 1000 lines of  explanation .. so here it is The above code plugs in a custom selector for matching all the elements which have class starting with a certain string so a selector like above would select all the input elements with class starting with highlight . I guess [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=suryagaddipati.wordpress.com&amp;blog=2167365&amp;post=64&amp;subd=suryagaddipati&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>A line on code speaks for 1000 lines of  explanation <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  .. so here it is</p>
<p><pre class="brush: jscript;">
jQuery.extend(jQuery.expr[':'], {
	classStartsWith: function(a, i, m){
		var classes = $(a).attr(&quot;className&quot;).split(&quot; &quot;)
		var found = false;
		for (var i = 0; i &lt; classes.length; i++) {
			if (classes[i].startsWith(m[3])) {
				found = true;
				break;
			}
		}
		return found;
	}
});
</pre></p>
<p>The above code plugs in a custom selector for matching all the elements which have class starting with a certain string so</p>
<p><pre class="brush: jscript;">
$('input:classStartsWith('highlight')')
</pre></p>
<p>a selector like above would select all the input elements with class starting with highlight .<br />
I guess the code is pretty straight forward  so I&#8217;m not going to go exegetic on the code .</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/suryagaddipati.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/suryagaddipati.wordpress.com/64/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/suryagaddipati.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/suryagaddipati.wordpress.com/64/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/suryagaddipati.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/suryagaddipati.wordpress.com/64/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/suryagaddipati.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/suryagaddipati.wordpress.com/64/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/suryagaddipati.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/suryagaddipati.wordpress.com/64/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/suryagaddipati.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/suryagaddipati.wordpress.com/64/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/suryagaddipati.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/suryagaddipati.wordpress.com/64/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=suryagaddipati.wordpress.com&amp;blog=2167365&amp;post=64&amp;subd=suryagaddipati&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://suryagaddipati.wordpress.com/2009/02/12/plugging-in-custom-selector-in-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c5a248cded4b8de6ea69feab15a9b6e6?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">suryagaddipati</media:title>
		</media:content>
	</item>
		<item>
		<title>jquery plugin to convert form input to a javascript object graph</title>
		<link>http://suryagaddipati.wordpress.com/2008/10/29/jquery-plugin-to-convert-form-input-to-a-javascript-object-graph/</link>
		<comments>http://suryagaddipati.wordpress.com/2008/10/29/jquery-plugin-to-convert-form-input-to-a-javascript-object-graph/#comments</comments>
		<pubDate>Wed, 29 Oct 2008 01:02:01 +0000</pubDate>
		<dc:creator>suryagaddipati</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://suryagaddipati.wordpress.com/?p=44</guid>
		<description><![CDATA[Client side javascript validation often ends up being  ugly and really boring ..while on the serverside validations usually tend to be more domain related ,something like &#8220;order.Qty &#62; 0&#8243; on the serverside endsup looking something ugly like &#8220;document.get(&#8230;&#8230;.).val()&#8230;.&#8221; I ended up writing a jquery plugin which reads the form inputs and converts it into an [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=suryagaddipati.wordpress.com&amp;blog=2167365&amp;post=44&amp;subd=suryagaddipati&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Client side javascript validation often ends up being  ugly and really boring ..while on the serverside validations usually tend to be more domain related ,something like &#8220;order.Qty &gt; 0&#8243; on the serverside endsup looking something ugly like &#8220;document.get(&#8230;&#8230;.).val()&#8230;.&#8221;</p>
<p>I ended up writing a jquery plugin which reads the form inputs and converts it into an object graph based on the name attribute, so for an form with the following  inputs</p>
<p><pre class="brush: xml;">
&lt;input  name=&quot;order.customerName&quot;  /&gt;
&lt;input  name=&quot;order.orderItem.qty&quot;  /&gt;
</pre></p>
<p>you could just say</p>
<p><pre class="brush: jscript;">
 var order = $('#myform').params2Object();
 test(order.customerName ==='john');
 test(order.orderItem.qty &gt; 0 );
</pre></p>
<p>Here is the actual plugin code ..HTH</p>
<p><pre class="brush: jscript;">
jQuery.fn.params2Object = function(){
    var d = this.serializeArray()
    var data = {};
    for (var i = 0; i &lt; d.length; i++) {
        var tokens = d[i].name.split('.');
        _setValue(data, tokens, d[i].value);
    }
    return data;

    function _setValue(obj, tokens, value, index){
        if (tokens.length == 1) {
            if (typeof index != 'undefined') {
                obj[index] = obj[index] ||
                {};
                obj[index][tokens[0]] = value;
            }
            else {
                obj[tokens[0]] = value;
            }
        }
        else {
            var prop = _getProperty(tokens[0]);
            obj[prop.name] = obj[prop.name] || (prop.isArray ? [] : {});
            _setValue(obj[prop.name], tokens.slice(1, tokens.length), value, prop.index);
        }
    }

    function _getProperty(token){
        var arraySplit = token.split('[');
        if (arraySplit.length &gt; 1) {
            var propName = arraySplit[0];
            var index = arraySplit[1].split(']')[0];
        }
        else {
            var propName = token;
        }
        return {
            name: propName,
            index: index,
            isArray: token.indexOf(']') &gt; 0
        };

    }

};

</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/suryagaddipati.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/suryagaddipati.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/suryagaddipati.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/suryagaddipati.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/suryagaddipati.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/suryagaddipati.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/suryagaddipati.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/suryagaddipati.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/suryagaddipati.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/suryagaddipati.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/suryagaddipati.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/suryagaddipati.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/suryagaddipati.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/suryagaddipati.wordpress.com/44/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=suryagaddipati.wordpress.com&amp;blog=2167365&amp;post=44&amp;subd=suryagaddipati&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://suryagaddipati.wordpress.com/2008/10/29/jquery-plugin-to-convert-form-input-to-a-javascript-object-graph/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c5a248cded4b8de6ea69feab15a9b6e6?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">suryagaddipati</media:title>
		</media:content>
	</item>
		<item>
		<title>Is it just me or are Indian musical intruments getting really mainstream ?</title>
		<link>http://suryagaddipati.wordpress.com/2008/07/21/is-it-just-me-or-are-indian-muscial-intruments-getting-really-mainstream/</link>
		<comments>http://suryagaddipati.wordpress.com/2008/07/21/is-it-just-me-or-are-indian-muscial-intruments-getting-really-mainstream/#comments</comments>
		<pubDate>Mon, 21 Jul 2008 22:59:53 +0000</pubDate>
		<dc:creator>suryagaddipati</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://suryagaddipati.wordpress.com/?p=26</guid>
		<description><![CDATA[I happened to catch up on my &#8220;mainstream&#8221; listening this week .. so I picked 3 albums and all three of them had *traditional* indian instruments in them.. Sitar , Yes &#8211; Viva La Vida , Coldplay ( http://www.imeem.com/dazhini/music/3IS9giaS/coldplay_yes_chinese_sleep_chant/ Tabla , Citizen of the Planet &#8211; Flavors of entanglement Alanis Morissette ( http://www.youtube.com/watch?v=TmnLBPENNys) Tabla Again [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=suryagaddipati.wordpress.com&amp;blog=2167365&amp;post=26&amp;subd=suryagaddipati&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://suryagaddipati.files.wordpress.com/2008/07/231350799_f9d5345bfb_m.jpg"><img class="alignnone size-medium wp-image-30" src="http://suryagaddipati.files.wordpress.com/2008/07/231350799_f9d5345bfb_m.jpg?w=151&#038;h=240" alt="" width="151" height="240" /></a></p>
<p>I happened to catch up on my &#8220;mainstream&#8221; listening this week .. so I picked 3 albums and all three of them had *traditional* indian instruments in them..</p>
<ul>
<li>Sitar ,  Yes &#8211; Viva La Vida , Coldplay ( <a class="aligncenter" title="u tube link" href="http://www.imeem.com/dazhini/music/3IS9giaS/coldplay_yes_chinese_sleep_chant/" target="_blank">http://www.imeem.com/dazhini/music/3IS9giaS/coldplay_yes_chinese_sleep_chant/</a></li>
<li>Tabla ,  Citizen of the Planet &#8211; Flavors of entanglement   Alanis Morissette<br />
( <a title="you tube link" href="http://www.youtube.com/watch?v=TmnLBPENNys" target="_blank">http://www.youtube.com/watch?v=TmnLBPENNys</a>)</li>
<li>Tabla Again , Pity And Fear &#8211; Narrow Stairs , Death Cab For Cutie ( <a class="aligncenter" title="you tube link" href="http://www.youtube.com/watch?v=pyyaSbSC61M" target="_blank">http://www.youtube.com/watch?v=pyyaSbSC61M</a>Ahh..Now I get what they meant when they said this is  their *Experimental* Album <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </li>
<li>Sitar , Loser &#8211; Mellow Gold , Beck ( <a href="http://www.youtube.com/watch?v=TJN3PGqDRNg">http://www.youtube.com/watch?v=TJN3PGqDRNg</a> )</li>
</ul>
<p>Or .. I guess it was just a coincidence  that the three ablums I picked up happened to have indian instruments in them ..</p>
<p>Either way its cool .. my brain subconsciously puts a seal of approval on a song  which has  even a  minor smattering of sitar , tabla , flute or any other awesome instruments ..</p>
<p>Bonus : *<em>Teen Mar</em>* in British Accent (<a title="Teen Mar" href="http://www.youtube.com/watch?v=fZv-G7IISgs" target="_blank"> http://www.youtube.com/watch?v=fZv-G7IISgs</a>)</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/suryagaddipati.wordpress.com/26/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/suryagaddipati.wordpress.com/26/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/suryagaddipati.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/suryagaddipati.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/suryagaddipati.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/suryagaddipati.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/suryagaddipati.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/suryagaddipati.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/suryagaddipati.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/suryagaddipati.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/suryagaddipati.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/suryagaddipati.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/suryagaddipati.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/suryagaddipati.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/suryagaddipati.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/suryagaddipati.wordpress.com/26/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=suryagaddipati.wordpress.com&amp;blog=2167365&amp;post=26&amp;subd=suryagaddipati&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://suryagaddipati.wordpress.com/2008/07/21/is-it-just-me-or-are-indian-muscial-intruments-getting-really-mainstream/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c5a248cded4b8de6ea69feab15a9b6e6?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">suryagaddipati</media:title>
		</media:content>

		<media:content url="http://suryagaddipati.files.wordpress.com/2008/07/231350799_f9d5345bfb_m.jpg?w=151" medium="image" />
	</item>
		<item>
		<title>Java 5.0 vs C# 3.0 Shootout</title>
		<link>http://suryagaddipati.wordpress.com/2008/05/05/java-50-vs-c-30-shootout/</link>
		<comments>http://suryagaddipati.wordpress.com/2008/05/05/java-50-vs-c-30-shootout/#comments</comments>
		<pubDate>Mon, 05 May 2008 23:06:13 +0000</pubDate>
		<dc:creator>suryagaddipati</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://suryagaddipati.wordpress.com/?p=23</guid>
		<description><![CDATA[Just a fun comparision between C# and Java ..I am obiviously not comparing stuff like LINQ, Lambda expressions which dont have java equivalents Round 1.0 &#8211; GENERICS No Type Erasure in C # , new T() anyone ?? Value types like int or Enumeration can be be used as type parameter so MyClass&#60;int&#62; is perfectly [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=suryagaddipati.wordpress.com&amp;blog=2167365&amp;post=23&amp;subd=suryagaddipati&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Just a fun comparision between C# and Java ..I am obiviously not comparing stuff like LINQ, Lambda expressions  which dont have java  equivalents</p>
<p><strong>Round 1.0 &#8211; GENERICS</strong></p>
<ol>
<li> No Type <a title="Erasure" href="http://msdn2.microsoft.com/en-us/library/f4a6ta2h(VS.80).aspx" target="_blank">Erasure </a>in C # , new T() anyone ??</li>
<li>Value types like int or Enumeration can be be used as type parameter so MyClass&lt;int&gt; is perfectly valid.</li>
<li> No Wildcards in C# which I terribly miss ,  Cast&lt;&gt;() from Linq Enumerable doesnt look too pretty</li>
<li>Java has better support for covariant and contravariant for type parameters , I dearly miss &#8221; ? &#8221; from java.</li>
<li> Assignment Type inference works in Java but not C#<br />
in Java,<br />
public T &lt;T&gt; myMethod()<br />
T var = myMethod() ; // T is inferred here !!!<br />
in C#<br />
public T  MyMethod&lt;T&gt;()<br />
T var = myMethod() ; // T cannot be inferred from the assignment here!!!</li>
</ol>
<p>This round clearly goes to C# &#8230;Generics done right ( almost ..)</p>
<p><strong>Round 2.0  Enums</strong></p>
<p>Java has enum support too..but whats different with enums in C# is</p>
<li><span style="font-family:Verdana,Arial,Helvetica,sans-serif;">They can&#8217;t define their own methods.</span></li>
<li><span style="font-family:Verdana,Arial,Helvetica,sans-serif;">They can&#8217;t implement interfaces.</span></li>
<li><span style="font-family:Verdana,Arial,Helvetica,sans-serif;"><br />
Both of which can be done in java side  ..Ok so this round goes to Java<strong></p>
<p>Round 3 : IDE&#8217;s<br />
</strong>Ok ..this has nothing to do with language itself ..but most people&#8217;s ( me included ) overall experience  with the language includes the IDE too ..if this was not the the factor dynamic languages would have won the battle ages ago.. </span></li>
<li>Visual studio  almost does justice to the word &#8220;Integrated&#8221; in IDE ..not more running around using 10 different tools just to put a database on the website..</li>
<li>There is no Concept of a &#8220;Power User &#8221; in visual studio..and its still catching on to the word &#8220;refactoring&#8221; even after 15 yrs.. without resharper it would be like coding with your mouth with your hands tied behind.<br />
This round is a TIE..<br />
<strong>Round 4 : Packaging</strong></li>
<li>C# does a pseudo OSGI  with internal access modifier</li>
<li>TODO<br />
Round Goes to C# ..</p>
<p><strong>Round  5 : Boilerplate Code</strong><br />
This is a Staticlly typed language &#8216;s kryptonite .. I know ..you know who is going to win this round..</li>
<li>Using blocks ..null coalescing operator , lambda expressions , Linq , automatic properties ..long list of awesome features<br />
Round clearly goes to C# again&#8230;no contest at all..</p>
<p><strong>Round 6 : Libraries / Frameworks</p>
<p></strong>Again this obviously has nothing to with language itself but still contributes to overall experience ..</li>
<li>Java has vast array of open source libraries to choose from ..( paradox of choice ?).. .Net libraries are mostly from Microsoft .. .Net equivalents of good stuff from JAVA like Nhibernate and Spring.NET are  generally lagging behind and receive much less attention than their java equivalents..
<p>This Round goes to Java</li>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/suryagaddipati.wordpress.com/23/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/suryagaddipati.wordpress.com/23/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/suryagaddipati.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/suryagaddipati.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/suryagaddipati.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/suryagaddipati.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/suryagaddipati.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/suryagaddipati.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/suryagaddipati.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/suryagaddipati.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/suryagaddipati.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/suryagaddipati.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/suryagaddipati.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/suryagaddipati.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/suryagaddipati.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/suryagaddipati.wordpress.com/23/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=suryagaddipati.wordpress.com&amp;blog=2167365&amp;post=23&amp;subd=suryagaddipati&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://suryagaddipati.wordpress.com/2008/05/05/java-50-vs-c-30-shootout/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c5a248cded4b8de6ea69feab15a9b6e6?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">suryagaddipati</media:title>
		</media:content>
	</item>
		<item>
		<title>NHibernate Mapping an Enum</title>
		<link>http://suryagaddipati.wordpress.com/2008/04/18/nhibernate-mapping-an-enum/</link>
		<comments>http://suryagaddipati.wordpress.com/2008/04/18/nhibernate-mapping-an-enum/#comments</comments>
		<pubDate>Fri, 18 Apr 2008 01:23:44 +0000</pubDate>
		<dc:creator>suryagaddipati</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://suryagaddipati.wordpress.com/?p=22</guid>
		<description><![CDATA[Option 1 : Subclass Enummapping class But that forces us to create several meaningless little classes just for the sake of mapping and if its always the string name of the enum why go through all that ? Option 2 : Create a Generic Enum mapping usertype ..which might look like &#8230; And the corresponding [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=suryagaddipati.wordpress.com&amp;blog=2167365&amp;post=22&amp;subd=suryagaddipati&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Option 1 : <a href="http://codebetter.com/blogs/jeremy.miller/archive/2006/02/20/138732.aspx">Subclass Enummapping class </a></p>
<p>But that forces us to create several meaningless little classes just for the sake of mapping and if its always the string name of the enum why go through all that ?</p>
<p>Option 2 : Create a Generic Enum mapping usertype ..which might look like &#8230;</p>
<p><pre class="brush: csharp;">
public class EnumMappingType : IEnhancedUserType , IParameterizedType
    {
        private Type enumClass;

        public  string Name
        {
            get { return &quot;enumstring - &quot; + enumClass.Name; }
        }

        public  Type ReturnedClass
        {
            get { return enumClass; }
        }
        public object StringToObject(string xml)
        {
            return null;
        }

        public object FromXMLString(string xml)
        {
            throw new NotImplementedException();
        }

        public string ObjectToSQLString(object value)
        {
            return GetValue(value).ToString();
        }
        public virtual object GetValue(object code)
        {
            //code is an enum instance.
            return code == null ? string.Empty : code.ToString();
        }

        public void SetParameterValues(IDictionary parameters)
        {
           enumClass = Type.GetType((string) parameters[&quot;enumClass&quot;],true);
        }

        public  object FromStringValue(string xml)
        {
            return GetInstance(xml);
        }
        public virtual object GetInstance(object code)
        {
            //code is an named constants defined for the enumeration.
            try
            {
                return Enum.Parse(enumClass, code as string, true);
            }
            catch (ArgumentException ae)
            {
                throw new HibernateException(string.Format(&quot;Can't Parse {0} as {1}&quot;, code, enumClass.Name), ae);
            }
        }

        public  string ToString(object value)
        {
            return (value == null) ? null : GetValue(value).ToString();
        }

        public  bool Equals(object x, object y)
        {
            return (x == y) || (x != null &amp;&amp; y != null &amp;&amp; x.Equals(y));
        }

        public int GetHashCode(object x)
        {
            throw new NotImplementedException();
        }

        public object NullSafeGet(IDataReader rs, string[] names, object owner)
        {
            object code = rs[rs.GetOrdinal(names[0])];
            if (code == DBNull.Value || code == null)
            {
                return null;
            }
            return GetInstance(code);
        }

        public void NullSafeSet(IDbCommand cmd, object value, int index)
        {
            IDataParameter par = (IDataParameter)cmd.Parameters[index];
            if (value == null)
            {
                par.Value = DBNull.Value;
            }
            else
            {
                par.Value = Enum.Format(this.enumClass, value, &quot;G&quot;);
            }
        }

        public object DeepCopy(object value)
        {
            return value;
        }

        public object Replace(object original, object target, object owner)
        {
            return original;
        }

        public object Assemble(object cached, object owner)
        {
            return cached;
        }

        public object Disassemble(object value)
        {
            return value;
        }

        public SqlType[] SqlTypes
        {
            get { return new[] { SqlTypeFactory.GetString(10) }; }
        }

        public Type ReturnedType
        {
            get { return enumClass; }
        }

        public bool IsMutable
        {
            get {return false; }
        }
    }
 </pre></p>
<p>And the corresponding mapping file can be ( you can also create shortcut typedef&#8217;s btw )</p>
<p><pre class="brush: xml;">
&lt;property  name=&quot;EnumPropertyName&quot;&gt;
      &lt;column name=&quot;EnumPropertyName&quot; sql-type=&quot;nvarchar(50)&quot; not-null=&quot;true&quot;/&gt;
      &lt;type name =&quot;....EnumMappingType, Assembly.Name&quot;&gt;
        &lt;param name =&quot;enumClass&quot;&gt;Your.Enum.ClassName&lt;/param&gt;
      &lt;/type&gt;
&lt;/property&gt;
</pre></p>
<p>Hope that helps someone out there !!!</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/suryagaddipati.wordpress.com/22/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/suryagaddipati.wordpress.com/22/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/suryagaddipati.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/suryagaddipati.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/suryagaddipati.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/suryagaddipati.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/suryagaddipati.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/suryagaddipati.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/suryagaddipati.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/suryagaddipati.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/suryagaddipati.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/suryagaddipati.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/suryagaddipati.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/suryagaddipati.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/suryagaddipati.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/suryagaddipati.wordpress.com/22/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=suryagaddipati.wordpress.com&amp;blog=2167365&amp;post=22&amp;subd=suryagaddipati&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://suryagaddipati.wordpress.com/2008/04/18/nhibernate-mapping-an-enum/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c5a248cded4b8de6ea69feab15a9b6e6?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">suryagaddipati</media:title>
		</media:content>
	</item>
		<item>
		<title>Creating Python extensions in C/C++ with SWIG on windows</title>
		<link>http://suryagaddipati.wordpress.com/2008/03/12/creating-python-extensions-in-cc-with-swig-on-windows/</link>
		<comments>http://suryagaddipati.wordpress.com/2008/03/12/creating-python-extensions-in-cc-with-swig-on-windows/#comments</comments>
		<pubDate>Wed, 12 Mar 2008 03:11:47 +0000</pubDate>
		<dc:creator>suryagaddipati</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://suryagaddipati.wordpress.com/?p=17</guid>
		<description><![CDATA[This  is a cookbook for creating Python extensions in C/C++ under Windows with SWIG, distutils and gcc (MinGW version). I am using to the following versions 1 . SWIG Version 1.3.24 2 . Python 2.3.4 3.mingw 3.0.0 1. Get and install MinGW gcc Download the compiler from http://www.mingw.org. This GCC compiler runs under Windows and [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=suryagaddipati.wordpress.com&amp;blog=2167365&amp;post=17&amp;subd=suryagaddipati&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><span>This  is a cookbook for creating Python extensions in C/C++ under Windows with SWIG, distutils and gcc (MinGW version).<br />
I am using to the following versions</p>
<p>1 . SWIG Version 1.3.24</p>
<p>2 . Python 2.3.4</p>
<p>3.mingw 3.0.0</p>
<p>1. Get and install MinGW gcc<br />
Download the compiler from http://www.mingw.org. This GCC compiler runs under Windows and compiled programs do not require support DLL like CygWin GCC.</p>
<p>You only need to download MinGW-1.1.tar.gz (roughly 10,6 Mb). It contains the whole compiler, support utilities, documentation, librairies and header files.</p>
<p>Once decompressed, you should add the \bin directory of MinGW to your path environment variable.<br />
(Example : Under Windows 95/98/ME, if you installed MinGW to c:\gcc, you would add SET PATH=c:\gcc\bin;%PATH% to your AUTOEXEC.BAT.)</p>
<p>If installed properly, you should be able to run gcc &#8211;version anywhere. (Mine displays : 2.95.3-6).</p>
<p>2 . Get and install Python<br />
Download the executable from www.python.org . As usually set the path to run python from anywhere.</p>
<p>3 . Create libpython23.a<br />
To create Python extensions, you need to link against the Python library. Unfortunately, most Python distributions are provided with Python23.lib, a library in Microsoft Visual C++ format. GCC expects a .a file (libpython23.a to be precise.). Here&#8217;s how to convert python23.lib to libpython23.a:</p>
<p>Download pexport (from here or http://starship.python.net/crew/kernr/mingw32/pexports-0.42h.zip).<br />
Get Python23.dll (it should be somewhere on your harddrive).<br />
Run : pexports python23.dll &gt; python23.def<br />
This will extract all symbols from python23.dll and write them into python23.def.<br />
Run : dlltool &#8211;dllname python23.dll &#8211;def python23.def &#8211;output-lib libpython23.a<br />
This will create libpython23.a (dlltool is part of MinGW utilities).<br />
Copy libpython23.a to c:\python23\libs\ (in the same directory as python23.lib).<br />
This trick should work for all Python versions, including future releases of Python. You can also use this trick to convert other libraries.</p>
<p>4. Get and install SWIG<br />
SWIG is a wrapper for C/C++ sources. It allows you to use C/C++ functions and classes to Python with a minimum effort.</p>
<p>Download SWIG binaries for Window ( Swigwin ) from http://www.swig.org, decompress them and add swig directory to your path (the directory where swig.exe is located).</p>
<p>5 . Write .i files<br />
Write the .i files  corresponding to your c++ files ( for more on how to write these files visit www.swig.org )</p>
<p>6 .  Use the following commands to get it going</p>
<p>A . swig –python –c++ example.i</p>
<p>output: example.py &amp; example_wrap.cxx<br />
B. g++ -c *.c++</p>
<p>output:  .o  files corresponding to your C++<br />
C. g++ -c example_wrap.cxx -Ic:\python23\include</p>
<p>output: example_wrap.o<br />
D. g++ -shared *.o -o _example.pyd -Lc:\python23\libs -lpython23</p>
<p>output: _example.pyd</p>
<p>Hopefully this worked . Now you can do an “ import example “ in python .<br />
</span></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/suryagaddipati.wordpress.com/17/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/suryagaddipati.wordpress.com/17/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/suryagaddipati.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/suryagaddipati.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/suryagaddipati.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/suryagaddipati.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/suryagaddipati.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/suryagaddipati.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/suryagaddipati.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/suryagaddipati.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/suryagaddipati.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/suryagaddipati.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/suryagaddipati.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/suryagaddipati.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/suryagaddipati.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/suryagaddipati.wordpress.com/17/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=suryagaddipati.wordpress.com&amp;blog=2167365&amp;post=17&amp;subd=suryagaddipati&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://suryagaddipati.wordpress.com/2008/03/12/creating-python-extensions-in-cc-with-swig-on-windows/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c5a248cded4b8de6ea69feab15a9b6e6?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">suryagaddipati</media:title>
		</media:content>
	</item>
		<item>
		<title>Itunes lyrics importer ..release 0.1</title>
		<link>http://suryagaddipati.wordpress.com/2008/02/21/itunes-lyrics-importer-release-01/</link>
		<comments>http://suryagaddipati.wordpress.com/2008/02/21/itunes-lyrics-importer-release-01/#comments</comments>
		<pubDate>Thu, 21 Feb 2008 21:45:49 +0000</pubDate>
		<dc:creator>suryagaddipati</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://suryagaddipati.wordpress.com/?p=15</guid>
		<description><![CDATA[I finally managed to get a 0.1 release out of the door for my breakable toy itunes-importer . This is a windows only release , I still have to iron out few kinks for the Mac version . You can choose the providers which get queried and can edit ( or paste your own) lyrics [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=suryagaddipati.wordpress.com&amp;blog=2167365&amp;post=15&amp;subd=suryagaddipati&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I finally managed to get a 0.1 release out of the door for my <a href="http://softwarecraftsmanship.oreilly.com/wiki/show/chapter-22-breakable-toys#breakable_toys" title="Breakable toy" target="_blank">breakable toy</a>  <a href="http://code.google.com/p/lyricstune/" title="lyrics importer">itunes-importer</a>  .</p>
<p>This is a windows only release  , I still have to iron out few kinks for the Mac version .</p>
<p>You can choose the providers which get queried and can edit ( or paste your own) lyrics before applying them to a track.</p>
<p>The UI is primitive ( but usable ) , on which I plan to work after I get the mac version working.</p>
<p><a href="http://suryagaddipati.files.wordpress.com/2008/02/lyrics-doctor01.jpg" title="lyrics importer 0.1"><img src="http://suryagaddipati.files.wordpress.com/2008/02/lyrics-doctor01.jpg?w=500" alt="lyrics importer 0.1" /></a></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/suryagaddipati.wordpress.com/15/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/suryagaddipati.wordpress.com/15/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/suryagaddipati.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/suryagaddipati.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/suryagaddipati.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/suryagaddipati.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/suryagaddipati.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/suryagaddipati.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/suryagaddipati.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/suryagaddipati.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/suryagaddipati.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/suryagaddipati.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/suryagaddipati.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/suryagaddipati.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/suryagaddipati.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/suryagaddipati.wordpress.com/15/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=suryagaddipati.wordpress.com&amp;blog=2167365&amp;post=15&amp;subd=suryagaddipati&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://suryagaddipati.wordpress.com/2008/02/21/itunes-lyrics-importer-release-01/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c5a248cded4b8de6ea69feab15a9b6e6?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">suryagaddipati</media:title>
		</media:content>

		<media:content url="http://suryagaddipati.files.wordpress.com/2008/02/lyrics-doctor01.jpg" medium="image">
			<media:title type="html">lyrics importer 0.1</media:title>
		</media:content>
	</item>
	</channel>
</rss>
