<?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>Julien Blin &#187; Development</title>
	<atom:link href="http://blog.jblin.com/category/development/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.jblin.com</link>
	<description>acts_as_architect( :.net, :rails )</description>
	<lastBuildDate>Tue, 02 Mar 2010 20:00:04 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>NAnt task to drop/create sqlite database from ActiveRecord</title>
		<link>http://blog.jblin.com/2009/12/nant-task-to-dropcreate-sqlite-database-from-activerecord/</link>
		<comments>http://blog.jblin.com/2009/12/nant-task-to-dropcreate-sqlite-database-from-activerecord/#comments</comments>
		<pubDate>Thu, 03 Dec 2009 20:00:04 +0000</pubDate>
		<dc:creator>Julien Blin</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[.Net]]></category>
		<category><![CDATA[ActiveRecord]]></category>
		<category><![CDATA[nant]]></category>
		<category><![CDATA[SQLite]]></category>

		<guid isPermaLink="false">http://blog.jblin.com/?p=95</guid>
		<description><![CDATA[I really like to use ActiveRecord when building small apps or internal tools. It offers a lot of great features of his older brother NHibernate, without freightening everybody on your team.
I also really like the ability to generate the database schema based on the domain entities, so you don&#8217;t have to worry about SQL and [...]]]></description>
			<content:encoded><![CDATA[<p>I really like to use <a href="http://www.castleproject.org/activerecord/index.html">ActiveRecord</a> when building small apps or internal tools. It offers a lot of great features of his older brother <a href="http://nhforge.org">NHibernate</a>, without freightening everybody on your team.</p>
<p>I also really like the ability to <a href="http://www.castleproject.org/activerecord/documentation/trunk/usersguide/schemagen.html">generate the database schema based on the domain entities</a>, so you don&#8217;t have to worry about SQL and DDL.<br />
Combine that with <a href="http://www.sqlite.org/">SQLite</a>, and you can develop on your local machine without an installed database server (like Sql Server). Makes it really easy  to setup a new development machine (checkout the code, build and run &#8211; it should works).</p>
<p><span id="more-95"></span></p>
<p>Unfortunately, the only way to do it provided by the framework is on the application code. So you end with something like that in your initializing file:</p>
<pre class="brush: csharp;">
ActiveRecordStarter.Initialize(typeof(ADomainEntity).Assembly, ActiveRecordSectionHandler.Instance);
#if DEBUG
    // ActiveRecordStarter.CreateSchema();
#end
</pre>
<p>The problems with this approach are multiples, just to name a few:</p>
<ul>
<li>you could potentially erase all your production data if you forget to comment line 3 (thus the #if DEBUG statement &#8211; just in case)</li>
<li>it&#8217;s not very handy : each time you want to drop/create the schema, you have to uncomment the line, run the application, stop it, comment the line.</li>
</ul>
<p>That&#8217;s why I created a <a href="http://nant.sourceforge.net/">NAnt</a> target, allowing the previous code to never appear in the application. You just use the target on your local machine when you want to drop and create the schema.</p>
<p>A really cool feature of NAnt is the ability to use the <a href="http://nant.sourceforge.net/release/latest/help/tasks/script.html">script</a> task: it allows you to use your favorite .Net language to code an inline task. In that case we use the ability to dynamically load the Domain Model assembly to feed the ActiveRecordStarter with the correct information.</p>
<pre class="brush: xml;">
&lt;script language=&quot;C#&quot;&gt;
  &lt;references&gt;
	&lt;include name=&quot;System.Data.dll&quot; /&gt;
	&lt;include name=&quot;Dependencies\SQLite.NET-0.21\SQLite.NET.dll&quot; /&gt;
	&lt;include name=&quot;Dependencies\Castle-net-2.0-release-2007-9-20\Castle.Core.dll&quot;/&gt;
	&lt;include name=&quot;Dependencies\Castle-net-2.0-release-2007-9-20\Castle.ActiveRecord.dll&quot;/&gt;
  &lt;/references&gt;
  &lt;imports&gt;
	&lt;import namespace=&quot;System.IO&quot; /&gt;
	&lt;import namespace=&quot;System.Collections&quot; /&gt;
	&lt;import namespace=&quot;System.Reflection&quot; /&gt;
	&lt;import namespace=&quot;Castle.ActiveRecord&quot; /&gt;
	&lt;import namespace=&quot;Castle.ActiveRecord.Framework.Config&quot; /&gt;
  &lt;/imports&gt;
  &lt;code&gt;
	&lt;![CDATA[
		public static void ScriptMain(Project project) {
			string dbFile = project.Properties[&quot;db.sqlite.path&quot;];
			string connectionString = string.Format(&quot;Data Source={0};Version=3;New=True&quot;, dbFile);
			string modelAssemblyFilePath = Path.Combine(
                                project.BaseDirectory,
                                @&quot;PathToTheModelAssembly.dll&quot;
                            );

			// Create DB and Schema
			IDictionary props = new Hashtable();
			props.Add(&quot;hibernate.connection.driver_class&quot;, &quot;NHibernate.Driver.SQLiteDriver&quot;);
			props.Add(&quot;hibernate.dialect&quot;, &quot;NHibernate.Dialect.SQLiteDialect&quot;);
			props.Add(&quot;hibernate.connection.provider&quot;, &quot;NHibernate.Connection.DriverConnectionProvider&quot;);
			props.Add(&quot;hibernate.connection.connection_string&quot;, connectionString);

			InPlaceConfigurationSource config = new InPlaceConfigurationSource();
			config.Add(typeof(ActiveRecordBase), props);

			project.Log(Level.Info, &quot;Loading ActiveRecord configuration...&quot;);
			ActiveRecordStarter.Initialize(Assembly.LoadFrom(modelAssemblyFilePath), config);

			project.Log(Level.Info, &quot;Dumping schema...&quot;);
			ActiveRecordStarter.CreateSchema();
		}
	  ]]&gt;
  &lt;/code&gt;
&lt;/script&gt;
</pre>
<p>In a nutshell:</p>
<ul>
<li>lines 3-6: don&#8217;t forget to add the necessary dependencies, otherwise compilation will fail. I use <a href="http://sourceforge.net/projects/adodotnetsqlite/">SQLLite.Net</a> library to connect to the sqlite database</li>
<li>line 18: notice the ability to use a NAnt property to define the sqlite file name</li>
<li>line 19: the &#8220;New=true&#8221; parameter will tell the provider to create the needed database file (you may need to add a task before this one to drop an existing file)</li>
<li>line 20: we specify the .net assembly that contains the ActiveRecord domain</li>
<li>line 26-33: we configure ActiveRecord using code, not a config file (much easier when using NAnt)</li>
</ul>
<p>You can also define another target, this time to generate a .sql file containing the schema for Sql Server, for example:</p>
<pre class="brush: xml;">
&lt;script language=&quot;C#&quot;&gt;
  &lt;references&gt;
	&lt;include name=&quot;System.Data.dll&quot; /&gt;
	&lt;include name=&quot;Dependencies\Castle-net-2.0-release-2007-9-20\Castle.Core.dll&quot;/&gt;
	&lt;include name=&quot;Dependencies\Castle-net-2.0-release-2007-9-20\Castle.ActiveRecord.dll&quot;/&gt;
  &lt;/references&gt;
  &lt;imports&gt;
	&lt;import namespace=&quot;System.IO&quot; /&gt;
	&lt;import namespace=&quot;System.Collections&quot; /&gt;
	&lt;import namespace=&quot;System.Reflection&quot; /&gt;
	&lt;import namespace=&quot;Castle.ActiveRecord&quot; /&gt;
	&lt;import namespace=&quot;Castle.ActiveRecord.Framework.Config&quot; /&gt;
  &lt;/imports&gt;
  &lt;code&gt;
	&lt;![CDATA[
		public static void ScriptMain(Project project) {
			string schemaFile = project.Properties[&quot;schema.file&quot;];
			string modelAssemblyFilePath = Path.Combine(
                                project.BaseDirectory,
                                @&quot;PathToTheModelAssembly.dll&quot;
                            );

			// Create DB and Schema
			IDictionary props = new Hashtable();
			props.Add(&quot;hibernate.connection.driver_class&quot;, &quot;NHibernate.Driver.SqlClientDriver&quot;);
			props.Add(&quot;hibernate.dialect&quot;, &quot;NHibernate.Dialect.MsSql2005Dialect&quot;);
			props.Add(&quot;hibernate.connection.provider&quot;, &quot;NHibernate.Connection.DriverConnectionProvider&quot;);

			InPlaceConfigurationSource config = new InPlaceConfigurationSource();
			config.Add(typeof(ActiveRecordBase), props);

			project.Log(Level.Info, &quot;Loading ActiveRecord configuration...&quot;);
			ActiveRecordStarter.Initialize(Assembly.LoadFrom(modelAssemblyFilePath), config);

			project.Log(Level.Info, &quot;Creating file...&quot;);
			ActiveRecordStarter.GenerateCreationScripts(schemaFile);
		}
	  ]]&gt;
  &lt;/code&gt;
&lt;/script&gt;
</pre>
<p>I believe a similar approach could be used in conjunction with <a href="http://www.nhforge.org/doc/nh/en/index.html#toolsetguide-s1">NHibernate schema generator</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jblin.com/2009/12/nant-task-to-dropcreate-sqlite-database-from-activerecord/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create a .wsdl file from an asmx web service with NAnt</title>
		<link>http://blog.jblin.com/2009/11/create-a-wsdl-file-from-an-asmx-web-service-with-nant/</link>
		<comments>http://blog.jblin.com/2009/11/create-a-wsdl-file-from-an-asmx-web-service-with-nant/#comments</comments>
		<pubDate>Sun, 29 Nov 2009 20:00:55 +0000</pubDate>
		<dc:creator>Julien Blin</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[.Net]]></category>
		<category><![CDATA[asmx]]></category>
		<category><![CDATA[Cassini]]></category>
		<category><![CDATA[nant]]></category>
		<category><![CDATA[Web Services]]></category>

		<guid isPermaLink="false">http://blog.jblin.com/?p=101</guid>
		<description><![CDATA[There are places where we are still stuck with .net framework 2.0 &#8211; so WCF is still not available. I&#8217;m currently working on such a project.
I&#8217;m using asmx web services, and i needed to be able to export the wsdl file generated by the framework, as part of an automated build.
It turns out that it seems [...]]]></description>
			<content:encoded><![CDATA[<p>There are places where we are still stuck with .net framework 2.0 &#8211; so WCF is still not available. I&#8217;m currently working on such a project.</p>
<p>I&#8217;m using asmx web services, and i needed to be able to export the wsdl file generated by the framework, as part of an automated build.<br />
It turns out that it seems there&#8217;s no way to generate a wsdl file from a web application directly without a web server.</p>
<p>So I decided to turn to <a href="http://nant.sourceforge.net/">NAnt</a> and Cassini (the web server integrated with visual studio) and came with the following target :</p>
<p><span id="more-101"></span></p>
<pre class="brush: xml;">
&lt;target name=&quot;generate-wsdl-files&quot;
        depends=&quot;build&quot;
        description=&quot;Regenerate wsdl files needed to access the web services&quot;&gt;
    &lt;property name=&quot;cassini.port&quot; value=&quot;1083&quot; /&gt;
    &lt;property name=&quot;webservices.url&quot; value=&quot;http://localhost:${cassini.port}&quot; /&gt;
    &lt;property name=&quot;wsdl.dir&quot; value=&quot;${project::get-base-directory()}\ExportWSDL&quot; /&gt;
    &lt;property name=&quot;project.web.path&quot; value=&quot;${project::get-base-directory()}\Sources\Web&quot; /&gt;

    &lt;exec program=&quot;${framework::get-tool-path('WebDev.WebServer.exe')}&quot;
          spawn=&quot;true&quot;
          pidproperty=&quot;cassini.pid&quot;&gt;
      &lt;arg value=&quot;/port:${cassini.port}&quot; /&gt;
      &lt;arg value=&quot;/path:&amp;quot;${project.web.path}&amp;quot;&quot; /&gt;
      &lt;arg value=&quot;/vpath:&amp;quot;/&amp;quot;&quot; /&gt;
    &lt;/exec&gt;

    &lt;sleep seconds=&quot;3&quot; /&gt;

    &lt;exec program=&quot;${framework::get-tool-path('disco.exe')}&quot; workingdir=&quot;${wsdl.dir}&quot;&gt;
      &lt;arg value=&quot;${webservices.url}/WebServices/AWebService.asmx&quot; /&gt;
      &lt;arg value=&quot;${webservices.url}/WebServices/AnotherWebService.asmx&quot; /&gt;
    &lt;/exec&gt;

    &lt;delete&gt;
      &lt;fileset basedir=&quot;${wsdl.dir}&quot;&gt;
        &lt;include name=&quot;*.disco&quot;/&gt;
        &lt;include name=&quot;*.discomap&quot;/&gt;
      &lt;/fileset&gt;
    &lt;/delete&gt;

    &lt;exec program=&quot;taskkill&quot;&gt;
      &lt;arg value=&quot;/PID&quot; /&gt;
      &lt;arg value=&quot;${cassini.pid}&quot; /&gt;
    &lt;/exec&gt;
  &lt;/target&gt;
</pre>
<p>What this target does is basically:</p>
<ul>
<li>set a bunch of properties: cassini port, export directory, the local path for the web project, etc.</li>
<li>line 9: start cassini (I believe you must have Visual Studio installed on the machine to do that), and very importantly <strong>spawns</strong> the process (meaning that NAnt will go on not waiting for the process to stop). The PID of the process is retained in a property (cassini.pid)</li>
<li>line 17: wait a couple of seconds for cassini to start and load the application (YMMV)</li>
<li>line 19: use the <a href="http://msdn.microsoft.com/en-us/library/cy2a3ybs(VS.80).aspx">disco.exe tool from the sdk</a> to produce a wsdl from a url &#8211; Note that you have to pass the list of all the asmx entries</li>
<li>line 24: delete the unnecessary .disco and .discomap files</li>
<li>line 31: kill the cassini process using <a href="http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/taskkill.mspx?mfr=true">taskkill</a></li>
</ul>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jblin.com/2009/11/create-a-wsdl-file-from-an-asmx-web-service-with-nant/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MindTouch Dream : a coroutine framework</title>
		<link>http://blog.jblin.com/2009/11/mindtouch-dream-a-coroutine-framework/</link>
		<comments>http://blog.jblin.com/2009/11/mindtouch-dream-a-coroutine-framework/#comments</comments>
		<pubDate>Fri, 20 Nov 2009 20:00:23 +0000</pubDate>
		<dc:creator>Julien Blin</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[.Net]]></category>

		<guid isPermaLink="false">http://blog.jblin.com/?p=46</guid>
		<description><![CDATA[Really interesting presentation about a concurrency in the .Net world :
MindTouch @ Monospace: Going Concurrent &#38; Keeping your Sanity «  MindTouch Developer Blog.
I should take the time to explore the MindTouch Dream framework.
]]></description>
			<content:encoded><![CDATA[<p>Really interesting presentation about a concurrency in the .Net world :</p>
<p><a href="http://blog.developer.mindtouch.com/2009/11/05/mindtouch-monospace-going-concurrent-keeping-your-sanity/">MindTouch @ Monospace: Going Concurrent &amp; Keeping your Sanity «  MindTouch Developer Blog</a>.</p>
<p>I should take the time to explore the <a href="http://developer.mindtouch.com/Dream">MindTouch Dream</a> framework.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jblin.com/2009/11/mindtouch-dream-a-coroutine-framework/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Git screencasts on tekpub</title>
		<link>http://blog.jblin.com/2009/11/git-screencasts-on-tekpub/</link>
		<comments>http://blog.jblin.com/2009/11/git-screencasts-on-tekpub/#comments</comments>
		<pubDate>Fri, 13 Nov 2009 20:00:46 +0000</pubDate>
		<dc:creator>Julien Blin</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Git]]></category>
		<category><![CDATA[Tekpub]]></category>

		<guid isPermaLink="false">http://blog.jblin.com/?p=25</guid>
		<description><![CDATA[I&#8217;ve just finished to watch the Mastering Git screencast series on tekpub.com
Though I was already familiar with Git, I learned a lot through the 12 episodes. Rob Conery takes the time to explain even the inner workings of Git, or how to simply integrate it with Visual Studio.
If you are using Git, or just interested [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just finished to watch the <a href="http://tekpub.com/preview/git">Mastering Git</a> screencast series on <a href="http://tekpub.com">tekpub.com</a></p>
<p>Though I was already familiar with Git, I learned a lot through the 12 episodes. Rob Conery takes the time to explain even the inner workings of Git, or how to simply integrate it with Visual Studio.</p>
<p>If you are using Git, or just interested in learning more about this really good tool, I encourage you to check these screencasts out.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jblin.com/2009/11/git-screencasts-on-tekpub/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
