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

<channel>
	<title>Ticklish Techs</title>
	<atom:link href="http://www.ticklishtechs.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ticklishtechs.net</link>
	<description>a mostly .NET but also some other cool techs blog</description>
	<pubDate>Mon, 05 Jan 2009 06:49:00 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Flow</title>
		<link>http://www.ticklishtechs.net/2009/01/05/flow/</link>
		<comments>http://www.ticklishtechs.net/2009/01/05/flow/#comments</comments>
		<pubDate>Mon, 05 Jan 2009 06:49:00 +0000</pubDate>
		<dc:creator>Benjamin Schröter</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[flow]]></category>

		<category><![CDATA[JaDAL]]></category>

		<category><![CDATA[visual studio]]></category>

		<category><![CDATA[vsx]]></category>

		<guid isPermaLink="false">http://www.ticklishtechs.net/2009/01/05/flow/</guid>
		<description><![CDATA[It was very silent here in the past month. That was mainly because I was working on my diploma thesis until the end of September. After that I did my final exam and started working in Bonn. Now it is December and almost 2009. I’m sitting in a plane to Australia for holiday and have [...]]]></description>
			<content:encoded><![CDATA[<p>It was very silent here in the past month. That was mainly because I was working on my diploma thesis until the end of September. After that I did my final exam and started working in Bonn. Now it is December and almost 2009. I’m sitting in a plane to Australia for holiday and have much time to write articles. I will try to keep this blog alive and will write articles more frequently.</p>
<p>Today I will introduce <em><strong>Flow</strong></em>. With <em>Flow</em> you can model the behavior of nodes in a wireless sensor network (WSN) in a data driven and event driven manor. I developed <em>Flow</em> as part of my diploma thesis.</p>
<p><em>Flow</em> is build as a Visual Studio Addon (a VS Package) on top of the DSL-Tools containing three different domain specific languages to describe different parts of the software running on a sensor node. These different DSLs are working together and using most of the techniques I described earlier in this blog. E.g. my library JaDAL was initially build to support this diploma thesis.</p>
<p>You will find screenshots, more explanations and <em>Flow</em> itself on <a href="http://flow.irgendwie.net">http://flow.irgendwie.net</a>. While the webpage and the software are available in English the thesis itself is a pdf-document and can only be downloaded in a German version.</p>
<p>The software is fully working and if no wireless sensor network is available you can use a node simulator to evaluate <em>Flow</em>. The code is released under GPL and also available for download.</p>
<h3>Screenshots:</h3>
<p>Dataflows modeled with <em>Flow</em> looks like that:</p>
<p><a href="http://www.ticklishtechs.net/wp-content/uploads/2009/01/dataflow.png"><img style="border-top-width: 0px; display: block; border-left-width: 0px; float: none; border-bottom-width: 0px; margin-left: auto; margin-right: auto; border-right-width: 0px" title="dataflow" src="http://www.ticklishtechs.net/wp-content/uploads/2009/01/dataflow-thumb.png" border="0" alt="dataflow" width="456" height="191" /></a></p>
<p>The simulated sensor nodes are represented as Windows forms programmed by such dataflows:</p>
<p><a href="http://www.ticklishtechs.net/wp-content/uploads/2009/01/simulatednode.png"><img style="border-top-width: 0px; display: block; border-left-width: 0px; float: none; border-bottom-width: 0px; margin-left: auto; margin-right: auto; border-right-width: 0px" title="simulatednode" src="http://www.ticklishtechs.net/wp-content/uploads/2009/01/simulatednode-thumb.png" border="0" alt="simulatednode" width="182" height="244" /></a></p>
<p>For more information just visit <a href="http://flow.irgendwie.net">http://flow.irgendwie.net</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ticklishtechs.net/2009/01/05/flow/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Microsoft Technical Summit in Berlin</title>
		<link>http://www.ticklishtechs.net/2008/11/06/microsoft-technical-summit-in-berlin/</link>
		<comments>http://www.ticklishtechs.net/2008/11/06/microsoft-technical-summit-in-berlin/#comments</comments>
		<pubDate>Thu, 06 Nov 2008 21:37:09 +0000</pubDate>
		<dc:creator>Benjamin Schröter</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[dates]]></category>

		<guid isPermaLink="false">http://www.ticklishtechs.net/2008/11/06/microsoft-technical-summit-in-berlin/</guid>
		<description><![CDATA[From 11/19 to 11/21/2008 I will be at the Microsoft Technical Summit in Berlin. The Technical Summit itself starts on 20th; on the 19th I will attend the 4th Academic Day.
If anyone will be at these conferences and likes to meet please drop me a line.
See you in Berlin.  
]]></description>
			<content:encoded><![CDATA[<p>From 11/19 to 11/21/2008 I will be at the <a href="http://www.technical-summit.de">Microsoft Technical Summit</a> in Berlin. The Technical Summit itself starts on 20th; on the 19th I will attend the <a href="http://www.technical-summit.de/4thMicrosoftAcademicDays_ts08.mspx?ActiveID=1343">4th Academic Day</a>.</p>
<p>If anyone will be at these conferences and likes to meet please drop me a line.</p>
<p>See you in Berlin. <img src='http://www.ticklishtechs.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.ticklishtechs.net/2008/11/06/microsoft-technical-summit-in-berlin/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Using Geonames.org webservice from .Net</title>
		<link>http://www.ticklishtechs.net/2008/11/02/using-geonamesorg-webservice-from-net/</link>
		<comments>http://www.ticklishtechs.net/2008/11/02/using-geonamesorg-webservice-from-net/#comments</comments>
		<pubDate>Sun, 02 Nov 2008 14:33:14 +0000</pubDate>
		<dc:creator>Benjamin Schröter</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[dotnet]]></category>

		<category><![CDATA[geonames]]></category>

		<category><![CDATA[GPS]]></category>

		<category><![CDATA[release]]></category>

		<guid isPermaLink="false">http://www.ticklishtechs.net/2008/11/02/using-geonamesorg-webservice-from-net/</guid>
		<description><![CDATA[Lately I was looking for a way to translate geo coordinates (latitude and longitude form my gps device) to some sort of text or names. As you know I’m trying to geotag my photos using a gps logger and PhotoTagStudio. This data can be used to visualize the place a photo was taken on a [...]]]></description>
			<content:encoded><![CDATA[<p>Lately I was looking for a way to translate geo coordinates (latitude and longitude form my gps device) to some sort of text or names. As you know I’m trying to geotag my photos using a gps logger and <a href="http://phototagstudio.irgendwie.net/">PhotoTagStudio</a>. This data can be used to visualize the place a photo was taken on a map (e.g. Google Maps or flickr!). The next step can be to use this data to describe the photo as well.</p>
<p>I think one should be able to translate a geo coordinate into at least the name of the county, the state and the city; maybe to the district or a street name, too. To achieve this I found the <a href="http://www.geonames.org/">geonames.org webpage</a>. This page collects exactly the data I need and allows searching via the website and a <a href="http://www.geonames.org/export/">webservice</a>.</p>
<p>The webservice itself consists of approximate <a href="http://www.geonames.org/export/ws-overview.html">30 REST methods</a> one can call by querying an URL. Most of these calls return a XML document (or optional a JSON document). Unfortunately  there is no SOAP / WSDL version of this webservice. For a .net and C# developer a SOAP webservice is very easy to consume but for such a REST / XML webservice you have to create the URLs yourself and parse the resulting XML document.</p>
<p>I started to create a library to query the webservice. This library provides a few static methods mapped to the most useable webservice-methods and returns good shaped .Net objects. These objects carry all the data coming from the webservice. At the moment this library is in an early beta status but you can use it in your own projects. It can be found on Codeplex: <a href="http://www.codeplex.com/GeonamesDotOrgDotNet">GeonamesDotOrgDotNet</a>, there you will find a small example and a demo application. When using this library you should take a look at the documentation of the geonames.org webservices since the interfaces are nearly the same.</p>
<p>I hope this is useful for someone. I will extend the library in the next weeks. Feature requests are welcome, so is help on the coding side.</p>
<p>Currently the following webservice calls are supported:</p>
<ul>
<li>findNearby</li>
<li>findNearbyPlaceName</li>
<li>findNearByWeather</li>
<li>findNearbyWikipedia</li>
<li>get</li>
<li>hierarchy</li>
<li>children</li>
<li>gtopo30</li>
<li>srtm3</li>
</ul>
<p>At the end a few random screenshots and a code snippet. For more information please take a look at the <a href="http://www.codeplex.com/GeonamesDotOrgDotNet">Codeplex project page</a>.</p>
<p><code>// finding some place in Berlin, Germany<br />
</code><code>// (using prefix m for decimal literals)<br />
Geoname Place =<br />
GeoNamesOrgWebservice.FindNearbyPlaceName(52.51m, 13.4m); </code></p>
<p>// getting all parents<br />
IEnumerable ParentPlaces = Place.Hierarchy();</p>
<p>// display the partents<br />
// (will print out something like:<br />
//  &#8220;Globe &gt; Europe &gt; Germany &gt; Land Berlin &gt; Berlin &gt;&#8221;)<br />
foreach (Geoname x in ParentPlaces)<br />
Console.Write(x.Name + &#8221; &gt; &#8220;);</p>
<p>The Classes of the Library:</p>
<p><a href="http://www.ticklishtechs.net/wp-content/uploads/2008/11/classes.png"><img style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" title="classes" src="http://www.ticklishtechs.net/wp-content/uploads/2008/11/classes-thumb.png" border="0" alt="classes" width="334" height="484" /></a></p>
<p>A screenshot of the demo application to test the library:</p>
<p><a href="http://www.ticklishtechs.net/wp-content/uploads/2008/11/testapp.png"><img style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" title="testapp" src="http://www.ticklishtechs.net/wp-content/uploads/2008/11/testapp-thumb.png" border="0" alt="testapp" width="244" height="221" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ticklishtechs.net/2008/11/02/using-geonamesorg-webservice-from-net/feed/</wfw:commentRss>
		</item>
		<item>
		<title>DirectiveProcessor for VSX</title>
		<link>http://www.ticklishtechs.net/2008/10/15/directiveprocessor-for-vsx/</link>
		<comments>http://www.ticklishtechs.net/2008/10/15/directiveprocessor-for-vsx/#comments</comments>
		<pubDate>Wed, 15 Oct 2008 20:20:33 +0000</pubDate>
		<dc:creator>Benjamin Schröter</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[dsl]]></category>

		<category><![CDATA[JaDAL]]></category>

		<category><![CDATA[t4]]></category>

		<category><![CDATA[visual studio]]></category>

		<category><![CDATA[vsx]]></category>

		<guid isPermaLink="false">http://www.ticklishtechs.net/2008/10/15/directiveprocessor-for-vsx/</guid>
		<description><![CDATA[I created two DirectiveProcessor for Visual Studio to use in the T4 system. I added the classes to JaDAL hoping someone can use them in her project or use the code as an example when creating new DirectiveProcessors.
Let&#8217;s start with a short introduction to DirectiveProcessors. DirectiveProcessors are used in .tt-files to provide data to the [...]]]></description>
			<content:encoded><![CDATA[<p>I created two DirectiveProcessor for Visual Studio to use in the T4 system. I added the classes to JaDAL hoping someone can use them in her project or use the code as an example when creating new DirectiveProcessors.</p>
<p>Let&#8217;s start with a short introduction to DirectiveProcessors. DirectiveProcessors are used in .tt-files to provide data to the template. The DirectiveProcessor can take parameters from the declaration in the .tt-file and adds some code to the compiled template. This code (often properties) can be used from within the template. For example the DSL Tools are generating one DirectiveProcessor for each DSL model. In a template form the DSL Tools you will see a line like the following:</p>
<p><span style="background: gold">&lt;#@</span><span style="color: red;"> Language1 </span><span style="color: red;">processor=</span>&#8220;<span style="color: blue;">Language1DirectiveProcessor</span>&#8221;<br />
<span style="color: red;">requires=</span>&#8220;<span style="color: blue;">fileName=&#8217;Sample.mydsl1&#8242;</span>&#8221; <span style="background: gold">#&gt;</span></p>
<p>This line uses the <code>Language1DirectiveProcessor</code> and provides it with one parameter (<code>fileName</code>). The DirectiveProcessor adds code to the template to open the given file and creates (in this case) a <code>ExampleModel</code>-property to use in the template code.</p>
<p>I created two DirectiveProcessors to use the data of simple Xml-files and Visual Studio Project files in the templates. The code of the two DirectiveProcessors is very straight forward and maybe one could advance it (e.g. make it compatible with templates written in Visual Basic).</p>
<h3>Using the XmlFileDirectiveProcessor</h3>
<p>Add a line like the following to your .tt-file:</p>
<p><span style="background: gold">&lt;#@</span><span style="color: red;"> XmlFile processor=</span>&#8220;<span style="color: blue;">XmlFileDirectiveProcessor</span>&#8221; <span style="color: red;">FileName=</span>&#8220;<span style="color: blue;">example.xml</span>&#8221; <span style="background: gold">#&gt;</span></p>
<p>Inside this template you can access the (full qualified) filename via the <code>this.XmlFileName</code>-Property and the Content of this file (as a <code>XDocument</code>) via the <code>this.XmlFile</code>-Property.</p>
<h3>Using the VsProjectFileDirectiveProcessor</h3>
<p>Add this line to your template:</p>
<p><span style="background: gold">&lt;#@</span><span style="color: red;"> ProjectFile processor=</span>&#8220;<span style="color: blue;">VsProjectFileDirectiveProcessor</span>&#8221; <span style="color: red;">FileName=</span>&#8220;<span style="color: #0000ff;">x.csproj</span>&#8221; <span style="background: gold">#&gt;</span></p>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>A property named <code>this.ProjectFile</code> will be added to the template. This property provides you with an instance of the <code>VsProjectFile</code>-class containing the project file contents. This class contains only very little functionality (feel free to add some more and submit it back to me!). Just take a look at the source code of this class. The method <code>GetAllFiles()</code> returns a string array of all files found in the project (supporting C++ and C# project files - .vcproj and .csproj).</p>
<h3>Setup</h3>
<p>An entry in the registry is needed to allow the T4 system to find custom DirectiveProcessors. Just add the following entries to your registry and don&#8217;t forget to point to the right location of the <code>JaDAL.dll</code>.</p>
<p>[HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\9.0Exp\<br />
Configuration\TextTemplating\DirectiveProcessors\VsProjectFileDirectiveProcessor]<br />
&#8220;Class&#8221;=&#8221;BenjaminSchroeter.Dsl.DirectiveProcessors.VsProjectFileDirectiveProcessor&#8221;<br />
&#8220;CodeBase&#8221;=&#8221;D:\\JaDAL\\bin\\Debug\\JaDAL.dll&#8221;</p>
<p>[HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\9.0Exp\<br />
Configuration\TextTemplating\DirectiveProcessors\XmlFileDirectiveProcessor]<br />
&#8220;Class&#8221;=&#8221;BenjaminSchroeter.Dsl.DirectiveProcessors.XmlFileDirectiveProcessor&#8221;<br />
&#8220;CodeBase&#8221;=&#8221;D:\\JaDAL\\bin\\Debug\\JaDAL.dll&#8221;</p>
<p>These registry keys are for the Experimental Hive of Visual Studio. To register the DirectiveProcessors for the normal Visual Studio instance the registry key starts with HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\9.0<br />
\TextTemplating\DirectiveProcessors\</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ticklishtechs.net/2008/10/15/directiveprocessor-for-vsx/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Tagcloud reloaded</title>
		<link>http://www.ticklishtechs.net/2008/08/28/tagcloud-reloaded/</link>
		<comments>http://www.ticklishtechs.net/2008/08/28/tagcloud-reloaded/#comments</comments>
		<pubDate>Thu, 28 Aug 2008 09:11:04 +0000</pubDate>
		<dc:creator>Benjamin Schröter</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[internet]]></category>

		<category><![CDATA[meta]]></category>

		<guid isPermaLink="false">http://www.ticklishtechs.net/?p=165</guid>
		<description><![CDATA[There was not that much going on here lately. Wolfram and I are very busy these days, but we didn&#8217;t forgot about the blog. There are many ideas for articles but to few spare time to write them. Fortunately this will become a little bit better in a few weeks.
For the meantime I build a [...]]]></description>
			<content:encoded><![CDATA[<p>There was not that much going on here lately. Wolfram and I are very busy these days, but we didn&#8217;t forgot about the blog. There are many ideas for articles but to few spare time to write them. Fortunately this will become a little bit better in a few weeks.</p>
<p>For the meantime I build a nice tagcloud to remember you what&#8217;s usually going on her:</p>
<p style="text-align: center;"><a href="http://www.ticklishtechs.net/wp-content/uploads/2008/08/wordle.png"><img class="aligncenter" style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" src="http://www.ticklishtechs.net/wp-content/uploads/2008/08/wordle-thumb.png" border="0" alt="wordle" width="420" height="264" /></a></p>
<p>Produced with <a href="http://wordle.net/">Wordle</a>. Images of Wordles are licensed <a href="http://creativecommons.org/licenses/by/3.0/us/"><img src="http://i.creativecommons.org/l/by/3.0/us/80x15.png" alt="Creative Commons License" /></a>.</p>
<p>Stay tuned!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ticklishtechs.net/2008/08/28/tagcloud-reloaded/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Getting rid of the DSL model explorer</title>
		<link>http://www.ticklishtechs.net/2008/07/27/getting-rid-of-the-dsl-model-explorer/</link>
		<comments>http://www.ticklishtechs.net/2008/07/27/getting-rid-of-the-dsl-model-explorer/#comments</comments>
		<pubDate>Sun, 27 Jul 2008 08:19:41 +0000</pubDate>
		<dc:creator>Benjamin Schröter</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[dotnet]]></category>

		<category><![CDATA[dsl]]></category>

		<category><![CDATA[visual studio]]></category>

		<category><![CDATA[vsx]]></category>

		<guid isPermaLink="false">http://www.ticklishtechs.net/2008/07/27/getting-rid-of-the-dsl-model-explorer/</guid>
		<description><![CDATA[Every DSL you create with DSL Tools has a model explorer. This model explorer is a tool window in Visual Studio displaying the elements of your model in a hierarchical way. This is often a nice feature but sometimes a hierarchical view of your data is not appropriate. So I came to the question: How [...]]]></description>
			<content:encoded><![CDATA[<p>Every DSL you create with DSL Tools has a model explorer. This model explorer is a tool window in Visual Studio displaying the elements of your model in a hierarchical way. This is often a nice feature but sometimes a hierarchical view of your data is not appropriate. So I came to the question: <em>How to remove the explorer from the generated code?</em></p>
<p>I could not find any option in the DSL design to remove the model explorer, but if you look at some of the .tt files you will find somewhere a query for <code>this.Dsl.Explorer != null</code>. For example in the <code>package.tt</code> file that generates the <code>package.cs</code> which is responsible for registering the tool window for the model explorer:</p>
<pre class="code"><span style="background: gold">&lt;#
</span><span style="background: #f0f8ff none repeat scroll 0% 0%; color: #191970;">    if(this.Dsl.Explorer != null)
    {
</span><span style="background: gold">#&gt;
</span><span style="color: red;">    </span><span style="color: gray;">[VSShell::ProvideToolWindow(         typeof(</span><span style="background: gold">&lt;#=</span><span style="background: #f0f8ff none repeat scroll 0% 0%; color: #191970;"> dslName </span><span style="background: gold">#&gt;</span><span style="color: gray;">ExplorerToolWindow),          MultiInstances = false,          Style = VSShell::VsDockStyle.Tabbed,          Orientation = VSShell::ToolWindowOrientation.Right,          Window = "{3AE79031-E1BC-11D0-8F78-00A0C9110057}")]
    [VSShell::ProvideToolWindowVisibility(         typeof(</span><span style="background: gold">&lt;#=</span><span style="background: #f0f8ff none repeat scroll 0% 0%; color: #191970;"> dslName </span><span style="background: gold">#&gt;</span><span style="color: gray;">ExplorerToolWindow),          Constants.</span><span style="background: gold">&lt;#=</span><span style="background: #f0f8ff none repeat scroll 0% 0%; color: #191970;"> dslName </span><span style="background: gold">#&gt;</span><span style="color: gray;">EditorFactoryId)]
</span><span style="background: gold">&lt;#
</span><span style="background: #f0f8ff none repeat scroll 0% 0%; color: #191970;">    }
</span><span style="background: gold">#&gt;</span></pre>
<p><a href="http://11011.net/software/vspaste"></a>Even if I did not find any option to set the <code>Dsl.Explorer</code> property of the model to <code>null</code> (you did not see the Explorer property anywhere in the DSL diagram) it seems that the developers of the DSL Tools had this use case in mind.</p>
<p>To remove the <code>Dsl.Explorer</code> from your DSL model open the <code>.dsl</code> file with a text editor and go to the end. There you will find some XML tags like the following:</p>
<pre class="code"><span style="color: blue;">&lt;</span><span style="color: #a31515;">Explorer </span><span style="color: red;">ExplorerGuid</span><span style="color: blue;">=</span>"<span style="color: blue;">6c276297-6acd-4e9a-8740-b61ba834004b</span>"  <span style="color: red;">Title</span><span style="color: blue;">=</span>"<span style="color: blue;">HardwareDescription Explorer</span>"<span style="color: blue;">&gt;
    &lt;</span><span style="color: #a31515;">ExplorerBehaviorMoniker      </span><span style="color: red;">Name</span><span style="color: blue;">=</span>"<span style="color: blue;">HardwareDescription/HardwareDescriptionExplorer</span>" <span style="color: blue;">/&gt;
&lt;/</span><span style="color: #a31515;">Explorer</span><span style="color: blue;">&gt;
</span></pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>Just delete these three lines and generate your code once again. Maybe you should reset your Experimental Hive, too.</p>
<p>I tested a DSL with a removed Model Explorer without any problems. It seems the developers of the DSL Tools did a very good job on the code generation templates . The generated <code>ModelExplorer.cs</code> file contains only a single line:</p>
<pre class="code"><span style="color: green;">// This source file is empty because    this DSL does not define a model explorer.
</span></pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>That should be a good proof that a DSL can run without the model explorer even if it might be not supported by the DSL Tools. <img src='http://www.ticklishtechs.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.ticklishtechs.net/2008/07/27/getting-rid-of-the-dsl-model-explorer/feed/</wfw:commentRss>
		</item>
		<item>
		<title>The List&#60;T&#62;.ForEach() method</title>
		<link>http://www.ticklishtechs.net/2008/07/23/the-listtforeach-method/</link>
		<comments>http://www.ticklishtechs.net/2008/07/23/the-listtforeach-method/#comments</comments>
		<pubDate>Wed, 23 Jul 2008 16:43:51 +0000</pubDate>
		<dc:creator>Benjamin Schröter</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[dotnet]]></category>

		<category><![CDATA[dotnet3.5]]></category>

		<category><![CDATA[LINQ]]></category>

		<guid isPermaLink="false">http://www.ticklishtechs.net/2008/07/23/the-listtforeach-method/</guid>
		<description><![CDATA[We all know and love the foreach keyword in C# and use it for loops every day:
List&#60;int&#62; list = new List&#60;int&#62;();
/* fill the list */
foreach (int i in list)
    Console.WriteLine(i);

But the generic List&#60;T&#62; class contains a useful method for small loops, too. The method is called ForEach() and has only one parameter: [...]]]></description>
			<content:encoded><![CDATA[<p>We all know and love the foreach keyword in C# and use it for loops every day:</p>
<pre class="code"><span style="color: #2b91af;">List</span>&lt;<span style="color: blue;">int</span>&gt; list = <span style="color: blue;">new </span><span style="color: #2b91af;">List</span>&lt;<span style="color: blue;">int</span>&gt;();
<span style="color: green;">/* fill the list */
</span><span style="color: blue;">foreach </span>(<span style="color: blue;">int </span>i <span style="color: blue;">in </span>list)
    <span style="color: #2b91af;">Console</span>.WriteLine(i);</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>But the generic <code>List&lt;T&gt; </code>class contains a useful method for small loops, too. The method is called <code>ForEach()</code> and has only one parameter: an <code>Action&lt;T&gt;</code>.</p>
<h3>delegates: Action&lt;&gt;, Func&lt;&gt; and Predicate&lt;&gt;</h3>
<p>The Framework 3.5 defines a few generic delegate types for actions and functions. In this case a function is something that returns a value (think back to your math class) and actions are something that do not return a value but do something (maybe think back to physics class). All these delegates are defined with zero, one, two, three and four parameters:</p>
<p><span style="color: blue;">public delegate void</span><span style="color: #2b91af;">Action</span>();<br />
<span style="color: blue;">public delegate void</span><span style="color: #2b91af;">Action</span>&lt;T&gt;(T obj);<br />
<span style="color: blue;">public delegate void</span><span style="color: #2b91af;">Action</span>&lt;T1, T2&gt;(T1 arg1, T2 arg2);<br />
<span style="color: blue;">public delegate void</span><span style="color: #2b91af;">Action</span>&lt;T1, T2, T3&gt;(T1 arg1, T2 arg2, T3 arg3);<br />
<span style="color: blue;">public delegate void</span><span style="color: #2b91af;">Action</span>&lt;T1, T2, T3, T4&gt;(T1 arg1, T2 arg2, T3 arg3, T4 arg4);</p>
<p><span style="color: blue;">public delegate</span>TResult <span style="color: #2b91af;">Func</span>&lt;TResult&gt;();<br />
<span style="color: blue;">public delegate</span>TResult <span style="color: #2b91af;">Func</span>&lt;T, TResult&gt;(T arg);<br />
<span style="color: blue;">public delegate</span>TResult <span style="color: #2b91af;">Func</span>&lt;T1, T2, TResult&gt;(T1 arg1, T2 arg2);<br />
<span style="color: blue;">public delegate</span>TResult <span style="color: #2b91af;">Func</span>&lt;T1, T2, T3, TResult&gt;(T1 arg1, T2 arg2, T3 arg3);<br />
<span style="color: blue;">public delegate</span>TResult <span style="color: #2b91af;">Func</span>&lt;T1, T2, T3, T4, TResult&gt;(T1 arg1, T2 arg2, T3 arg3, T4 arg4);</p>
<p>And there is one more delegate. The <code>Predicate&lt;T&gt;</code> (philosophy class, you know). A predicate comes to a logical decision (true or false; bool return value) based on a single object:<br />
<span style="color: blue;">public delegate bool </span><span style="color: #2b91af;">Predicate</span>&lt;T&gt;(T obj);</p>
<p>All these delegates are generic so you can use them in a type save way with the type parameters you need.</p>
<h3>Back to the ForEach() method</h3>
<p>As I explained above, the <code>ForEach()</code> method takes an <code>Action&lt;T&gt;</code> parameter. In my example this is an <code>Action&lt;int&gt; </code>delegate:</p>
<pre class="code">list.ForEach( <span style="color: blue;">delegate</span>(<span style="color: blue;">int </span>i) {<span style="color: #2b91af;">Console</span>.WriteLine(i);} );</pre>
<p>This anonymous delegate declaration is not that nice, but we can use Lamda types here:</p>
<pre class="code">list.ForEach(i =&gt; <span style="color: #2b91af;">Console</span>.WriteLine(i));</pre>
<p><a href="http://11011.net/software/vspaste"></a>But let&#8217;s take a look at the method we&#8217;re calling: <code>void Console.WriteLine(int)</code>. That is exactly the definition of the needed Action here. So we can write the code line even shorter:</p>
<pre class="code">list.ForEach( <span style="color: #2b91af;">Console</span>.WriteLine );</pre>
<p><a href="http://11011.net/software/vspaste"></a>I like this code. It is very short, elegant and readable. It says: &#8220;For each [entry of] the list: write it out&#8221;. Great.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ticklishtechs.net/2008/07/23/the-listtforeach-method/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Workaround for Known Issue with TypeDescriptors in DSL Tools for Visual Studio</title>
		<link>http://www.ticklishtechs.net/2008/07/19/workaround-for-known-issue-with-typedescriptors-in-dsl-tools-for-visual-studio/</link>
		<comments>http://www.ticklishtechs.net/2008/07/19/workaround-for-known-issue-with-typedescriptors-in-dsl-tools-for-visual-studio/#comments</comments>
		<pubDate>Sat, 19 Jul 2008 17:28:38 +0000</pubDate>
		<dc:creator>Benjamin Schröter</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[dotnet]]></category>

		<category><![CDATA[dsl]]></category>

		<category><![CDATA[visual studio]]></category>

		<category><![CDATA[vsx]]></category>

		<guid isPermaLink="false">http://www.ticklishtechs.net/2008/07/19/workaround-for-known-issue-with-typedescriptors-in-dsl-tools-for-visual-studio/</guid>
		<description><![CDATA[There is a known issue in the current version of the DSL Tools while dealing with custom TypeConverters or custom TypeDescriptors:
1.10 TypeConverters and TypeDescriptors are not picked up during the build process or during toolbox initialization.
When adding a custom TypeConverter or TypeDescriptor and then building the DSL, the TypeConvertor or TypeDescriptor is not picked up. [...]]]></description>
			<content:encoded><![CDATA[<p>There is a known issue in the current version of the DSL Tools while dealing with custom TypeConverters or custom TypeDescriptors:</p>
<blockquote><p><strong>1.10 TypeConverters and TypeDescriptors are not picked up during the build process or during toolbox initialization.</strong><br />
When adding a custom TypeConverter or TypeDescriptor and then building the DSL, the TypeConvertor or TypeDescriptor is not picked up. The workaround is to rebuild the solution with a clean build.</p>
<p>[see <a href="http://blogs.msdn.com/vsxteam/archive/2008/01/30/Known-Issues-for-Microsoft-Visual-Studio-2008-SDK-1.0.aspx">Known Issues for Microsoft Visual Studio 2008 SDK 1.0</a>]</p></blockquote>
<p>Some time ago I <a href="http://www.ticklishtechs.net/2008/02/06/workaround-for-known-issue-with-typeconverters-in-dsl-tools-for-visual-studio/">posted a workaround</a> for this problem with the TypeConverter, but today a realized that this workaround does not work with the same issue for TypeDescriptors.</p>
<p>Imagine some class with the following attribute:</p>
<pre class="code">[TypeDescriptionProvider(<span style="color: blue;">typeof</span>(MyClassTypeDescriptionProvider))]
<span style="color: blue;">public partial class </span><span style="color: #2b91af;">MyClass </span>: ModelElement
{}</pre>
<p>The corresponding TypeDescriptor (provided by the <code>MyClassTypeDescriptionProvider</code> class) is loaded only the first time you build or rebuild your solution. Every time you start Visual Studio after that, this attribute seems to be ignored.</p>
<p>Fortunately there is another way to glue TypeDescriptors to your classes using a static method of the <code>TypeDescriptor</code> class at runtime:</p>
<pre class="code"><span style="color: #2b91af;">TypeDescriptor</span>.AddProvider(
   <span style="color: blue;">new </span><span style="color: #2b91af;">MyClassTypeDescriptionProvider</span>(), <span style="color: blue;">typeof</span>(<span style="color: #2b91af;">MyClass</span>));</pre>
<p>I think a good place for this code is the static constructor of the <code>MyClass</code> type:</p>
<pre class="code"><span style="color: blue;">partial class </span><span style="color: #2b91af;">MyClass
</span>{
    <span style="color: blue;">static </span>MyClass()
    {
        <span style="color: #2b91af;">TypeDescriptor</span>.AddProvider(
            <span style="color: blue;">new </span>MyClassTypeDescriptionProvider(),
            <span style="color: blue;">typeof</span>(<span style="color: #2b91af;">MyClass</span>));
    }
}</pre>
<p>Another interesting point is: Not only custom TypeDescriptors you write yourself are affected by this problem, also the TypeDescriptors that are generated by the DSL-Tools from your DslDefintion have to struggle with it:</p>
<p>In the <em>DSL Explorer</em> you can define custom TypeDescriptors for each <em>Domain Class</em> and each <em>Shape</em>. Even these TypeDescriptors will not be loaded after the first run. In other words: the definition of TypeDescriptors in the DSL Explorer is pretty useless as long as you do not add the three lines of code to each class. Of course this is something one can automate! <img src='http://www.ticklishtechs.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> I stole some code from <code>PropertiesGrid.tt</code> and added a few lines to create the <code>RegisterTypeDescriptor.tt</code>. Just add this file to your <code>Dsl</code> Project in the <code>GeneratedCode</code> folder and all TypeDescriptors defined in the <em>DSL Explore</em>r will be loaded every time you start your project.</p>
<div id="scid:fb3a1972-4489-4e52-abe7-25a00bb07fdf:1be880e0-1a85-4229-a307-aca8a23064bf" class="wlWriterSmartContent" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<p>Download: <a href="http://www.ticklishtechs.net/wp-content/uploads/2008/07/registertypedescriptors.zip" target="_blank">RegisterTypeDescriptors.tt</a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.ticklishtechs.net/2008/07/19/workaround-for-known-issue-with-typedescriptors-in-dsl-tools-for-visual-studio/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Even CodeVeil has bugs</title>
		<link>http://www.ticklishtechs.net/2008/07/14/even-codeveil-has-bugs/</link>
		<comments>http://www.ticklishtechs.net/2008/07/14/even-codeveil-has-bugs/#comments</comments>
		<pubDate>Mon, 14 Jul 2008 20:48:22 +0000</pubDate>
		<dc:creator>Wolfram Bernhardt</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[codeveil]]></category>

		<category><![CDATA[dotnet]]></category>

		<category><![CDATA[visual studio]]></category>

		<guid isPermaLink="false">http://www.ticklishtechs.net/2008/07/14/even-codeveil-has-bugs/</guid>
		<description><![CDATA[I love CodeVeil. From my point of view CodeVeil is simply the best tool to protect .NET assemblies from being reflectored, decompiled or whatever. It is very powerful, offers a wide range of protection aspects and still comes with a handy gui. So far I haven&#8217;t seen a method to crack veiled assemblies and that&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>I love CodeVeil. From my point of view CodeVeil is simply the best tool to protect .NET assemblies from being reflectored, decompiled or whatever. It is very powerful, offers a wide range of protection aspects and still comes with a handy gui. So far I haven&#8217;t seen a method to crack veiled assemblies and that&#8217;s why I really rely on it for my commercial products.</p>
<p>You don&#8217;t find bugs in CodeVeil when you try to find them, but half a year ago we found this one by chance. CodeVeil veils well, but the resulting code throws a mighty exception.</p>
<p>You don&#8217;t need spectacular code to lure the bug out of it&#8217;s hole - here is the prelude:</p>
<pre class="code"><span style="color: blue">private static void </span>Main(<span style="color: blue">string</span>[] args)
{
    <span style="color: green">// Get list and fill it with values
    </span><span style="color: #2b91af">List</span>&lt;<span style="color: #2b91af">Capsule</span>&lt;<span style="color: blue">int</span>&gt;&gt; l = <span style="color: blue">new </span><span style="color: #2b91af">List</span>&lt;<span style="color: #2b91af">Capsule</span>&lt;<span style="color: blue">int</span>&gt;&gt;();
    l.Add(<span style="color: blue">new </span><span style="color: #2b91af">Capsule</span>&lt;<span style="color: blue">int</span>&gt;(23));
    l.Add(<span style="color: blue">new </span><span style="color: #2b91af">Capsule</span>&lt;<span style="color: blue">int</span>&gt;(42));

    <span style="color: green">// Have it sorted
    </span><span style="color: #2b91af">List</span>&lt;<span style="color: #2b91af">Capsule</span>&lt;<span style="color: blue">int</span>&gt;&gt; l2 = GetSortedReturnList(l);

    <span style="color: green">// Show result
    </span><span style="color: blue">foreach </span>(<span style="color: #2b91af">Capsule</span>&lt;<span style="color: blue">int</span>&gt; ci <span style="color: blue">in </span>l2)
        <span style="color: #2b91af">Console</span>.WriteLine(ci.Item);

    <span style="color: #2b91af">Console</span>.ReadLine();
}</pre>
<p>A simple list of two <code>ints </code>that are encapsulated in a generic type. The generic type just makes sure that two items can be compared:</p>
<pre class="code"><span style="color: blue">internal class </span><span style="color: #2b91af">Capsule</span>&lt;T&gt; : <span style="color: #2b91af">IComparable</span>&lt;<span style="color: #2b91af">Capsule</span>&lt;T&gt;&gt;
{
    <span style="color: blue">public </span>T Item;

    <span style="color: blue">public </span>Capsule(T i)
    {
        Item = i;
    }

    <span style="color: blue">public int </span>CompareTo(<span style="color: #2b91af">Capsule</span>&lt;T&gt; other)
    {
        <span style="color: blue">return </span>Item.ToString().CompareTo(other.Item.ToString());
    }
}
</pre>
<p>And this code causes the exception when being executed by the veiled assembly:</p>
<pre class="code"><span style="color: blue">private static </span><span style="color: #2b91af">List</span>&lt;<span style="color: #2b91af">Capsule</span>&lt;T&gt;&gt; </pre>
<pre class="code">    GetSortedReturnList&lt;T&gt;(<span style="color: #2b91af">List</span>&lt;<span style="color: #2b91af">Capsule</span>&lt;T&gt;&gt; list)
{
    <span style="color: blue">int </span><strong>sortOrder</strong> = 1;
    list.Sort(
        <span style="color: blue">delegate</span>(<span style="color: #2b91af">Capsule</span>&lt;T&gt; a, <span style="color: #2b91af">Capsule</span>&lt;T&gt; b) </pre>
<pre class="code">          { <span style="color: blue">return </span><strong>sortOrder</strong> * a.CompareTo(b); });

    <span style="color: blue">return </span>(list);
}
</pre>
<p>The sore point is the <code>sortOrder</code> variable being multiplied with the result of a.CompareTo(b) used in an anonymous method. Okay, you wouldn&#8217;t expect this code from a beginner, but it&#8217;s not rocket-science either. So we were very astonished and it took us quite some time to track this down and to believe our eyes. Maybe the problem with CodeVeil is related to the internal representation of anonymous method. When you use a constant instead of a variable</p>
<p><code>const int sortOrder = 1;</code></p>
<p>the problem disappears. I guess the compiler eliminates the constant and CodeVeil will not see it. But it remains, when you use a Linq-notation here:</p>
<pre class="code">list.Sort((a, b) =&gt; a.CompareTo(b)*sortOrder);
</pre>
<p>As said before we found this bug half a year ago. We contacted Xheo and received a very quick and friendly reply, but no solution. Seasons went by and several new versions of CodeVeil were released; but this bug is still present. At least in the stand-alone version.</p>
<p>But there is hope: The new beta preview of the DeployLX suite contains an obviously new version of CodeVeil and the bug <u>is finally gone</u>. And - by the way - this new version seems to offer a nice package of new feature and improved power! So, please, Mr. Xheo, release a new stand-alone-version of CodeVeil based on the new beta preview!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ticklishtechs.net/2008/07/14/even-codeveil-has-bugs/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Where can I find the model filename in a text template (tt)?</title>
		<link>http://www.ticklishtechs.net/2008/07/03/where-can-i-find-the-model-filename-in-a-text-template-tt/</link>
		<comments>http://www.ticklishtechs.net/2008/07/03/where-can-i-find-the-model-filename-in-a-text-template-tt/#comments</comments>
		<pubDate>Thu, 03 Jul 2008 00:46:18 +0000</pubDate>
		<dc:creator>Benjamin Schröter</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[dotnet]]></category>

		<category><![CDATA[dsl]]></category>

		<category><![CDATA[t4]]></category>

		<category><![CDATA[visual studio]]></category>

		<category><![CDATA[vsx]]></category>

		<guid isPermaLink="false">http://www.ticklishtechs.net/2008/07/03/where-can-i-find-the-model-filename-in-a-text-template-tt/</guid>
		<description><![CDATA[As you know I was working with the DSL Tools in the past months. For some weeks I am writing the code generation for my project and I am struggling with new problems.
For some reason I want to know the filename of the model used in the tt-file. The default implementation provides you only with [...]]]></description>
			<content:encoded><![CDATA[<p>As you know I was working with the DSL Tools in the past months. For some weeks I am writing the code generation for my project and I am struggling with new problems.</p>
<p>For some reason I want to know the filename of the model used in the tt-file. The default implementation provides you only with a reference to the model but with no chance to get its filename.</p>
<p>In your tt-file you will find something similar to</p>
<pre class="code"><span style="background: gold">&lt;#@</span><span style="color: red;"> Language15 processor=</span>"<span style="color: blue;">Language15DirectiveProcessor</span>"
     <span style="color: red;">requires=</span>"<span style="color: blue;">fileName='Sample.mydsl1'</span>" <span style="background: gold">#&gt;</span></pre>
<p>This will use the <code>Language15DirectiveProcessor</code> to load the given file and provide your template with a global <code>ExampleModel</code> variable (of cause the name depends on your DSL and you can change it with the <code>provides</code> attribute in the tt-file).</p>
<p>To change the <code>Language15DirectiveProcessor</code> you can create a partial class in your DSL and add some code to it:</p>
<pre class="code"><span style="color: blue;">partial class </span><span style="color: #2b91af;">Language15DirectiveProcessor
</span>{
    <span style="color: blue;">protected override void </span>GenerateTransformCode
     (<span style="color: blue;">string </span>directiveName,
      <span style="color: #2b91af;">StringBuilder </span>codeBuffer,
      System.CodeDom.Compiler.<span style="color: #2b91af;">CodeDomProvider </span>languageProvider,
      <span style="color: #2b91af;">IDictionary</span>&lt;<span style="color: blue;">string</span>, <span style="color: blue;">string</span>&gt; requiresArguments,
      <span style="color: #2b91af;">IDictionary</span>&lt;<span style="color: blue;">string</span>, <span style="color: blue;">string</span>&gt; providesArguments)
      {
        <span style="color: blue;">base</span>.GenerateTransformCode(directiveName,
                    codeBuffer, languageProvider,
                    requiresArguments, providesArguments);           

        codeBuffer.AppendFormat(
           <span style="color: #a31515;">"public string {1} = @\"{0}\";"</span>,
             requiresArguments[<span style="color: #a31515;">"FileName"</span>],
             providesArguments[<span style="color: #a31515;">"FileName"</span>]);</pre>
<pre class="code">       codeBuffer.AppendLine();
    }

    <span style="color: blue;">protected override void </span>InitializeProvidesDictionary
    (<span style="color: blue;">string </span>directiveName,
      <span style="color: #2b91af;">IDictionary</span>&lt;<span style="color: blue;">string</span>, <span style="color: blue;">string</span>&gt; providesDictionary)
    {
        <span style="color: blue;">base</span>.InitializeProvidesDictionary(directiveName,
                            providesDictionary);

        providesDictionary.Add(<span style="color: #a31515;">"FileName"</span>,<span style="color: #a31515;">"FileName"</span>);
    }
}</pre>
<p>This adds a new global variable <code>FileName</code> to the tt and initializes it with the model file name.</p>
<p><strong>Attention:</strong> You see the variable in this example is generated by writing a line of C# code to the <code>codeBuffer</code>. This may be a bad idea if you want to use this DirectiveProcessor for templates where the template language is set to VB. The better way is to create the code using the Emit and CodeDom API, but I was to lazy to do it that way.</p>
<p>If anybody ports this code to work with VB templates by using the CodeDom or plain VB code, please post a comment here.</p>
<p><strong>Further reading</strong>: The process of creating your own DirectiveProcessor and everything you need to understand the code above can be found in the msdn: <a href="http://msdn.microsoft.com/en-us/library/bb126315.aspx">Creating Custom Text Template Directive Processors</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ticklishtechs.net/2008/07/03/where-can-i-find-the-model-filename-in-a-text-template-tt/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
