<?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>Rash thoughts about .NET, C#, F# and Dynamics NAV. &#187; C#</title>
	<atom:link href="http://www.navision-blog.de/tag/c/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.navision-blog.de</link>
	<description>This Blog is about Microsoft Dynamics NAV (f.k.a Navision incl. C/SIDE and C/AL), C#, F# and .NET in general.</description>
	<lastBuildDate>Wed, 14 Jul 2010 11:12:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Observing global hotkeys in C# / F#</title>
		<link>http://www.navision-blog.de/2009/11/06/observing-global-shortcuts/</link>
		<comments>http://www.navision-blog.de/2009/11/06/observing-global-shortcuts/#comments</comments>
		<pubDate>Fri, 06 Nov 2009 10:08:05 +0000</pubDate>
		<dc:creator>Steffen Forkmann</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[F#]]></category>
		<category><![CDATA[Hotkey]]></category>
		<category><![CDATA[PInvoke]]></category>
		<category><![CDATA[win32]]></category>

		<guid isPermaLink="false">http://www.navision-blog.de/2009/11/06/observing-global-shortcuts/</guid>
		<description><![CDATA[I recently had the problem to register a global hotkey, but my “old” Win32-API calls didn’t work with WPF. I looked around the web and found the “Managed Windows API”, but I didn’t want to add another external dependency to my project, so I extracted the core functions for registering hotkeys and condensed the code [...]]]></description>
			<content:encoded><![CDATA[<p>I recently had the problem to register a global hotkey, but my “old” Win32-API calls didn’t work with WPF. I looked around the web and found the “<a href="http://mwinapi.sourceforge.net/">Managed Windows API</a>”, but I didn’t want to add another external dependency to my project, so I extracted the core functions for registering hotkeys and condensed the code to a new version. </p>
<p>As the original “Managed Windows API” is licensed by the GNU Lesser General Public License (LGPL) I want to provide my modifications here.</p>
<p>First we need a Window which can dispatch the window messages to our event handlers:</p>
<div style="font-family: courier new; background: white; color: black; font-size: 10pt">
<p style="margin: 0px"><span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;summary&gt;</span></p>
<p style="margin: 0px"><span style="color: gray">///</span><span style="color: green"> A Win32 native window that delegates window messages to </span></p>
<p style="margin: 0px"><span style="color: gray">///</span><span style="color: green"> </span><span style="color: green">handlers. So several</span></p>
<p style="margin: 0px"><span style="color: gray">///</span><span style="color: green"> components can use the same native window to save </span></p>
<p style="margin: 0px"><span style="color: gray">///</span><span style="color: green"> </span><span style="color: green">&quot;USER resources&quot;. This class</span></p>
<p style="margin: 0px"><span style="color: gray">///</span><span style="color: green"> is useful when writing your own components.</span></p>
<p style="margin: 0px"><span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;/summary&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">public</span> <span style="color: blue">sealed</span> <span style="color: blue">class</span> <span style="color: #2b91af">EventDispatchingNativeWindow</span> : <span style="color: #2b91af">NativeWindow</span></p>
<p style="margin: 0px">{</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: blue">private</span> <span style="color: blue">static</span> <span style="color: blue">readonly</span> <span style="color: #2b91af">Object</span> MyLock = <span style="color: blue">new</span> <span style="color: #2b91af">Object</span>();</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: blue">private</span> <span style="color: blue">static</span> <span style="color: #2b91af">EventDispatchingNativeWindow</span> _instance;</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;summary&gt;</span></p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> Create your own event dispatching window.</span></p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;/summary&gt;</span></p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: blue">public</span> EventDispatchingNativeWindow()</p>
<p style="margin: 0px">&#160;&#160;&#160; {</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; CreateHandle(<span style="color: blue">new</span> <span style="color: #2b91af">CreateParams</span>());</p>
<p style="margin: 0px">&#160;&#160;&#160; }</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;summary&gt;</span></p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> A global instance which can be used by components </span></p>
<p style="margin: 0px"><span style="color: green">&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span>that do not need</span><span style="color: green"> their own window.</span></p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;/summary&gt;</span></p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: blue">public</span> <span style="color: blue">static</span> <span style="color: #2b91af">EventDispatchingNativeWindow</span> Instance</p>
<p style="margin: 0px">&#160;&#160;&#160; {</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">get</span></p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">lock</span> (MyLock)</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">return</span> </p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; _instance ?? </p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; (_instance = </p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">new</span> <span style="color: #2b91af">EventDispatchingNativeWindow</span>());</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p style="margin: 0px">&#160;&#160;&#160; }</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;summary&gt;</span></p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> Attach your event handlers here.</span></p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;/summary&gt;</span></p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: blue">public</span> <span style="color: blue">event</span> <span style="color: #2b91af">WndProcEventHandler</span> EventHandler;</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;summary&gt;</span></p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> Parse messages passed to this window and send </span></p>
<p style="margin: 0px"><span style="color: gray">&#160;&#160;&#160; ///</span><span style="color: green"> </span><span style="color: green">them to the event handlers.</span></p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;/summary&gt;</span></p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;param name=&quot;m&quot;&gt;</span><span style="color: green">A System.Windows.Forms.Message </span></p>
<p style="margin: 0px"><span style="color: gray">&#160;&#160;&#160; ///</span><span style="color: green"> </span><span style="color: green">that is associated with the </span></p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> current Windows message.</span><span style="color: gray">&lt;/param&gt;</span></p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: blue">protected</span> <span style="color: blue">override</span> <span style="color: blue">void</span> WndProc(<span style="color: blue">ref</span> <span style="color: #2b91af">Message</span> m)</p>
<p style="margin: 0px">&#160;&#160;&#160; {</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">bool</span> handled = <span style="color: blue">false</span>;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">if</span> (EventHandler != <span style="color: blue">null</span>)</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; EventHandler(<span style="color: blue">ref</span> m, <span style="color: blue">ref</span> handled);</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">if</span> (!handled)</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">base</span>.WndProc(<span style="color: blue">ref</span> m);</p>
<p style="margin: 0px">&#160;&#160;&#160; }</p>
<p style="margin: 0px">}</p>
</p></div>
<p>Now we can write our global hotkey handler class:</p>
<div style="font-family: courier new; background: white; color: black; font-size: 10pt">
<p style="margin: 0px"><span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;summary&gt;</span></p>
<p style="margin: 0px"><span style="color: gray">///</span><span style="color: green"> Specifies a class that creates a global keyboard hotkey.</span></p>
<p style="margin: 0px"><span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;/summary&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">public</span> <span style="color: blue">class</span> <span style="color: #2b91af">GlobalHotkey</span></p>
<p style="margin: 0px">{</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: blue">private</span> <span style="color: blue">static</span> <span style="color: blue">readonly</span> <span style="color: #2b91af">Object</span> MyStaticLock = <span style="color: blue">new</span> <span style="color: #2b91af">Object</span>();</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: blue">private</span> <span style="color: blue">static</span> <span style="color: blue">int</span> _hotkeyCounter = 0xA000;</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: blue">private</span> <span style="color: blue">readonly</span> <span style="color: blue">int</span> _hotkeyIndex;</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: blue">private</span> <span style="color: blue">readonly</span> <span style="color: #2b91af">IntPtr</span> _hWnd;</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;summary&gt;</span></p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> Initializes a new instance of this class.</span></p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;/summary&gt;</span></p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;param name=&quot;keys&quot;&gt;</span><span style="color: green">The keys.</span><span style="color: gray">&lt;/param&gt;</span></p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;param name=&quot;ctrl&quot;&gt;</span><span style="color: green">if </span><span style="color: gray">&lt;c&gt;</span><span style="color: green">true</span><span style="color: gray">&lt;/c&gt;</span><span style="color: green"> [CTRL].</span><span style="color: gray">&lt;/param&gt;</span></p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;param name=&quot;alt&quot;&gt;</span><span style="color: green">if </span><span style="color: gray">&lt;c&gt;</span><span style="color: green">true</span><span style="color: gray">&lt;/c&gt;</span><span style="color: green"> [alt].</span><span style="color: gray">&lt;/param&gt;</span></p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;param name=&quot;shift&quot;&gt;</span><span style="color: green">if </span><span style="color: gray">&lt;c&gt;</span><span style="color: green">true</span><span style="color: gray">&lt;/c&gt;</span><span style="color: green"> [shift].</span><span style="color: gray">&lt;/param&gt;</span></p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;param name=&quot;winKey&quot;&gt;</span><span style="color: green">if </span><span style="color: gray">&lt;c&gt;</span><span style="color: green">true</span><span style="color: gray">&lt;/c&gt;</span><span style="color: green"> [win key].</span><span style="color: gray">&lt;/param&gt;</span></p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: blue">public</span> GlobalHotkey(<span style="color: #2b91af">Keys</span> keys, <span style="color: blue">bool</span> ctrl, </p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">bool</span> alt, <span style="color: blue">bool</span> shift, <span style="color: blue">bool</span> winKey)</p>
<p style="margin: 0px">&#160;&#160;&#160; {</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; KeyCode = keys;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; Ctrl = ctrl;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; Alt = alt;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; Shift = shift;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; WindowsKey = winKey;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #2b91af">EventDispatchingNativeWindow</span>.Instance.EventHandler </p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; += NwEventHandler;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">lock</span> (MyStaticLock)</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; _hotkeyIndex = ++_hotkeyCounter;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; _hWnd = <span style="color: #2b91af">EventDispatchingNativeWindow</span>.Instance.Handle;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; Enable();</p>
<p style="margin: 0px">&#160;&#160;&#160; }</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;summary&gt;</span></p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> The key code of the hotkey.</span></p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;/summary&gt;</span></p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: blue">public</span> <span style="color: #2b91af">Keys</span> KeyCode { <span style="color: blue">get</span>; <span style="color: blue">private</span> <span style="color: blue">set</span>; }</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;summary&gt;</span></p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> Whether the shortcut includes the Control modifier.</span></p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;/summary&gt;</span></p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: blue">public</span> <span style="color: blue">bool</span> Ctrl { <span style="color: blue">get</span>; <span style="color: blue">private</span> <span style="color: blue">set</span>; }</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;summary&gt;</span></p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> Whether this shortcut includes the Alt modifier.</span></p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;/summary&gt;</span></p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: blue">public</span> <span style="color: blue">bool</span> Alt { <span style="color: blue">get</span>; <span style="color: blue">private</span> <span style="color: blue">set</span>; }</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;summary&gt;</span></p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> Whether this shortcut includes the shift modifier.</span></p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;/summary&gt;</span></p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: blue">public</span> <span style="color: blue">bool</span> Shift { <span style="color: blue">get</span>; <span style="color: blue">private</span> <span style="color: blue">set</span>; }</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;summary&gt;</span></p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> Whether this shortcut includes the Windows key modifier.</span></p>
<p style="margin: 0px">
<p style="margin: 0px"><span style="color: green"></span></p>
<p>&#160;&#160;&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;/summary&gt;</span>
</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: blue">public</span> <span style="color: blue">bool</span> WindowsKey { <span style="color: blue">get</span>; <span style="color: blue">private</span> <span style="color: blue">set</span>; }</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160;&#160;&#160; ~GlobalHotkey()</p>
<p style="margin: 0px">&#160;&#160;&#160; {</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; Disable();</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #2b91af">EventDispatchingNativeWindow</span>.Instance.EventHandler </p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; -= NwEventHandler;</p>
<p style="margin: 0px">&#160;&#160;&#160; }</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;summary&gt;</span></p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> Enables the hotkey. When the hotkey is enabled, </span></p>
<p style="margin: 0px"><span style="color: gray">&#160;&#160;&#160; ///</span><span style="color: green"> </span><span style="color: green">pressing it causes a</span></p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;c&gt;</span><span style="color: green">HotkeyPressed</span><span style="color: gray">&lt;/c&gt;</span><span style="color: green"> event instead of being </span></p>
<p style="margin: 0px"><span style="color: gray">&#160;&#160;&#160; ///</span><span style="color: green"> </span><span style="color: green">handled by the active</span><span style="color: green"> application.</span></p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;/summary&gt;</span></p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: blue">private</span> <span style="color: blue">void</span> Enable()</p>
<p style="margin: 0px">&#160;&#160;&#160; {</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: green">// register hotkey</span></p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">int</span> fsModifiers = 0;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">if</span> (Shift) fsModifiers += ModShift;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">if</span> (Ctrl) fsModifiers += ModControl;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">if</span> (Alt) fsModifiers += ModAlt;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">if</span> (WindowsKey) fsModifiers += ModWin;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">bool</span> success = </p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; RegisterHotKey(_hWnd, _hotkeyIndex, </p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; fsModifiers, (<span style="color: blue">int</span>) KeyCode);</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">if</span> (!success)</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">throw</span> <span style="color: blue">new</span> </p>
<p style="margin: 0px"><span style="color: #2b91af"><font color="#000000">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </font>Exception</span>(</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #a31515">&quot;Could not register hotkey (already in use).&quot;</span>);</p>
<p style="margin: 0px">&#160;&#160;&#160; }</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;summary&gt;</span></p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> Disables this instance.</span></p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;/summary&gt;</span></p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: blue">private</span> <span style="color: blue">void</span> Disable()</p>
<p style="margin: 0px">&#160;&#160;&#160; {</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: green">// unregister hotkey</span></p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; UnregisterHotKey(_hWnd, _hotkeyIndex);</p>
<p style="margin: 0px">&#160;&#160;&#160; }</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;summary&gt;</span></p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> Occurs when the hotkey is pressed.</span></p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;/summary&gt;</span></p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: blue">public</span> <span style="color: blue">event</span> <span style="color: #2b91af">EventHandler</span> HotkeyPressed;</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: blue">private</span> <span style="color: blue">void</span> NwEventHandler(<span style="color: blue">ref</span> <span style="color: #2b91af">Message</span> m, <span style="color: blue">ref</span> <span style="color: blue">bool</span> handled)</p>
<p style="margin: 0px">&#160;&#160;&#160; {</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">if</span> (handled) <span style="color: blue">return</span>;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">if</span> (m.Msg != WmHotkey || </p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; m.WParam.ToInt32() != _hotkeyIndex)</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">return</span>;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">if</span> (HotkeyPressed != <span style="color: blue">null</span>)</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; HotkeyPressed(<span style="color: blue">this</span>, <span style="color: #2b91af">EventArgs</span>.Empty);</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; handled = <span style="color: blue">true</span>;</p>
<p style="margin: 0px">&#160;&#160;&#160; }</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px"><span style="color: blue">&#160;&#160;&#160; #region</span> PInvoke Declarations</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: blue">private</span> <span style="color: blue">const</span> <span style="color: blue">int</span> ModAlt = 0&#215;0001;</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: blue">private</span> <span style="color: blue">const</span> <span style="color: blue">int</span> ModControl = 0&#215;0002;</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: blue">private</span> <span style="color: blue">const</span> <span style="color: blue">int</span> ModShift = 0&#215;0004;</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: blue">private</span> <span style="color: blue">const</span> <span style="color: blue">int</span> ModWin = 0&#215;0008;</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: blue">private</span> <span style="color: blue">const</span> <span style="color: blue">int</span> WmHotkey = 0&#215;0312;</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160;&#160;&#160; [<span style="color: #2b91af">DllImport</span>(<span style="color: #a31515">&quot;user32.dll&quot;</span>, SetLastError = <span style="color: blue">true</span>)]</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: blue">private</span> <span style="color: blue">static</span> <span style="color: blue">extern</span> <span style="color: blue">bool</span> RegisterHotKey(<span style="color: #2b91af">IntPtr</span> hWnd, </p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">int</span> id, <span style="color: blue">int</span> fsModifiers, <span style="color: blue">int</span> vlc);</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160;&#160;&#160; [<span style="color: #2b91af">DllImport</span>(<span style="color: #a31515">&quot;user32.dll&quot;</span>, SetLastError = <span style="color: blue">true</span>)]</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: blue">private</span> <span style="color: blue">static</span> <span style="color: blue">extern</span> <span style="color: blue">bool</span> UnregisterHotKey(<span style="color: #2b91af">IntPtr</span> hWnd, </p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">int</span> id);</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px"><span style="color: blue">&#160;&#160;&#160; #endregion</span></p>
<p style="margin: 0px">}</p>
</p></div>
<p>Now we can easily register a global hotkey or use it as an observable in F#:</p>
<div style="font-family: courier new; background: white; color: black; font-size: 10pt">
<p style="margin: 0px"><span style="color: green">/// system-wide keyboard hook</span></p>
<p style="margin: 0px"><span style="color: blue">let</span> hotkey = <span style="color: blue">new</span> GlobalHotkey(Keys.Q,<span style="color: blue">true</span>,<span style="color: blue">false</span>,<span style="color: blue">false</span>,<span style="color: blue">false</span>)</p>
<p style="margin: 0px"><span style="color: blue">let</span> hookObserver =</p>
<p style="margin: 0px">&#160; hotkey.HotkeyPressed&#160; </p>
<p style="margin: 0px">&#160;&#160;&#160; |&gt; Observable.subscribe (<span style="color: blue">fun</span> _ <span style="color: blue">-&gt;</span> printfn <span style="color: maroon">&quot;Hotkey pressed&quot;</span>)</p>
</p></div>
<p>&copy;2010 <a href="http://www.navision-blog.de">Rash thoughts about .NET, C#, F# and Dynamics NAV.</a>. All Rights Reserved.</p>.]]></content:encoded>
			<wfw:commentRss>http://www.navision-blog.de/2009/11/06/observing-global-shortcuts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Extensibility of functions with lambdas (in F# and C#)</title>
		<link>http://www.navision-blog.de/2009/07/01/extensibility-of-functions-with-lambdas-in-f-and-c/</link>
		<comments>http://www.navision-blog.de/2009/07/01/extensibility-of-functions-with-lambdas-in-f-and-c/#comments</comments>
		<pubDate>Wed, 01 Jul 2009 14:02:25 +0000</pubDate>
		<dc:creator>Steffen Forkmann</dc:creator>
				<category><![CDATA[English posts]]></category>
		<category><![CDATA[F#]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Fake]]></category>
		<category><![CDATA[Functional Programming]]></category>

		<guid isPermaLink="false">http://www.navision-blog.de/2009/07/01/extensibility-of-functions-with-lambdas-in-f-and-c/</guid>
		<description><![CDATA[One of the nice properties of functional programming languages is the easy extensibility of custom functions. Let’s consider a simple F# function (from “FAKE – F# Make”) for a recursive directory copy: open System open System.IO /// Copies a directory recursive /// Thanks to Robert Pickering http://strangelights.com/blog/ /// param target: target directory : string /// [...]]]></description>
			<content:encoded><![CDATA[<p>One of the nice properties of functional programming languages is the easy extensibility of custom functions. Let’s consider a simple F# function (from <a href="http://code.google.com/p/fake/">“FAKE – F# Make”</a>) for a recursive directory copy:</p>
<pre class="code"><span style="color: blue">open </span>System
<span style="color: blue">open </span>System.IO
<span style="color: green">
/// Copies a directory recursive
/// Thanks to Robert Pickering <a title="http://strangelights.com/blog/" href="http://strangelights.com/blog/">http://strangelights.com/blog/</a></span><span style="color: green">
///  param target: target directory : string
///  param source: source directory : string
</span><span style="color: blue">let </span>CopyDir target source =
  Directory.GetFiles(source, <span style="color: maroon">&quot;*.*&quot;</span>, SearchOption.AllDirectories)
    |&gt; Seq.iter (<span style="color: blue">fun </span>file <span style="color: blue">-&gt;
      let </span>newFile = target + file.Remove(0, source.Length)
      printf <span style="color: maroon">&quot;%s =&gt; %s&quot; </span>file newFile
      Directory.CreateDirectory(Path.GetDirectoryName(newFile)) |&gt; ignore
      File.Copy(file, newFile, <span style="color: blue">true</span>))</pre>
<p>If we want to allow users to set custom file filters, we can add a third parameter:</p>
<pre class="code"><span style="color: green">/// Copies a directory recursive
<strong>/// and allows to filter the files</strong>
<span style="color: green">/// Thanks to Robert Pickering <a title="http://strangelights.com/blog/" href="http://strangelights.com/blog/">http://strangelights.com/blog/</span></span><span style="color: green"></span></a>
<span style="color: green">///  param target: target directory : string
///  param source: source directory : string
<strong>///  param filterFile: FilterFunction: string -&gt; bool</strong>
</span><span style="color: blue">let </span>CopyDirFiltered target source <strong>filterFile</strong> =
  Directory.GetFiles(source, <span style="color: maroon">&quot;*.*&quot;</span>, SearchOption.AllDirectories)
    <strong>|&gt; Seq.filter filterFile</strong>
    |&gt; Seq.iter (<span style="color: blue">fun </span>file <span style="color: blue">-&gt;
      let </span>newFile = target + file.Remove(0, source.Length)
      printfn <span style="color: maroon">&quot;%s =&gt; %s&quot; </span>file newFile
      Directory.CreateDirectory(Path.GetDirectoryName(newFile)) |&gt; ignore
      File.Copy(file, newFile, <span style="color: blue">true</span>))</pre>
<p>Now we can define some filter functions:</p>
<pre class="code"><span style="color: green">/// Exclude SVN files (path with .svn)
/// excludeSVNFiles<strong>: string -&gt; bool</strong>
</span><span style="color: blue">let </span>excludeSVNFiles (path:string) = not &lt;| path.Contains <span style="color: maroon">&quot;.svn&quot;

</span><span style="color: green">/// Includes all files
/// allFiles<strong>: string -&gt; bool</strong> </span>
</span><span style="color: blue">let </span>allFiles (path:string) = <span style="color: blue">true</span></pre>
<p>Now it is possible to use CopyDirFiltered in the following ways:</p>
<pre class="code"><span style="color: green">/// Copies all files &lt;=&gt; same as CopyDir
</span>CopyDirFiltered <span style="color: maroon">&quot;C:\\target&quot; &quot;C:\\source&quot; </span>allFiles

<span style="color: green">/// Copies all files except SVN files
</span>CopyDirFiltered <span style="color: maroon">&quot;C:\\target&quot; &quot;C:\\source&quot; </span>excludeSVNFiles

<span style="color: green">/// Copies all files only if random number &lt;&gt; 2
</span><span style="color: blue">let </span>r = <span style="color: blue">new </span>Random()
CopyDirFiltered <span style="color: maroon">&quot;C:\\target&quot; &quot;C:\\source&quot; </span>(<span style="color: blue">fun </span>path <span style="color: blue">-&gt; </span>r.Next(5) &lt;&gt; 2)</pre>
<h5>Extensibility of functions in C#</h5>
<p>Of course we can do the same thing in C# 3.0:</p>
<pre class="code"><span style="color: gray">/// &lt;summary&gt;
/// </span><span style="color: green">Copies a directory recursive
</span><span style="color: gray">/// </span><span style="color: green">and allows to filter the files
</span><span style="color: gray">/// &lt;/summary&gt;
/// &lt;param name=&quot;target&quot;&gt;</span><span style="color: green">The target.</span><span style="color: gray">&lt;/param&gt;
/// &lt;param name=&quot;source&quot;&gt;</span><span style="color: green">The source.</span><span style="color: gray">&lt;/param&gt;
/// &lt;param name=&quot;fileFilter&quot;&gt;</span><span style="color: green">The file filter.</span><span style="color: gray">&lt;/param&gt;
</span><span style="color: blue">public static void </span>CopyDirFiltered(<span style="color: blue">string </span>target, <span style="color: blue">string </span>source,
                                   <span style="color: #2b91af">Func</span>&lt;<span style="color: blue">string</span>, <span style="color: blue">bool</span>&gt; fileFilter)
{
    <span style="color: blue">string</span>[] allFiles = <span style="color: #2b91af">Directory</span>.GetFiles(
        source, <span style="color: #a31515">&quot;*.*&quot;</span>, <span style="color: #2b91af">SearchOption</span>.AllDirectories);
    <span style="color: blue">foreach </span>(<span style="color: blue">string </span>file <span style="color: blue">in from </span>f <span style="color: blue">in </span>allFiles
                            <span style="color: blue">where </span>fileFilter(f)
                            <span style="color: blue">select </span>f)
    {
        <span style="color: blue">string </span>newFile = target + file.Remove(0, source.Length);
        <span style="color: #2b91af">Console</span>.WriteLine(<span style="color: #a31515">&quot;{0} =&gt; {1}&quot;</span>, file, newFile);
        <span style="color: #2b91af">Directory</span>.CreateDirectory(<span style="color: #2b91af">Path</span>.GetDirectoryName(newFile));
        <span style="color: #2b91af">File</span>.Copy(file, newFile, <span style="color: blue">true</span>);
    }
}</pre>
<p>Now it is easy to use the C# function with lambdas:</p>
<blockquote>
<p>“A lambda expression is an anonymous function that can contain expressions and statements, and can be used to create delegates or expression tree types.”</p>
<p align="right">[<a href="http://msdn.microsoft.com/en-us/library/bb397687.aspx">MSDN</a>]</p>
</blockquote>
<pre class="code"><span style="color: #2b91af">Func</span>&lt;<span style="color: blue">string</span>, <span style="color: blue">bool</span>&gt; filterSVN = x =&gt; !x.Contains(<span style="color: #a31515">&quot;.svn&quot;</span>);
<span style="color: #2b91af">Func</span>&lt;<span style="color: blue">string</span>, <span style="color: blue">bool</span>&gt; allFiles = x =&gt; <span style="color: blue">true</span>;

<span style="color: gray">/// </span><span style="color: green">Copies all files </span><span style="color: gray">&lt;=&gt; </span><span style="color: green">same as CopyDir
</span>CopyDirFiltered(<span style="color: #a31515">&quot;C:\\target&quot;</span>, <span style="color: #a31515">&quot;C:\\source&quot;</span>, allFiles);

<span style="color: gray">/// </span><span style="color: green">Copies all files except SVN files
</span>CopyDirFiltered(<span style="color: #a31515">&quot;C:\\target&quot;</span>, <span style="color: #a31515">&quot;C:\\source&quot;</span>, filterSVN);

<span style="color: gray">/// </span><span style="color: green">Copies all files only if random number </span><span style="color: gray">&lt;&gt; </span><span style="color: green">2
</span><span style="color: blue">var </span>r = <span style="color: blue">new </span><span style="color: #2b91af">Random</span>();
CopyDirFiltered(<span style="color: #a31515">&quot;C:\\target&quot;</span>, <span style="color: #a31515">&quot;C:\\source&quot;</span>, path =&gt; r.Next(5) != 2);</pre>
<p>Keeping this simple technique in mind allows to create very flexible functions.</p>
<p>&copy;2010 <a href="http://www.navision-blog.de">Rash thoughts about .NET, C#, F# and Dynamics NAV.</a>. All Rights Reserved.</p>.]]></content:encoded>
			<wfw:commentRss>http://www.navision-blog.de/2009/07/01/extensibility-of-functions-with-lambdas-in-f-and-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Debugging in Dynamics NAV 2009</title>
		<link>http://www.navision-blog.de/2008/10/16/debugging-in-dynamics-nav-2009/</link>
		<comments>http://www.navision-blog.de/2008/10/16/debugging-in-dynamics-nav-2009/#comments</comments>
		<pubDate>Thu, 16 Oct 2008 11:41:09 +0000</pubDate>
		<dc:creator>Steffen Forkmann</dc:creator>
				<category><![CDATA[.NET 3.0]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Dynamics NAV 2009]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[msu solutions GmbH]]></category>
		<category><![CDATA[Debugging]]></category>
		<category><![CDATA[RoleTailored-Client]]></category>
		<category><![CDATA[UnitTest]]></category>
		<category><![CDATA[Visual Studio 2008]]></category>

		<guid isPermaLink="false">http://www.navision-blog.de/2008/10/16/debugging-in-nav-2009/</guid>
		<description><![CDATA[Claus Lundstrøm zeigt in einem sch&#246;nen Blogpost wie man in NAV2009 den Code auf Seite der ServiceTier (also auch remote) debuggen kann – und zwar &#252;ber Visual Studio 2008 direkt im generierten C#-Code. Mit dieser Variante ist man nicht mehr gezwungen das Debugging &#252;ber den Classic-Client zu tun, sondern kann direkt aus dem Dynamics NAV [...]]]></description>
			<content:encoded><![CDATA[<p>Claus Lundstrøm zeigt in einem sch&#246;nen Blogpost wie man in <a href="http://blogs.msdn.com/clausl/archive/2008/10/14/debugging-in-nav-2009.aspx">NAV2009 den Code auf Seite der ServiceTier (also auch remote) debuggen</a> kann – und zwar &#252;ber Visual Studio 2008 direkt im generierten C#-Code. Mit dieser Variante ist man nicht mehr gezwungen das Debugging &#252;ber den Classic-Client zu tun, sondern kann direkt aus dem Dynamics NAV RoleTailored-Client debuggen.</p>
<p>Dummerweise ist der generierte C#-Code, wie das bei generiertem Code eigentlich immer der Fall ist, nicht gerade “optisch sch&#246;ner” C#-Style und hat auch nur noch wenig mit dem Original-C/AL-Code zu tun – ist aber immerhin lesbar.</p>
<p>Das ist ein wirklich interessanter Ansatz und erlaubt mit etwas Geschick auch UnitTesting f&#252;r NAV 2009. Daf&#252;r werde ich demn&#228;chst mal versuchen ein kleines Beispiel zu bloggen.</p>
<p>&copy;2010 <a href="http://www.navision-blog.de">Rash thoughts about .NET, C#, F# and Dynamics NAV.</a>. All Rights Reserved.</p>.]]></content:encoded>
			<wfw:commentRss>http://www.navision-blog.de/2008/10/16/debugging-in-dynamics-nav-2009/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Technologie Highlights von Heute und Morgen! &#8211; Umfrage auf der BASTA! 2008</title>
		<link>http://www.navision-blog.de/2008/10/14/technologie-highlights-von-heute-und-morgen-umfrage-auf-der-basta-2008/</link>
		<comments>http://www.navision-blog.de/2008/10/14/technologie-highlights-von-heute-und-morgen-umfrage-auf-der-basta-2008/#comments</comments>
		<pubDate>Tue, 14 Oct 2008 07:02:56 +0000</pubDate>
		<dc:creator>Steffen Forkmann</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[F#]]></category>
		<category><![CDATA[Veranstaltungen]]></category>
		<category><![CDATA[BASTA! 2008]]></category>
		<category><![CDATA[Funktionale Programmierung]]></category>
		<category><![CDATA[LINQ]]></category>
		<category><![CDATA[Silverlight]]></category>

		<guid isPermaLink="false">http://www.navision-blog.de/2008/10/14/technologie-highlights-von-heute-und-morgen-umfrage-auf-der-basta-2008/</guid>
		<description><![CDATA[Florian M&#228;tschke hat soeben seine auf der BASTA! 2008 in Mainz angek&#252;ndigte Umfrage auf seinem Blog ver&#246;ffentlicht. Dabei wurden die BASTA!-Speaker zu der Technologie befragt, die sie im Moment am meisten fasziniert. “Gewinner” ist &#252;brigens Silverlight 2 geworden, dicht gefolgt von funktionaler Programmierung (in F# bzw. LINQ) – wof&#252;r ich mich &#252;brigens auch entschieden habe. [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blogs.dotnet-braunschweig.de/Florian/default.aspx">Florian M&#228;tschke</a> hat soeben seine auf der BASTA! 2008 in Mainz angek&#252;ndigte <a href="http://blogs.dotnet-braunschweig.de/Florian/PermaLink,guid,3fd651e6-70e3-4795-aebb-ab7dd3a82a39.aspx">Umfrage auf seinem Blog</a> ver&#246;ffentlicht. Dabei wurden die BASTA!-Speaker zu der Technologie befragt, die sie im Moment am meisten fasziniert. “Gewinner” ist &#252;brigens Silverlight 2 geworden, dicht gefolgt von funktionaler Programmierung (in F# bzw. LINQ) – wof&#252;r ich mich &#252;brigens auch entschieden habe.</p>
<p>Insgesamt ist das Umfrageergebnis, wie f&#252;r die BASTA! zu erwarten war, sehr .NET-lastig. Obwohl auf der Abendveranstaltung noch Technologien wie Waschmaschine und Auto als faszinierend erachtet wurden, haben sich die meisten Speaker schlussendlich f&#252;r ihr Vortragsthema im weitesten Sinne entschieden.</p>
<p>Ich muss sagen, dass ich das Konzept der Umfrage sehr interessant finde. Das Problem ist nur, dass man z.B. auf einer Java-Konferenz nat&#252;rlich vollkommen kontr&#228;re Ergebnisse erzielt. Um die wirklichen “Technologie Highlights“ zu ermitteln m&#252;sste man die Umfrage selbstverst&#228;ndlich viel gr&#246;&#223;er und anonymisiert anlegen.</p>
<p>&copy;2010 <a href="http://www.navision-blog.de">Rash thoughts about .NET, C#, F# and Dynamics NAV.</a>. All Rights Reserved.</p>.]]></content:encoded>
			<wfw:commentRss>http://www.navision-blog.de/2008/10/14/technologie-highlights-von-heute-und-morgen-umfrage-auf-der-basta-2008/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>F# option types und generische Listen in C# verwenden</title>
		<link>http://www.navision-blog.de/2008/10/12/f-option-types-und-generische-listen-in-c-verwenden/</link>
		<comments>http://www.navision-blog.de/2008/10/12/f-option-types-und-generische-listen-in-c-verwenden/#comments</comments>
		<pubDate>Sun, 12 Oct 2008 12:08:00 +0000</pubDate>
		<dc:creator>Steffen Forkmann</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[F#]]></category>
		<category><![CDATA[C# vs. F#]]></category>
		<category><![CDATA[Extension Methods]]></category>
		<category><![CDATA[F# list]]></category>
		<category><![CDATA[F# option types]]></category>
		<category><![CDATA[System.Collections.Generic.List]]></category>

		<guid isPermaLink="false">http://www.navision-blog.de/2008/10/12/f-option-types-in-c-verwenden/</guid>
		<description><![CDATA[Luis Fallas beschreibt in seinem Blog (“Exploring Beautiful Languages”) an einem sehr sch&#246;nen Beispiel, wie man die F# option types mit Hilfe von Extension Methods in C# verwenden kann. Hier ist eine generische Variante zu seiner Exists()-Methode: open System.Runtime.CompilerServices [&#60;Extension&#62;] module Extensions = &#160; [&#60;Extension&#62;] &#160; let Exists(opt : 'a option) = &#160;&#160;&#160; match opt [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://langexplr.blogspot.com/">Luis Fallas</a> beschreibt in seinem Blog (“Exploring Beautiful Languages”) an einem sehr sch&#246;nen Beispiel, wie man die <a href="http://langexplr.blogspot.com/2008/06/using-f-option-types-in-c.html">F# option types mit Hilfe von Extension Methods in C# verwenden</a> kann.</p>
<p>Hier ist eine generische Variante zu seiner Exists()-Methode:</p>
<p><span style="color: blue">open</span> System.Runtime.CompilerServices </p>
<div style="font-size: 10pt; background: white; color: black; font-family: courier new">
<pre style="margin: 0px">[&lt;Extension&gt;]</pre>
<pre style="margin: 0px"><span style="color: blue">module</span> Extensions =</pre>
<pre style="margin: 0px">&#160; [&lt;Extension&gt;]</pre>
<pre style="margin: 0px">&#160; <span style="color: blue">let</span> Exists(opt : 'a option) =</pre>
<pre style="margin: 0px">&#160;&#160;&#160; <span style="color: blue">match</span> opt <span style="color: blue">with</span></pre>
<pre style="margin: 0px">&#160;&#160;&#160;&#160;&#160; | Some _ <span style="color: blue">-&gt;</span> <span style="color: blue">true</span></pre>
<pre style="margin: 0px">&#160;&#160;&#160;&#160;&#160; | None –<span style="color: blue">&gt;</span> <span style="color: blue">false</span></pre>
</div>
<p>Auf &#228;hnlichem Wege kann man &#252;brigens auch die <a href="http://diditwith.net/2008/03/03/WhyILoveFListsTheBasics.aspx">generischen F#-Listen</a> in System.Collections.Generic.List&lt;T&gt; umwandeln:</p>
<div style="font-size: 10pt; background: white; color: black; font-family: courier new">
<pre style="margin: 0px">[&lt;Extension&gt;]&#160;&#160;&#160; </pre>
<pre style="margin: 0px"><span style="color: blue">let</span> ToCSharpList(list : 'a list) =</pre>
<pre style="margin: 0px">&#160; <span style="color: blue">let</span> csharpList = </pre>
<pre style="margin: 0px">    <span style="color: blue">new</span> System.Collections.Generic.List&lt;'a&gt;()</pre>
<pre style="margin: 0px">&#160; list |&gt; List.iter (<span style="color: blue">fun</span> item <span style="color: blue">-&gt;</span> csharpList.Add item)</pre>
<pre style="margin: 0px">&#160; csharpList</pre>
</div>
<p>Der umgekehrte Weg (von C# nach F#) ist fast analog, allerdings muss man die Liste drehen:</p>
<div style="font-size: 10pt; background: white; color: black; font-family: courier new">
<pre style="margin: 0px"><span style="color: blue">static</span> <span style="color: blue">class</span> <span style="color: #2b91af">Extensions</span></pre>
<pre style="margin: 0px">{</pre>
<div style="font-size: 10pt; background: white; color: black; font-family: courier new">
<pre style="margin: 0px"><span style="color: gray">  ///</span><span style="color: green"> </span><span style="color: gray">&lt;summary&gt;</span></pre>
<pre style="margin: 0px"><span style="color: gray">  ///</span><span style="color: green"> Converts a System.Collections.Generic.List</span><span style="color: gray">&lt;T&gt;</span><span style="color: green"> </span></pre>
<pre style="margin: 0px"><span style="color: green">  <span style="color: gray">///</span><span style="color: green"> </span>in the corresponding F# list.</span></pre>
<pre style="margin: 0px"><span style="color: gray">  ///</span><span style="color: green"> </span><span style="color: gray">&lt;/summary&gt;</span></pre>
<pre style="margin: 0px"><span style="color: gray">  </span><span style="color: blue">public</span> <span style="color: blue">static</span> Microsoft.FSharp.Collections.<span style="color: #2b91af">List</span>&lt;T&gt; </pre>
</p></div>
<pre style="margin: 0px">     ToFSharpList&lt;T&gt;(<span style="color: blue">this</span> <span style="color: #2b91af">List</span>&lt;T&gt; list)</pre>
<pre style="margin: 0px">&#160; {</pre>
<pre style="margin: 0px">&#160;&#160;&#160;&#160;&#160; <span style="color: blue">var</span> fSharpList = </pre>
<pre style="margin: 0px">        Microsoft.FSharp.Collections.<span style="color: #2b91af">List</span>&lt;T&gt;.Empty;</pre>
<pre style="margin: 0px">&#160;&#160;&#160;&#160;&#160; <span style="color: blue">for</span> (<span style="color: blue">int</span> i = list.Count - 1; i &gt;= 0; i--)</pre>
<pre style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160; fSharpList = </pre>
<pre style="margin: 0px">          Microsoft.FSharp.Collections.<span style="color: #2b91af">List</span>&lt;T&gt;.Cons(</pre>
<pre style="margin: 0px">            list[i], </pre>
<pre style="margin: 0px">            fSharpList);</pre>
<pre style="margin: 0px">&#160;&#160;&#160;&#160;&#160; <span style="color: blue">return</span> fSharpList;</pre>
<pre style="margin: 0px">&#160; }</pre>
<pre style="margin: 0px">}</pre>
</div>
<p>&copy;2010 <a href="http://www.navision-blog.de">Rash thoughts about .NET, C#, F# and Dynamics NAV.</a>. All Rights Reserved.</p>.]]></content:encoded>
			<wfw:commentRss>http://www.navision-blog.de/2008/10/12/f-option-types-und-generische-listen-in-c-verwenden/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Microsoft Dynamics Mobile 1.1 released</title>
		<link>http://www.navision-blog.de/2008/04/05/microsoft-dynamics-mobile-11-released/</link>
		<comments>http://www.navision-blog.de/2008/04/05/microsoft-dynamics-mobile-11-released/#comments</comments>
		<pubDate>Sat, 05 Apr 2008 09:53:34 +0000</pubDate>
		<dc:creator>Steffen Forkmann</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Dynamics Mobile]]></category>
		<category><![CDATA[Navision]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Dynamics Nav 5.0 SP1]]></category>
		<category><![CDATA[Mobile Development Tools]]></category>

		<guid isPermaLink="false">http://www.navision-blog.de/2008/04/05/microsoft-dynamics-mobile-11-released/</guid>
		<description><![CDATA[Microsoft hat am 31.3.2008 auf PartnerSource die erste Version von Dynamics Mobile ver&#246;ffentlicht. Dabei handelt es sich prim&#228;r um ein auf .NET basierendes Architekturkonzept mit dem man Mobile Endger&#228;te (mit Windows Mobile 5.0 oder 6.0) an ERP-Systeme (Dynamics NAV oder AX) anbinden kann. Weiterhin wird mit &#8220;Mobile Sales&#8221; jedoch eine umfangreiche Beispielanwendung mitgeliefert. Das Release [...]]]></description>
			<content:encoded><![CDATA[<p>Microsoft hat am 31.3.2008 auf <a href="https://mbs.microsoft.com/partnersource/downloads/releases/dynamicsmobileversion11.htm">PartnerSource</a> die erste Version von Dynamics Mobile ver&#246;ffentlicht. Dabei handelt es sich prim&#228;r um ein auf .NET basierendes Architekturkonzept mit dem man Mobile Endger&#228;te (mit Windows Mobile 5.0 oder 6.0) an ERP-Systeme (Dynamics NAV oder AX) anbinden kann. Weiterhin wird mit &#8220;Mobile Sales&#8221; jedoch eine umfangreiche Beispielanwendung mitgeliefert.</p>
<p><img class="bordered" height="261" alt="Architektur Dynamics Mobile - siehe Mobile Development Tools Whitepaper" src="http://www.navision-blog.de/blog/wp-content/uploads/2008/04/architecture-dynamics-mobile.jpg" width="500" border="0"> </p>
<p>Das Release umfasst:</p>
<ul>
<li><a href="https://mbs.microsoft.com/fileexchange/?fileID=173f10ce-3a89-4445-a721-6e5a0a9a4aaa">Microsoft Dynamics Mobile &#8211; Mobile Development Tools.zip</a>
<ul>
<li>Server und Framework Komponenten, sowie Beispielquellcode in C#</li>
</ul>
<li><a href="https://mbs.microsoft.com/fileexchange/?fileID=a19e3557-b797-4d65-b4b2-0a89fea9c1c6">Microsoft Dynamics Mobile &#8211; Mobile Sales.zip</a>
<ul>
<li>Installer f&#252;r &#8220;Mobile Sales&#8221;, die Beispielanwendung f&#252;r Dynamics Mobile</li>
</ul>
<li><a href="https://mbs.microsoft.com/fileexchange/?fileID=10508464-da1d-4ab4-9066-fa5a956f0252">Microsoft Dynamics Mobile &#8211; Documentation.zip</a>
<ul>
<li>Installer f&#252;r die Dokumentation der Mobile Development Tools und Mobile Sales</li>
</ul>
</li>
</ul>
<p>Dynamics Mobile wird momentan unterst&#252;tzt f&#252;r:
<ul>
<li>Microsoft Dynamics NAV 5.0 SP1
<li>Microsoft Dynamics NAV 4.0 SP3
<li>Microsoft Dynamics AX 4.0 SP1
<li>Microsoft Dynamics AX 4.0 SP2</li>
</ul>
<p>&copy;2010 <a href="http://www.navision-blog.de">Rash thoughts about .NET, C#, F# and Dynamics NAV.</a>. All Rights Reserved.</p>.]]></content:encoded>
			<wfw:commentRss>http://www.navision-blog.de/2008/04/05/microsoft-dynamics-mobile-11-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ReSharper 3.0 f&#252;r Visual Studio 2005 im Test &#8211; Refactoring f&#252;r Profis</title>
		<link>http://www.navision-blog.de/2007/10/06/resharper-30-fr-visual-studio-2005-im-test/</link>
		<comments>http://www.navision-blog.de/2007/10/06/resharper-30-fr-visual-studio-2005-im-test/#comments</comments>
		<pubDate>Sat, 06 Oct 2007 10:03:11 +0000</pubDate>
		<dc:creator>Steffen Forkmann</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Firmen]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[Refactoring]]></category>
		<category><![CDATA[resharper]]></category>

		<guid isPermaLink="false">http://www.navision-blog.de/2007/10/06/resharper-30-fr-visual-studio-2005-im-test/</guid>
		<description><![CDATA[ReSharper ist ein Plugin der Firma JetBrains f&#252;r Visual Studio, das sich speziell die Produktivit&#228;tssteigerung beim Entwickeln als Ziel gesetzt hat. Besonderes Augenmerk wird dabei auf die Refactoring-Unterst&#252;zung gelegt, also auf das nachtr&#228;gliche Umgestalten von Quellcode. JetBrains wirbt damit das &#8220;intelligenteste AddIn f&#252;r Visual Studio&#8221; entwickelt zu haben &#8211; doch was kann ReSharper wirklich?  Download [...]]]></description>
			<content:encoded><![CDATA[<p>ReSharper ist ein Plugin der Firma <a href="http://www.jetbrains.com/index.html">JetBrains</a> f&#252;r Visual Studio, das sich speziell die Produktivit&#228;tssteigerung beim Entwickeln als Ziel gesetzt hat. Besonderes Augenmerk wird dabei auf die Refactoring-Unterst&#252;zung gelegt, also auf das nachtr&#228;gliche Umgestalten von Quellcode. JetBrains wirbt damit das &#8220;intelligenteste AddIn f&#252;r Visual Studio&#8221; entwickelt zu haben &#8211; doch was kann ReSharper wirklich? </p>
<p><span id="more-345"></span></p>
<h5>Download &amp; Installation</h5>
<p>ReSharper 3.0.2 gibt es bei JetBrains als <a href="http://www.jetbrains.com/resharper/download/index.html#full" title="ReSharper Download">30-Tage Testversion</a> zum Download. Die Installation gestaltet sich wirklich einfach &#8211; empfehlenswert ist jedoch Visual Studio vorher zu schlie&#223;en. Nach vollendeter Installation und erneutem Starten von Visual Studio wird die Shortcutbelegung f&#252;r ReSharper abgefragt. Es besteht die Wahl zwischen <a href="http://www.jetbrains.com/resharper/documentation/ReSharper30DefaultKeymap.pdf" title="Visual Studio Keyboard Schema">&#8220;Visual Studio&#8221;</a> und <a href="http://www.jetbrains.com/resharper/documentation/ReSharper30DefaultKeymap_2.pdf" title="IntelliJ IDEA">&#8220;IntelliJ IDEA&#8221;</a>. Beim &#8220;Visual Studio&#8221;-Schema werden die bekannten Standard-Refactoring-Features von Visual Studio einfach mit den analogen ReSharper-Features &#252;berschrieben, w&#228;hrend die zweite Einstellung f&#252;r Entwickler gedacht ist, die bereits mit IntelliJ IDEA oder ReSharper 2.5 gearbeitet haben.</p>
<p><img border="0" width="467" src="http://www.navision-blog.de/blog/wp-content/uploads/2007/10/install-resharper.gif" alt="ReSharper Keyboard Schema" height="281" style="border-width: 0px" /></p>
<p>Seit der Version 3.0 kann man die Keyboard-Belegung nun auch jederzeit &#252;ber <em>ReSharper/Options/Environment/General</em> editieren. Im weiteren werde ich jedoch nur auf die &#8220;Visual Studio&#8221;-Belegung eingehen.</p>
<h5>IntelliSense-Erweiterungen</h5>
<p>Visual Studio 2005 bringt standardm&#228;&#223;ig eine Reihe von <a href="http://de.wikipedia.org/wiki/IntelliSense" title="IntelliSense - Wikipedia">&#8220;IntelliSense&#8221;</a>-Features mit, die das Entwicklerleben einfacher gemacht haben. ReSharper erweitert diese Features noch um einige weitere M&#246;glichkeiten. So ist es zum Beispiel m&#246;glich alle im Projekt verwendeten Typen im IntelliSense auszuw&#228;hlen und nicht nur die Importierten. Das m&#246;glicherweise erforderliche Using-Statement wird von ReSharper automatisch erg&#228;nzt.</p>
<h5>Code-Assistent</h5>
<p>Immer wenn die Gl&#252;hbirne <img border="0" width="14" src="http://www.navision-blog.de/blog/wp-content/uploads/2007/10/bulb.gif" alt="Code Assistent" height="18" /> am linken Bildschirmrand erscheint, hat der Code-Assistent eine M&#246;glichkeit zum Refactoring gefunden. Durch Druck auf ALT+ENTER werden die gefundenen M&#246;glichkeiten aufgelistet. Hier einige Beispiele:</p>
<ul>
<li>Member-Variablen, die nicht beschrieben werden, k&#246;nnen &#8220;readonly&#8221; gesetzt werden:</li>
</ul>
<p> <img border="0" width="400" src="http://www.navision-blog.de/blog/wp-content/uploads/2007/10/codeassistent1.gif" alt="Code-Assistent" height="88" /> </p>
<ul>
<li>Stringverkettungen k&#246;nnen in String.Fomat() umgewandelt werden:</li>
</ul>
<p><img border="0" width="393" src="http://www.navision-blog.de/blog/wp-content/uploads/2007/10/codeassistent2.gif" alt="Code-Assistent" height="72" /></p>
<ul>
<li>Falls festgestellt wird, dass eine benutzte Variable NULL sein k&#246;nnte, wird ein &#8220;If(variable != null)&#8221; angeboten:</li>
</ul>
<p><img border="0" width="400" src="http://www.navision-blog.de/blog/wp-content/uploads/2007/10/codeassistent3.gif" alt="Code-Assistent" height="53" /></p>
<ul>
<li>Wenn erkannt wird, dass der benutzte Namespace in einer Datei nicht der Struktur innerhalb der Projektmappe entspricht, kann der Namespace verlagert werden:</li>
</ul>
<p><img border="0" width="400" src="http://www.navision-blog.de/blog/wp-content/uploads/2007/10/codeassistent4.gif" alt="Code-Assistent" height="93" /></p>
<h5>Code-Navigation</h5>
<p>ReSharper bildet intern den gesamten <a href="http://de.wikipedia.org/wiki/Abstract_Syntax_Tree">abstrakten Syntaxbau</a> des Projektes ab und kann so genau erkennen, wann Refactoring eingesetzt werden kann. Das AddIn ist so u.a. in der Lage alle Aufrufe einer Funktion (ALT+F7) innerhalb der gesamten Projektmappe zu finden. Neben der Anzeige dieser Stellen ist auch eine einfache Navigation innerhalb der Aufrufhierarchie m&#246;glich.</p>
<p><img border="0" width="400" src="http://www.navision-blog.de/blog/wp-content/uploads/2007/10/usages.jpg" alt="usages" height="207" /></p>
<p>Besonders nett ist dieses Feature, wenn man innerhalb von Klassenhierarchien an abgeleitete Stellen navigieren m&#246;chte.</p>
<h5>Toter Code</h5>
<p>Da alle Funktions-Aufrufe der Projektmappe analysiert werden, ist ReSharper auch in der Lage &#8220;toten Code&#8221; zu erkennen, also Code der nirgends aufgerufen wird. Dieser Code wird grau markiert und kann getreu dem <a href="http://de.wikipedia.org/wiki/YAGNI">YAGNI-Prinzip</a> (<em>You Ain’t Gonna Need It) </em>per ALT+ENTER gel&#246;scht werden.</p>
<p><img border="0" width="382" src="http://www.navision-blog.de/blog/wp-content/uploads/2007/10/gray-code1.png" alt="Toter Code" height="74" /></p>
<p><img border="0" width="400" src="http://www.navision-blog.de/blog/wp-content/uploads/2007/10/gray-code2.png" alt="Tote Referenzen" height="109" /> </p>
<p>Das Feature funktioniert so gut, dass ich mittlerweile bei grauem Code automatisch ALT+ENTER dr&#252;cke und den Code l&#246;sche. Falls der sehr seltene Fall eintritt, dass man die Funktion irgendwann doch nochmal braucht, dann schreibt man sie eben neu &#8211; oder schaut in seine Versionsverwaltung.</p>
<h5>Codeformatierung</h5>
<p>Nachdem man ReSharper installiert hat, zeigt sich Visual Studio in einem etwas anderen Gesicht. Das Erste das auff&#228;llt, ist das verfeinerte Syntax-Highlighting. Aber auch beim Tippen von Code darf man sich an einige neue Features gew&#246;hnen &#8211; u.a. werden ge&#246;ffnete Klammern immer gleich wieder geschlossen und der Cursor zwischen die Klammern geschoben. Das gr&#246;&#223;te Feature in diesem Bereich ist jedoch die automatische Codeformatierung mit STRG+ALT+F. Je nach eingestellter Stufe werden hier toter Code entfernt, die Klassen-Member alphabetisch geordnet, Usings optimiert und die Blockeinr&#252;ckung nach voreingestellter Konvention korrigiert.</p>
<p>Leider hat das Feature in der getesteten Version 3.0.2 noch ein paar kleine Macken, so dass ReSharper beim Neuformatieren einiger l&#228;ngerer Dateien einen &#8220;Out of Memory Error&#8221; meldet. Laut <a href="http://www.jetbrains.net/jira/browse/RSRP">JetBrains Bugdatenbank</a> wurde das Problem bereits gel&#246;st &#8211; der Patch ist aber noch nicht downloadbar.</p>
<h5>Die Farbanzeige</h5>
<p>Neben dem Quellcodefenster zeigt ReSharper eine Farbanzeige mit einem &#220;berblick &#252;ber den Status des aktuellen Dokuments an. Die Balken stellen dabei Links zu den entsprechenden Stellen im Dokument dar und die Position innerhalb des Dokuments wird auf die Gr&#246;&#223;e der Scrollleiste skaliert.</p>
<table border="1" width="398" cellPadding="2" cellSpacing="2">
<tr>
<td width="118" vAlign="top">
<p style="text-align: center"><img border="0" width="37" src="http://www.navision-blog.de/blog/wp-content/uploads/2007/10/bar0.png" alt="Roter Rand - Compile-Error" height="281" /></p>
</td>
<td width="146" vAlign="top">
<p style="text-align: center"><img border="0" width="51" src="http://www.navision-blog.de/blog/wp-content/uploads/2007/10/bar1.png" alt="Gelber Rand - Warnungen / Toter Code / Refactoringanweisungen" height="281" /></p>
</td>
<td width="124" vAlign="top">
<p style="text-align: center"><img border="0" width="46" src="http://www.navision-blog.de/blog/wp-content/uploads/2007/10/bar2.png" alt="Gr&#252;ner Rand - Alles Ok / Empfehlungen" height="281" /></p>
</td>
</tr>
<tr>
<td width="116" vAlign="top">Roter Rand:Compile-Error</td>
<td width="151" vAlign="top">Gelber Rand:Warnungen / Toter Code / Refactoringanweisungen</td>
<td width="127" vAlign="top">Gr&#252;ner Rand:Alles Ok / Empfehlungen zum Refactoring</td>
</tr>
</table>
<p>Leider gibt es keine solche Anzeige f&#252;r alle Dateien innerhalb eines Projektes, so dass man alle Dateien manuell &#246;ffnen und ansehen muss.</p>
<h5>UnitTesting</h5>
<p>ReSharper bietet wie viele andere Tools eine erweiterte Unterst&#252;tzung f&#252;r UnitTests. Dabei werden aktuell <a href="http://www.nunit.org/">NUnit</a>, <a href="http://www.csunit.org/">csUnit</a> und &#252;ber ein zus&#228;tzliches <a href="http://der-albert.com/Tags/MbUnit/default.aspx">Plugin</a> auch <a href="http://www.mbunit.com/">mbUnit</a> angeboten. Leider gibt es scheinbar keine M&#246;glichkeit das UnitTest-Framework von Visual Studio Team System zu benutzen, so dass ich hier nicht weiter getestet habe.</p>
<h5>Refactoring</h5>
<p>Das Herz von ReSharper ist nat&#252;rlich das Refactoring. Es werden hier so viele Funktionen angeboten, so dass ich hier nur auf die Wichtigsten eingehen m&#246;chte. Eine <a href="http://www.jetbrains.com/resharper/features/code_refactoring.html" title="ReSharper - Refactoringfeatures">komplette &#220;bersicht</a> aller Refactoring-Features gibt es auf der ReSharper-Homepage.</p>
<p>Als wichtigsten ReSharper-Shortcut sollte man sich STRG+SHIFT+R f&#252;r &#8220;Refactor This&#8221; merken. Diese Funktionalit&#228;t bietet abh&#228;ngig vom Kontext eine Auswahl der gerade m&#246;glichen Refactoring-M&#246;glichkeiten.</p>
<p><img border="0" width="400" src="http://www.navision-blog.de/blog/wp-content/uploads/2007/10/refactor-this.png" alt="refactor_this" height="167" /></p>
<p>Neben den bereits aus Visual Studio bekannten Features wie &#8220;Feld einkapseln&#8221; und &#8220;Umbenennen&#8221; gibt es zum Beispiel M&#246;glichkeiten um Eigenschaften in Methoden zu konvertieren und umgekehrt, Methoden entlang von Vererbungshierarchien zu verschieben und Interfaces in Abstrakte Klassen zu konvertieren. Ein besonders nettes Feature ist, dass man ganze Quelltextbl&#246;cke als eigenst&#228;ndige Methoden auslagern kann. ReSharper erkennt dabei sogar automatisch welche Parameter der Methode &#252;bergeben werden m&#252;ssen:</p>
<p><img border="0" width="400" src="http://www.navision-blog.de/blog/wp-content/uploads/2007/10/extract-method.png" alt="Extract Method" height="240" /></p>
<h5>Fazit</h5>
<p>ReSharper ist ein ausgezeichnetes Tool um die Produktivit&#228;t in Visual Studio zu steigern. Es werden viele Refactoring-Features angeboten und durch die Farbanzeige am Bildschirmrand hat man immer einen &#220;berblick &#252;ber den aktuellen Stats der Datei (leider nicht &#252;ber das gesamte Projekt). Ein kleiner Wermutstropfen ist die fehlende UnitTest-Unterst&#252;tzung f&#252;r Visual Studio Team System und der mit 249 $ (C#-Edition f&#252;r Firmen) doch meiner Meinung nach recht saftige Preis.</p>
<p>&copy;2010 <a href="http://www.navision-blog.de">Rash thoughts about .NET, C#, F# and Dynamics NAV.</a>. All Rights Reserved.</p>.]]></content:encoded>
			<wfw:commentRss>http://www.navision-blog.de/2007/10/06/resharper-30-fr-visual-studio-2005-im-test/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Vortrag von Roland Weigelt zur Visual Studio 2005 Erweiterbarkeit</title>
		<link>http://www.navision-blog.de/2007/05/05/vortrag-von-roland-weigelt-zur-visual-studio-2005-erweiterbarkeit/</link>
		<comments>http://www.navision-blog.de/2007/05/05/vortrag-von-roland-weigelt-zur-visual-studio-2005-erweiterbarkeit/#comments</comments>
		<pubDate>Sat, 05 May 2007 06:57:36 +0000</pubDate>
		<dc:creator>Steffen Forkmann</dc:creator>
				<category><![CDATA[.NET 3.0]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[TechTalk]]></category>
		<category><![CDATA[Veranstaltungen]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[.NET-3.0]]></category>

		<guid isPermaLink="false">http://www.navision-blog.de/2007/05/05/vortrag-von-roland-weigelt-zur-visual-studio-2005-erweiterbarkeit/</guid>
		<description><![CDATA[Am 06.07.2007 findet ab 19:30 ein sehr interessantes Event in Leipzig statt. Roland Weigelt wird &#252;ber die Entwicklung seines mehrfach ausgezeichneten Plugins GhostDoc berichten und einen Einblick in die Visual Studio Erweiterbarkeit geben. GhostDoc ist f&#252;r mich neben ReSharper das wichtigste Plugin f&#252;r Visual Studio &#252;berhaupt. Der Vortragende&#160;wird folgende Features vorstellen: Code Snippets Item und [...]]]></description>
			<content:encoded><![CDATA[<p>Am 06.07.2007 findet ab 19:30 ein sehr interessantes Event in Leipzig statt. Roland Weigelt wird &#252;ber die Entwicklung seines mehrfach ausgezeichneten Plugins <a href="http://www.roland-weigelt.de/ghostdoc/">GhostDoc</a> berichten und einen Einblick in die Visual Studio Erweiterbarkeit geben. GhostDoc ist f&#252;r mich neben <a href="http://www.jetbrains.com/resharper/">ReSharper</a> das wichtigste Plugin f&#252;r Visual Studio &#252;berhaupt.</p>
<p>Der Vortragende&nbsp;wird folgende Features vorstellen:</p>
<ul>
<li>Code Snippets
<li>Item und Project Templates
<li>Wizards
<li>Makros
<li>Add-Ins</li>
</ul>
<p><a href="http://www.dotnet-leipzig.de/v/visualstudioerweiterbarkeit/">Mehr zu dieser Veranstaltung</a> bzw. die <a href="http://www.dotnet-leipzig.de/v/visualstudioerweiterbarkeit/register.aspx">Anmeldung</a>&nbsp;findet man auf den Seiten der <a href="http://www.dotnet-leipzig.de/">.NET User Group Leipzig</a>.</p>
<p><a href="http://www.navision-blog.de/2007/05/05/vortrag-von-roland-weigelt-zur-visual-studio-2005-erweiterbarkeit/">View this on the map.</a></p>
<p>&copy;2010 <a href="http://www.navision-blog.de">Rash thoughts about .NET, C#, F# and Dynamics NAV.</a>. All Rights Reserved.</p>.]]></content:encoded>
			<wfw:commentRss>http://www.navision-blog.de/2007/05/05/vortrag-von-roland-weigelt-zur-visual-studio-2005-erweiterbarkeit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java vs. C# vs. VB.NET</title>
		<link>http://www.navision-blog.de/2007/01/03/java-vs-c-vs-vbnet/</link>
		<comments>http://www.navision-blog.de/2007/01/03/java-vs-c-vs-vbnet/#comments</comments>
		<pubDate>Wed, 03 Jan 2007 13:35:49 +0000</pubDate>
		<dc:creator>Steffen Forkmann</dc:creator>
				<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://www.navision-blog.de/2007/01/03/java-vs-c-vs-vbnet/</guid>
		<description><![CDATA[F&#252;r Java-Programmierer bzw. VB-Programmierer&#160;die gern in C#&#160;einsteigen wollen, gibt es eine&#160;Schnellreferenz mit den wichtigsten Syntaxunterschieden. Das funktioniert nat&#252;rlich auch umgekehrt &#8211; aber wer w&#252;rde schon freiwillig&#160;von C# weg wollen? &#160; Java (J2SE 5.0) and C# Comparison VB.NET and C# Comparison &#169;2010 Rash thoughts about .NET, C#, F# and Dynamics NAV.. All Rights Reserved..]]></description>
			<content:encoded><![CDATA[<p>F&#252;r Java-Programmierer bzw. VB-Programmierer&nbsp;die gern in C#&nbsp;einsteigen wollen, gibt es eine&nbsp;Schnellreferenz mit den wichtigsten Syntaxunterschieden. Das funktioniert nat&#252;rlich auch umgekehrt &#8211; aber wer w&#252;rde schon freiwillig&nbsp;von C# weg wollen? <img src='http://www.navision-blog.de/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> &nbsp;</p>
<ul>
<li><a href="http://www.harding.edu/USER/fmccown/WWW/java1_5_csharp_comparison.html">Java (J2SE 5.0) and C# Comparison</a></li>
<li><a href="http://www.harding.edu/USER/fmccown/WWW/vbnet_csharp_comparison.html">VB.NET and C# Comparison</a></li>
</ul>
<p>&copy;2010 <a href="http://www.navision-blog.de">Rash thoughts about .NET, C#, F# and Dynamics NAV.</a>. All Rights Reserved.</p>.]]></content:encoded>
			<wfw:commentRss>http://www.navision-blog.de/2007/01/03/java-vs-c-vs-vbnet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Codierung einer Textdatei &#228;ndern in C#</title>
		<link>http://www.navision-blog.de/2007/01/03/codierung-einer-textdatei-ndern-in-c/</link>
		<comments>http://www.navision-blog.de/2007/01/03/codierung-einer-textdatei-ndern-in-c/#comments</comments>
		<pubDate>Wed, 03 Jan 2007 13:24:58 +0000</pubDate>
		<dc:creator>Steffen Forkmann</dc:creator>
				<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://www.navision-blog.de/2007/01/03/codierung-einer-textdatei-ndern-in-c/</guid>
		<description><![CDATA[Wenn man die Encodierung einer Textdatei &#228;ndern m&#246;chte, kann man das mit diesem Code-Fragment tun: public void ConvertEncoding( string fileName, string newFileName, Encoding oldEncoding, Encoding newEncoding) { using (StreamWriter w = new StreamWriter(newFileName, false, newEncoding)) { using (StreamReader r = new StreamReader(fileName, oldEncoding, false)) { int charsRead; char[] buffer = new char[128 * 1024]; while [...]]]></description>
			<content:encoded><![CDATA[<p>Wenn man die Encodierung einer Textdatei &#228;ndern m&#246;chte, kann man das mit diesem Code-Fragment tun:</p>
<div class="wlWriterSmartContent" id="57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:436f4bc2-216b-4003-9507-0bf0d06a1fe8" contenteditable="false" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<pre style="background-color:White;">
<div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)

http://www.CodeHighlighter.com/

--><span style="color: #0000FF; ">public</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">void</span><span style="color: #000000; "> ConvertEncoding(
  </span><span style="color: #0000FF; ">string</span><span style="color: #000000; "> fileName, </span><span style="color: #0000FF; ">string</span><span style="color: #000000; "> newFileName,
  Encoding oldEncoding, Encoding newEncoding)
{
    </span><span style="color: #0000FF; ">using</span><span style="color: #000000; "> (StreamWriter w </span><span style="color: #000000; ">=</span><span style="color: #000000; ">
        </span><span style="color: #0000FF; ">new</span><span style="color: #000000; "> StreamWriter(newFileName, </span><span style="color: #0000FF; ">false</span><span style="color: #000000; ">, newEncoding))
    {
        </span><span style="color: #0000FF; ">using</span><span style="color: #000000; "> (StreamReader r </span><span style="color: #000000; ">=</span><span style="color: #000000; ">
            </span><span style="color: #0000FF; ">new</span><span style="color: #000000; "> StreamReader(fileName, oldEncoding, </span><span style="color: #0000FF; ">false</span><span style="color: #000000; ">))
        {
            </span><span style="color: #0000FF; ">int</span><span style="color: #000000; "> charsRead;
            </span><span style="color: #0000FF; ">char</span><span style="color: #000000; ">[] buffer </span><span style="color: #000000; ">=</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">new</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">char</span><span style="color: #000000; ">[</span><span style="color: #000000; ">128</span><span style="color: #000000; "> </span><span style="color: #000000; ">*</span><span style="color: #000000; "> </span><span style="color: #000000; ">1024</span><span style="color: #000000; ">];
            </span><span style="color: #0000FF; ">while</span><span style="color: #000000; "> ((charsRead </span><span style="color: #000000; ">=</span><span style="color: #000000; ">
                        r.ReadBlock(buffer, </span><span style="color: #000000; ">0</span><span style="color: #000000; ">, buffer.Length)) </span><span style="color: #000000; ">&gt;</span><span style="color: #000000; "> </span><span style="color: #000000; ">0</span><span style="color: #000000; ">)
                w.Write(buffer, </span><span style="color: #000000; ">0</span><span style="color: #000000; ">, charsRead);
        }
    }
}</span></div>
</pre>
</div>
<p>&copy;2010 <a href="http://www.navision-blog.de">Rash thoughts about .NET, C#, F# and Dynamics NAV.</a>. All Rights Reserved.</p>.]]></content:encoded>
			<wfw:commentRss>http://www.navision-blog.de/2007/01/03/codierung-einer-textdatei-ndern-in-c/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
