<?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/"
	>

<channel>
	<title>cat brain.stuff &#62; wordpress &#187; Coding</title>
	<atom:link href="http://famvdploeg.com/blog/category/coding/feed/" rel="self" type="application/rss+xml" />
	<link>http://famvdploeg.com/blog</link>
	<description>A simple look on things</description>
	<lastBuildDate>Wed, 21 Mar 2012 19:47:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>jQuery + Fancybox + Vimeo PlugIn</title>
		<link>http://famvdploeg.com/blog/2012/02/jquery-fancybox-vimeo-plugin/</link>
		<comments>http://famvdploeg.com/blog/2012/02/jquery-fancybox-vimeo-plugin/#comments</comments>
		<pubDate>Fri, 03 Feb 2012 15:06:14 +0000</pubDate>
		<dc:creator>Wytze</dc:creator>
				<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://famvdploeg.com/blog/?p=299</guid>
		<description><![CDATA[Just a small jQuery plugin that I wrote to quickly add playing of vimeo clips in a fancybox (unobtrusive). &#40;function &#40;$&#41; &#123; $.fn.vimeoInFancybox = function &#40;options&#41; &#123; var opts = $.extend&#40;&#123;&#125;, $.fn.vimeoInFancybox.defaults, options&#41;; &#160; $&#40;this&#41;.each&#40;function &#40;&#41; &#123; var url = $&#40;this&#41;.attr&#40;&#34;href&#34;&#41;; var optionRegex = new RegExp&#40;&#34;.*?/([\\d]+)$&#34;&#41;; var vimeoId = optionRegex.exec&#40;url&#41;&#91;1&#93;; var playerUrl = &#34;http://player.vimeo.com/video/&#34; + [...]]]></description>
			<content:encoded><![CDATA[<p>Just a small jQuery plugin that I wrote to quickly add playing of vimeo clips in a fancybox (unobtrusive).</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    $.<span style="color: #660066;">fn</span>.<span style="color: #660066;">vimeoInFancybox</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>options<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003366; font-weight: bold;">var</span> opts <span style="color: #339933;">=</span> $.<span style="color: #660066;">extend</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> $.<span style="color: #660066;">fn</span>.<span style="color: #660066;">vimeoInFancybox</span>.<span style="color: #660066;">defaults</span><span style="color: #339933;">,</span> options<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #003366; font-weight: bold;">var</span> url <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;href&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #003366; font-weight: bold;">var</span> optionRegex <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> RegExp<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.*?/([<span style="color: #000099; font-weight: bold;">\\</span>d]+)$&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #003366; font-weight: bold;">var</span> vimeoId <span style="color: #339933;">=</span> optionRegex.<span style="color: #660066;">exec</span><span style="color: #009900;">&#40;</span>url<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
            <span style="color: #003366; font-weight: bold;">var</span> playerUrl <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;http://player.vimeo.com/video/&quot;</span> <span style="color: #339933;">+</span> vimeoId<span style="color: #339933;">;</span>
&nbsp;
            $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">fancybox</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
                href<span style="color: #339933;">:</span> playerUrl<span style="color: #339933;">,</span>
                type<span style="color: #339933;">:</span> <span style="color: #3366CC;">'iframe'</span><span style="color: #339933;">,</span>
                width<span style="color: #339933;">:</span> opts.<span style="color: #660066;">width</span><span style="color: #339933;">,</span>
                height<span style="color: #339933;">:</span> opts.<span style="color: #660066;">height</span>
            <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
    $.<span style="color: #660066;">fn</span>.<span style="color: #660066;">vimeoInFancybox</span>.<span style="color: #660066;">defaults</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
        width<span style="color: #339933;">:</span> <span style="color: #CC0000;">640</span><span style="color: #339933;">,</span>
        height<span style="color: #339933;">:</span> <span style="color: #CC0000;">480</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>jQuery<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
$<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;a.fancybox-vimeo&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">vimeoInFancybox</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Example: (Just include the js on the page in a javascript tag or in a separate file that is included)</p>

<div class="wp_syntax"><div class="code"><pre class="html4" style="font-family:monospace;">&lt;a href=&quot;http://vimeo.com/1084537&quot; class=&quot;fancybox-vimeo&quot;&gt;Add image here if you want&lt;/a&gt;</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://famvdploeg.com/blog/2012/02/jquery-fancybox-vimeo-plugin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery + CSS3 rotating panel</title>
		<link>http://famvdploeg.com/blog/2012/01/jquery-css3-rotating-panel/</link>
		<comments>http://famvdploeg.com/blog/2012/01/jquery-css3-rotating-panel/#comments</comments>
		<pubDate>Tue, 17 Jan 2012 19:58:07 +0000</pubDate>
		<dc:creator>Wytze</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[flip]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[rotate]]></category>
		<category><![CDATA[rotate panel]]></category>
		<category><![CDATA[switch]]></category>

		<guid isPermaLink="false">http://famvdploeg.com/blog/?p=289</guid>
		<description><![CDATA[This is just a small proof of concept (so don&#8217;t blame me for the lame CSS I created. ). I found out it can be done nicer. (Read this awesome article about flip effects) I only do 90 degree rotations on the Y-axis and do no backside-hiding. The idea is that a visible panel is [...]]]></description>
			<content:encoded><![CDATA[<p>This is just a small proof of concept (so don&#8217;t blame me for the lame CSS I created. <img src='http://famvdploeg.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> ).<br />
I found out it can be done nicer. (<a href="http://line25.com/articles/super-cool-css-flip-effect-with-webkit-animation">Read this awesome article about flip effects</a>) I only do 90 degree rotations on the Y-axis and do no backside-hiding.</p>
<p>The idea is that a visible panel is seemingly rotated and the backside becomes visible. This works by using transition events. The 1st panel is visible at start and the 2nd panel is hidden. Then when an event is triggered (Hovered in this example) the 1st panel will be rotated 90 degrees (y-axis). The panel is then invisible the animation is ended and an event is triggered. At that point the 2nd panel is made visible and an class is added to trigger to animate it from 90 degrees back to 0 degrees. Thus creating an animation which makes it seem like the panel was completely rotated.</p>
<p>The implementation is currently only working for webkit based browsers.</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #00bbdd;">&lt;!DOCTYPE HTML&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">html</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">style</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/css&quot;</span>&gt;</span> 
		div#slide1
		{
		    width:100px;
		    height:100px;
		    background:red;
		    -webkit-transition: -webkit-transform 0.5s ease-in;
		}
&nbsp;
		div#slide2
		{
		    width:100px;
		    height:100px;
		    background:green;
		    -webkit-transform: rotateY(90deg);
		    -webkit-transition: -webkit-transform 0.5s ease-in;
		}
&nbsp;
		div#slide1:hover
		{
		    -webkit-transform: rotateY(90deg);
		}
&nbsp;
		div#slide2.foo
		{
		    -webkit-transform: rotateY(0deg);
		}
	<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">style</span>&gt;</span>
&nbsp;
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;</span>
		document.addEventListener(
			'webkitTransitionEnd', 
			function( event ) {
				$(&quot;#slide1&quot;).hide();
				$(&quot;#slide2&quot;).show().addClass(&quot;foo&quot;);
			}, false );
	<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">b</span>&gt;</span>Note:<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">b</span>&gt;</span> This example does not work in Internet Explorer.<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;</span>
&nbsp;
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;slide1&quot;</span>&gt;</span>Test<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;slide2&quot;</span> <span style="color: #000066;">style</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;display: none;&quot;</span>&gt;</span>Awesome<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
&nbsp;
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;</span>Hover over the div element above, to see the transition effect.<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">html</span>&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://famvdploeg.com/blog/2012/01/jquery-css3-rotating-panel/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adding awesomeness on the run with javassist</title>
		<link>http://famvdploeg.com/blog/2012/01/adding-awesomeness-on-the-run-with-javassist/</link>
		<comments>http://famvdploeg.com/blog/2012/01/adding-awesomeness-on-the-run-with-javassist/#comments</comments>
		<pubDate>Tue, 17 Jan 2012 09:04:21 +0000</pubDate>
		<dc:creator>Wytze</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[javassist]]></category>
		<category><![CDATA[new class]]></category>
		<category><![CDATA[new method]]></category>
		<category><![CDATA[runtime]]></category>

		<guid isPermaLink="false">http://famvdploeg.com/blog/?p=287</guid>
		<description><![CDATA[Creating new classes during runtime can be nice when you need it. Below is a small example of what is possible. (No interface or existing base class is used in this example so reflection is required to invoke a method) ClassPool classPool = ClassPool.getDefault&#40;&#41;; CtClass cc = classPool.makeClass&#40;&#34;AwesomeNewClass&#34;&#41;; cc.addMethod&#40;CtMethod.make&#40;&#34;public String getValue() { return \&#34;Hello World!\&#34;; [...]]]></description>
			<content:encoded><![CDATA[<p>Creating new classes during runtime can be nice when you need it. Below is a small example of what is possible. (No interface or existing base class is used in this example so reflection is required to invoke a method)</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">ClassPool classPool <span style="color: #339933;">=</span> ClassPool.<span style="color: #006633;">getDefault</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
CtClass cc <span style="color: #339933;">=</span> classPool.<span style="color: #006633;">makeClass</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;AwesomeNewClass&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
cc.<span style="color: #006633;">addMethod</span><span style="color: #009900;">&#40;</span>CtMethod.<span style="color: #006633;">make</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;public String getValue() { return <span style="color: #000099; font-weight: bold;">\&quot;</span>Hello World!<span style="color: #000099; font-weight: bold;">\&quot;</span>; }&quot;</span>, cc<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">Class</span> awesome <span style="color: #339933;">=</span> cc.<span style="color: #006633;">toClass</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003399;">Object</span> o <span style="color: #339933;">=</span> awesome.<span style="color: #006633;">newInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003399;">Method</span> method <span style="color: #339933;">=</span> awesome.<span style="color: #006633;">getMethod</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;getValue&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003399;">String</span> returnValue <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#41;</span> method.<span style="color: #006633;">invoke</span><span style="color: #009900;">&#40;</span>o<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://famvdploeg.com/blog/2012/01/adding-awesomeness-on-the-run-with-javassist/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NHibernate SqlAliasCriterion and Random sorting</title>
		<link>http://famvdploeg.com/blog/2011/12/nhibernate-sqlaliascriterion/</link>
		<comments>http://famvdploeg.com/blog/2011/12/nhibernate-sqlaliascriterion/#comments</comments>
		<pubDate>Fri, 30 Dec 2011 10:35:19 +0000</pubDate>
		<dc:creator>Wytze</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[alias]]></category>
		<category><![CDATA[criterion]]></category>
		<category><![CDATA[nhibernate]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://famvdploeg.com/blog/?p=280</guid>
		<description><![CDATA[Wrote this custom NHibernate Criterion to be able to add custom SQL snippets with alias support when using criteria. public class SqlAliasCriterion : SQLCriterion &#123; private string sql; &#160; public SqlAliasCriterion&#40;string sql&#41; : base&#40;new SqlString&#40;sql&#41;, new string&#91;0&#93;, new IType&#91;0&#93;&#41; &#123; this.sql = sql; &#125; &#160; public override SqlString ToSqlString&#40;ICriteria criteria, ICriteriaQuery criteriaQuery, IDictionary&#60;string, IFilter&#62; enabledFilters&#41; [...]]]></description>
			<content:encoded><![CDATA[<p>Wrote this custom NHibernate Criterion to be able to add custom SQL snippets with alias support when using criteria.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> SqlAliasCriterion <span style="color: #008000;">:</span> SQLCriterion
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">string</span> sql<span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">public</span> SqlAliasCriterion<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> sql<span style="color: #008000;">&#41;</span>
            <span style="color: #008000;">:</span> <span style="color: #0600FF; font-weight: bold;">base</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">new</span> SqlString<span style="color: #008000;">&#40;</span>sql<span style="color: #008000;">&#41;</span>, <span style="color: #008000;">new</span> <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&#91;</span><span style="color: #FF0000;">0</span><span style="color: #008000;">&#93;</span>, <span style="color: #008000;">new</span> IType<span style="color: #008000;">&#91;</span><span style="color: #FF0000;">0</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">sql</span> <span style="color: #008000;">=</span> sql<span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">override</span> SqlString ToSqlString<span style="color: #008000;">&#40;</span>ICriteria criteria, ICriteriaQuery criteriaQuery, IDictionary<span style="color: #008000;">&lt;</span><span style="color: #6666cc; font-weight: bold;">string</span>, IFilter<span style="color: #008000;">&gt;</span> enabledFilters<span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            <span style="color: #6666cc; font-weight: bold;">string</span> replacedString <span style="color: #008000;">=</span> Regex<span style="color: #008000;">.</span><span style="color: #0000FF;">Replace</span><span style="color: #008000;">&#40;</span>
                sql,
                <span style="color: #666666;">@&quot;{([a-zA-Z_]((\.)?[a-zA-Z0-9_])*)}&quot;</span>,
                m <span style="color: #008000;">=&gt;</span>
                <span style="color: #008000;">&#123;</span>
                    ICriteria critter <span style="color: #008000;">=</span> criteria<span style="color: #008000;">.</span><span style="color: #0000FF;">GetCriteriaByAlias</span><span style="color: #008000;">&#40;</span>m<span style="color: #008000;">.</span><span style="color: #0000FF;">Groups</span><span style="color: #008000;">&#91;</span><span style="color: #FF0000;">1</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Value</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
                    <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>critter <span style="color: #008000;">!=</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span>
                    <span style="color: #008000;">&#123;</span>
                        <span style="color: #0600FF; font-weight: bold;">return</span> criteriaQuery<span style="color: #008000;">.</span><span style="color: #0000FF;">GetSQLAlias</span><span style="color: #008000;">&#40;</span>critter<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
                    <span style="color: #008000;">&#125;</span>
&nbsp;
                    <span style="color: #0600FF; font-weight: bold;">return</span> m<span style="color: #008000;">.</span><span style="color: #0000FF;">Groups</span><span style="color: #008000;">&#91;</span><span style="color: #FF0000;">0</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Value</span><span style="color: #008000;">;</span>
                <span style="color: #008000;">&#125;</span>
            <span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #008000;">new</span> SqlString<span style="color: #008000;">&#40;</span>replacedString<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
    <span style="color: #008000;">&#125;</span></pre></div></div>

<p>Usage example:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">return</span> Session<span style="color: #008000;">.</span><span style="color: #0000FF;">CreateCriteria</span><span style="color: #008000;">&lt;</span>YourClass<span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;x&quot;</span><span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">new</span> SqlAliasCriterion<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;{x}.YourField = SomeNativeSQLFunc(foo)&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">.</span><span style="color: #0000FF;">List</span><span style="color: #008000;">&lt;</span>YourClass<span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></pre></div></div>

<p>You can use the same trick to do ordering. (We use this for native MSSQL random ordering)</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> OrderBySql <span style="color: #008000;">:</span> Order
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">string</span> sql<span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">public</span> OrderBySql<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> sql, <span style="color: #6666cc; font-weight: bold;">bool</span> ascending<span style="color: #008000;">&#41;</span>
            <span style="color: #008000;">:</span> <span style="color: #0600FF; font-weight: bold;">base</span><span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">String</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Empty</span>, ascending<span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">sql</span> <span style="color: #008000;">=</span> sql<span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">override</span> SqlString ToSqlString<span style="color: #008000;">&#40;</span>ICriteria criteria, ICriteriaQuery criteriaQuery<span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            <span style="color: #6666cc; font-weight: bold;">string</span> replacedString <span style="color: #008000;">=</span> Regex<span style="color: #008000;">.</span><span style="color: #0000FF;">Replace</span><span style="color: #008000;">&#40;</span>
                sql,
                <span style="color: #666666;">@&quot;{([a-zA-Z_]((\.)?[a-zA-Z0-9_])*)}&quot;</span>,
                m <span style="color: #008000;">=&gt;</span>
                <span style="color: #008000;">&#123;</span>
                    ICriteria critter <span style="color: #008000;">=</span> criteria<span style="color: #008000;">.</span><span style="color: #0000FF;">GetCriteriaByAlias</span><span style="color: #008000;">&#40;</span>m<span style="color: #008000;">.</span><span style="color: #0000FF;">Groups</span><span style="color: #008000;">&#91;</span><span style="color: #FF0000;">1</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Value</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
                    <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>critter <span style="color: #008000;">!=</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span>
                    <span style="color: #008000;">&#123;</span>
                        <span style="color: #0600FF; font-weight: bold;">return</span> criteriaQuery<span style="color: #008000;">.</span><span style="color: #0000FF;">GetSQLAlias</span><span style="color: #008000;">&#40;</span>critter<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
                    <span style="color: #008000;">&#125;</span>
&nbsp;
                    <span style="color: #0600FF; font-weight: bold;">return</span> m<span style="color: #008000;">.</span><span style="color: #0000FF;">Groups</span><span style="color: #008000;">&#91;</span><span style="color: #FF0000;">0</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Value</span><span style="color: #008000;">;</span>
                <span style="color: #008000;">&#125;</span>
            <span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #008000;">new</span> SqlString<span style="color: #008000;">&#40;</span>replacedString <span style="color: #008000;">+</span> <span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">ascending</span> <span style="color: #008000;">?</span> <span style="color: #666666;">&quot; ASC&quot;</span> <span style="color: #008000;">:</span> <span style="color: #666666;">&quot; DESC&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
    <span style="color: #008000;">&#125;</span></pre></div></div>

<p>Example with random sorting (MSSQL):</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">criteria<span style="color: #008000;">.</span><span style="color: #0000FF;">addOrder</span><span style="color: #008000;">&#40;</span>
    <span style="color: #008000;">new</span> OrderBySql<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;NEWID()&quot;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://famvdploeg.com/blog/2011/12/nhibernate-sqlaliascriterion/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HTML5 Sample Gallery</title>
		<link>http://famvdploeg.com/blog/2011/12/html5-sample-gallery/</link>
		<comments>http://famvdploeg.com/blog/2011/12/html5-sample-gallery/#comments</comments>
		<pubDate>Tue, 20 Dec 2011 23:42:17 +0000</pubDate>
		<dc:creator>Wytze</dc:creator>
				<category><![CDATA[Coding]]></category>

		<guid isPermaLink="false">http://famvdploeg.com/blog/?p=277</guid>
		<description><![CDATA[Came across this excellent presentation which covers (all?) new features of HTML5. Have a look at the html5rocks site.]]></description>
			<content:encoded><![CDATA[<p>Came across this excellent presentation which covers (all?) new features of HTML5. Have a look at the <a href="http://slides.html5rocks.com">html5rocks</a> site.</p>
]]></content:encoded>
			<wfw:commentRss>http://famvdploeg.com/blog/2011/12/html5-sample-gallery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>C# CacheHelper</title>
		<link>http://famvdploeg.com/blog/2011/12/c-cachehelper/</link>
		<comments>http://famvdploeg.com/blog/2011/12/c-cachehelper/#comments</comments>
		<pubDate>Mon, 19 Dec 2011 15:27:39 +0000</pubDate>
		<dc:creator>Wytze</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[cache]]></category>
		<category><![CDATA[csharp]]></category>
		<category><![CDATA[helper]]></category>

		<guid isPermaLink="false">http://famvdploeg.com/blog/?p=271</guid>
		<description><![CDATA[Just a simple class I put together for easy cache handling. public class CacheHelper &#123; private static readonly ILog logger = LogManager.GetLogger&#40;typeof&#40;CacheHelper&#41;&#41;; &#160; public static T CachedResult&#60;T&#62;&#40;string key, Func&#60;T&#62; valueRetrieval, double timeout = 5&#41; &#123; T result = &#40;T&#41;HttpContext.Current.Cache&#91;key&#93;; if &#40;result == null&#41; &#123; logger.InfoFormat&#40;&#34;Cached item with key: {0} not found in Cache, fetching value&#34;, [...]]]></description>
			<content:encoded><![CDATA[<p>Just a simple class I put together for easy cache handling.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> CacheHelper
<span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #0600FF; font-weight: bold;">readonly</span> ILog logger <span style="color: #008000;">=</span> LogManager<span style="color: #008000;">.</span><span style="color: #0000FF;">GetLogger</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">typeof</span><span style="color: #008000;">&#40;</span>CacheHelper<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">static</span> T CachedResult<span style="color: #008000;">&lt;</span>T<span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> key, Func<span style="color: #008000;">&lt;</span>T<span style="color: #008000;">&gt;</span> valueRetrieval, <span style="color: #6666cc; font-weight: bold;">double</span> timeout <span style="color: #008000;">=</span> <span style="color: #FF0000;">5</span><span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        T result <span style="color: #008000;">=</span> <span style="color: #008000;">&#40;</span>T<span style="color: #008000;">&#41;</span>HttpContext<span style="color: #008000;">.</span><span style="color: #0000FF;">Current</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Cache</span><span style="color: #008000;">&#91;</span>key<span style="color: #008000;">&#93;</span><span style="color: #008000;">;</span>
        <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>result <span style="color: #008000;">==</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            logger<span style="color: #008000;">.</span><span style="color: #0000FF;">InfoFormat</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Cached item with key: {0} not found in Cache, fetching value&quot;</span>, key<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            result <span style="color: #008000;">=</span> valueRetrieval<span style="color: #008000;">.</span><span style="color: #0000FF;">Invoke</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            HttpContext<span style="color: #008000;">.</span><span style="color: #0000FF;">Current</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Cache</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Insert</span><span style="color: #008000;">&#40;</span>key, result, <span style="color: #0600FF; font-weight: bold;">null</span>, DateTime<span style="color: #008000;">.</span><span style="color: #0000FF;">Now</span><span style="color: #008000;">.</span><span style="color: #0000FF;">AddMinutes</span><span style="color: #008000;">&#40;</span>timeout<span style="color: #008000;">&#41;</span>, Cache<span style="color: #008000;">.</span><span style="color: #0000FF;">NoSlidingExpiration</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
        <span style="color: #0600FF; font-weight: bold;">else</span>
        <span style="color: #008000;">&#123;</span>
            logger<span style="color: #008000;">.</span><span style="color: #0000FF;">DebugFormat</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Cached item with key: {0} retrieved from Cache&quot;</span>, key<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">return</span> result<span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p>Usage example:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">RssFeed rssFeed <span style="color: #008000;">=</span> CacheHelper<span style="color: #008000;">.</span><span style="color: #0000FF;">CachedResult</span><span style="color: #008000;">&lt;</span>RssFeed<span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span>url, <span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">=&gt;</span> TwitterApplication<span style="color: #008000;">.</span><span style="color: #0000FF;">GetPublicTimelineFeed</span><span style="color: #008000;">&#40;</span>url<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://famvdploeg.com/blog/2011/12/c-cachehelper/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Knockout JS</title>
		<link>http://famvdploeg.com/blog/2011/12/knockout-js/</link>
		<comments>http://famvdploeg.com/blog/2011/12/knockout-js/#comments</comments>
		<pubDate>Thu, 15 Dec 2011 21:14:14 +0000</pubDate>
		<dc:creator>Wytze</dc:creator>
				<category><![CDATA[Coding]]></category>

		<guid isPermaLink="false">http://famvdploeg.com/blog/?p=268</guid>
		<description><![CDATA[A friend of mine showed me the Knockout JavaScript Framework today. Seems quite promising. I love the idea of data-binding. When putting together a new view I most often want to start from static html and add unobtrusive javascript from there to add dynamic functionality. I hope this new framework will stack well with jQuery.]]></description>
			<content:encoded><![CDATA[<p>A friend of mine showed me the <a href="http://www.knockoutjs.com" target="_blank">Knockout JavaScript Framework</a> today. Seems quite promising. I love the idea of data-binding.<br />
When putting together a new view I most often want to start from static html and add unobtrusive javascript from there to add dynamic functionality. I hope this new framework will stack well with jQuery.</p>
]]></content:encoded>
			<wfw:commentRss>http://famvdploeg.com/blog/2011/12/knockout-js/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MSSQL Restore locked database</title>
		<link>http://famvdploeg.com/blog/2011/10/mssql-restore-locked-database/</link>
		<comments>http://famvdploeg.com/blog/2011/10/mssql-restore-locked-database/#comments</comments>
		<pubDate>Tue, 18 Oct 2011 10:07:27 +0000</pubDate>
		<dc:creator>Wytze</dc:creator>
				<category><![CDATA[SQL]]></category>
		<category><![CDATA[locked]]></category>
		<category><![CDATA[mssql]]></category>
		<category><![CDATA[restore database]]></category>

		<guid isPermaLink="false">http://famvdploeg.com/blog/?p=256</guid>
		<description><![CDATA[Below is a short snippet that will allow you to restore your database by putting it in single user mode. After restoring (if without errors) it will be in multi user mode again. If it is not you can still run the &#8216;alter database DATABASE_NAME set multi_user&#8217; command to put it back in original mode. [...]]]></description>
			<content:encoded><![CDATA[<p>Below is a short snippet that will allow you to restore your database by putting it in single user mode.<br />
After restoring (if without errors) it will be in multi user mode again. If it is not you can still run the &#8216;alter database DATABASE_NAME set multi_user&#8217; command to put it back in original mode.</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">USE</span> master;
&nbsp;
<span style="color: #993333; font-weight: bold;">ALTER</span> <span style="color: #993333; font-weight: bold;">DATABASE</span> <span style="color: #66cc66;">&#91;</span>DATABASE_NAME<span style="color: #66cc66;">&#93;</span> <span style="color: #993333; font-weight: bold;">SET</span> single_user <span style="color: #993333; font-weight: bold;">WITH</span> <span style="color: #993333; font-weight: bold;">ROLLBACK</span> immediate;
&nbsp;
restore <span style="color: #993333; font-weight: bold;">DATABASE</span> <span style="color: #66cc66;">&#91;</span>DATABASE_NAME<span style="color: #66cc66;">&#93;</span> <span style="color: #993333; font-weight: bold;">FROM</span> disk <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'C:<span style="color: #000099; font-weight: bold;">\P</span>rogram Files<span style="color: #000099; font-weight: bold;">\M</span>icrosoft SQL Server<span style="color: #000099; font-weight: bold;">\M</span>SSQL10.MSSQLSERVER<span style="color: #000099; font-weight: bold;">\M</span>SSQL<span style="color: #000099; font-weight: bold;">\B</span>ackup<span style="color: #000099; font-weight: bold;">\Y</span>OUR_AWESOME_BACKUP.bak'</span>;</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://famvdploeg.com/blog/2011/10/mssql-restore-locked-database/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MSSQL Changing login for user</title>
		<link>http://famvdploeg.com/blog/2011/10/mssql-changing-login-for-user/</link>
		<comments>http://famvdploeg.com/blog/2011/10/mssql-changing-login-for-user/#comments</comments>
		<pubDate>Tue, 18 Oct 2011 09:53:04 +0000</pubDate>
		<dc:creator>Wytze</dc:creator>
				<category><![CDATA[SQL]]></category>
		<category><![CDATA[alter user]]></category>
		<category><![CDATA[login]]></category>
		<category><![CDATA[mssql]]></category>

		<guid isPermaLink="false">http://famvdploeg.com/blog/?p=254</guid>
		<description><![CDATA[Sometimes when you move a database to another server it is necessary to change the login for a user to match the new environment. You can use the alter user command to do this. Do something like the following: ALTER USER &#91;THE_USER_NAME&#93; WITH NAME = NEW_USER_NAME, LOGIN = &#91;MACHINENAME\NEW_USER_NAME&#93;; Not really complicated, but handy when [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes when you move a database to another server it is necessary to change the login for a user to match the new environment. You can use the alter user command to do this. Do something like the following:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">ALTER</span> <span style="color: #993333; font-weight: bold;">USER</span> <span style="color: #66cc66;">&#91;</span>THE_USER_NAME<span style="color: #66cc66;">&#93;</span> <span style="color: #993333; font-weight: bold;">WITH</span> NAME <span style="color: #66cc66;">=</span> NEW_USER_NAME<span style="color: #66cc66;">,</span> LOGIN <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#91;</span>MACHINENAME\NEW_USER_NAME<span style="color: #66cc66;">&#93;</span>;</pre></div></div>

<p>Not really complicated, but handy when you need it. <img src='http://famvdploeg.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://famvdploeg.com/blog/2011/10/mssql-changing-login-for-user/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Visual Studio, Attach debugger to w3wp process through macro</title>
		<link>http://famvdploeg.com/blog/2011/10/visual-studio-attach-debugger-to-w3wp-process-through-macro/</link>
		<comments>http://famvdploeg.com/blog/2011/10/visual-studio-attach-debugger-to-w3wp-process-through-macro/#comments</comments>
		<pubDate>Wed, 12 Oct 2011 18:38:48 +0000</pubDate>
		<dc:creator>Wytze</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[attach debugger]]></category>
		<category><![CDATA[macro]]></category>
		<category><![CDATA[visual studio]]></category>
		<category><![CDATA[w3wp]]></category>
		<category><![CDATA[w3wp.exe]]></category>

		<guid isPermaLink="false">http://famvdploeg.com/blog/?p=244</guid>
		<description><![CDATA[Here is a short macro that will attach the debugger to the first w3wp.exe process it can find in the process list. (Script assumes a w3wp.exe process is running. Expect error messages if it doesn&#8217;t ) Imports System Imports EnvDTE Imports EnvDTE80 Imports EnvDTE90 Imports System.Diagnostics &#160; Public Module Famvdploeg 'Attach the debugger to a [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a short macro that will attach the debugger to the first w3wp.exe process it can find in the process list. (Script assumes a w3wp.exe process is running. Expect error messages if it doesn&#8217;t <img src='http://famvdploeg.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> )</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;">Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports System.Diagnostics
&nbsp;
<span style="color: #E56717; font-weight: bold;">Public</span> Module Famvdploeg
    <span style="color: #008000;">'Attach the debugger to a w3wp.exe process
</span>    <span style="color: #E56717; font-weight: bold;">Sub</span> AttachDebugger()
        Try
            <span style="color: #008000;">'Get your hostname
</span>            <span style="color: #151B8D; font-weight: bold;">Dim</span> hostname <span style="color: #151B8D; font-weight: bold;">As</span> <span style="color: #F660AB; font-weight: bold;">String</span> = System.Net.Dns.GetHostName
            <span style="color: #008000;">'Load the debugger interface
</span>            <span style="color: #151B8D; font-weight: bold;">Dim</span> debugger <span style="color: #151B8D; font-weight: bold;">As</span> EnvDTE80.Debugger2 = DTE.Debugger
            <span style="color: #008000;">'Get a local transport, (this is the &quot;Default&quot;)
</span>            <span style="color: #151B8D; font-weight: bold;">Dim</span> trans <span style="color: #151B8D; font-weight: bold;">As</span> EnvDTE80.Transport = debugger.Transports.Item(<span style="color: #800000;">&quot;Default&quot;</span>)
&nbsp;
            <span style="color: #008000;">'Attach to the first w3wp.exe command which we find
</span>            <span style="color: #151B8D; font-weight: bold;">Dim</span> dbgeng(3) <span style="color: #151B8D; font-weight: bold;">As</span> EnvDTE80.Engine
            dbgeng(0) = trans.Engines.Item(<span style="color: #800000;">&quot;T-SQL&quot;</span>)
            dbgeng(1) = trans.Engines.Item(<span style="color: #800000;">&quot;T-SQL&quot;</span>)
            dbgeng(2) = trans.Engines.Item(<span style="color: #800000;">&quot;Managed&quot;</span>)
            <span style="color: #151B8D; font-weight: bold;">Dim</span> process <span style="color: #151B8D; font-weight: bold;">As</span> EnvDTE80.Process2 = debugger.GetProcesses(trans, hostname).Item(<span style="color: #800000;">&quot;w3wp.exe&quot;</span>)
            process.Attach2(dbgeng)
        Catch ex <span style="color: #151B8D; font-weight: bold;">As</span> System.Exception
            MsgBox(ex.Message)
        <span style="color: #8D38C9; font-weight: bold;">End</span> Try
&nbsp;
    <span style="color: #8D38C9; font-weight: bold;">End</span> <span style="color: #E56717; font-weight: bold;">Sub</span>
<span style="color: #8D38C9; font-weight: bold;">End</span> Module</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://famvdploeg.com/blog/2011/10/visual-studio-attach-debugger-to-w3wp-process-through-macro/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

