<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" gd:etag="W/&quot;DU8EQ3k8eCp7ImA9WhBaEk0.&quot;"><id>tag:blogger.com,1999:blog-6511237790974218081</id><updated>2013-05-22T09:30:02.770+02:00</updated><category term="AOP" /><category term="Lean" /><category term="Visual Studio" /><category term="Domain Driven Design" /><category term="Team Foundation Server" /><category term="Architecture" /><category term="Metro" /><category term="Windows 8" /><category term="WebAPI" /><category term="Attached Behaviors" /><category term="Design Time Data" /><category term="Software Mason" /><category term="tales of an outlier" /><category term="Security" /><category term="Ensure" /><category term="WPC/TechDays" /><category term="Blendability" /><category term="SOA" /><category term="Azure" /><category term="async/await" /><category term="Unit Tests" /><category term="MongoDB" /><category term="Identity" /><category term="MEF" /><category term="Community" /><category term="TDD" /><category term="CQRS" /><category term="Presentation Pattern" /><category term="Memento" /><category term="Kanban" /><category term="Attached Properties" /><category term="VSIX" /><category term="Model View ViewModel" /><category term="Radical" /><category term="Windows Developer Conference" /><category term="Event Sourcing" /><category term="Why not..." /><category term="EmitMapper" /><category term="Windows 7" /><category term="PostSharp" /><category term="Extensibility" /><category term="Xaml" /><category term="Wcf" /><category term="MVP Award" /><category term="Inversion of Control" /><category term="Guisa" /><category term="TechEd" /><category term="WinRT" /><category term="Windows Phone 7" /><category term="RavenDB" /><category term="UI Composition" /><category term="NServiceBus" /><category term="Agile" /><category term="Castle Windsor" /><category term="User Experience" /><category term="ACS" /><category term="Jason" /><category term="NHibernate" /><category term="Italian Agile Day" /><category term="OpenXml" /><category term="WPF" /><category term="Fluent Interfaces" /><category term="Silverlight" /><title>Mauro and the sustainable development</title><subtitle type="html">The journey is the most important thing, not the destination.
Find your next destination and start travelling again.</subtitle><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://milestone.topics.it/feeds/posts/default" /><link rel="alternate" type="text/html" href="http://milestone.topics.it/" /><link rel="next" type="application/atom+xml" href="http://www.blogger.com/feeds/6511237790974218081/posts/default?start-index=26&amp;max-results=25&amp;redirect=false&amp;v=2" /><author><name>Mauro Servienti</name><uri>https://plus.google.com/109709600646686474961</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh4.googleusercontent.com/-KXU7umaJ7sQ/AAAAAAAAAAI/AAAAAAAAAAA/hZhvEAaYHiQ/s512-c/photo.jpg" /></author><generator version="7.00" uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults>707</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/tpx" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="tpx" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><entry gd:etag="W/&quot;DU8EQ3kycSp7ImA9WhBaEk0.&quot;"><id>tag:blogger.com,1999:blog-6511237790974218081.post-7122586779780859854</id><published>2013-05-22T09:30:00.000+02:00</published><updated>2013-05-22T09:30:02.799+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-05-22T09:30:02.799+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Software Mason" /><category scheme="http://www.blogger.com/atom/ns#" term="Radical" /><category scheme="http://www.blogger.com/atom/ns#" term="Inversion of Control" /><title>Expanding Radical IoC/DI support</title><content type="html">&lt;p&gt;We are pretty proud of the work we are doing with &lt;a href="http://radical.codeplex.com" target="_blank"&gt;Radical&lt;/a&gt; and now we are even pretty happy with the overall architecture of the whole toolkit. The reason is pretty simple we have decided (due to some requests) to add support for 2 new Inversion of Control containers: &lt;a href="https://code.google.com/p/autofac/"&gt;Autofac&lt;/a&gt; and &lt;a href="http://unity.codeplex.com/"&gt;Unity&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;We are proud because it has been a really easy task, that does not require any change to the toolkit proving that the architectural choices made some years ago to isolate the IoC infrastructure were pretty good choices.&lt;/p&gt; &lt;p&gt;We have now support for: &lt;a href="http://www.castleproject.org/projects/windsor/"&gt;Windsor&lt;/a&gt;, Puzzle (Radical built-in IoC container), Autofac and Unity (both v2 and v3).&lt;/p&gt; &lt;p&gt;Nuget packages:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;Windsor: &lt;a href="http://nuget.org/packages/Radical.Windows.Presentation.CastleWindsor"&gt;http://nuget.org/packages/Radical.Windows.Presentation.CastleWindsor&lt;/a&gt;&lt;/li&gt; &lt;li&gt;Puzzle: &lt;a href="http://nuget.org/packages/Radical.Windows.Presentation.Puzzle"&gt;http://nuget.org/packages/Radical.Windows.Presentation.Puzzle&lt;/a&gt;&lt;/li&gt; &lt;li&gt;Autofac: &lt;a href="http://nuget.org/packages/Radical.Windows.Presentation.Autofac"&gt;http://nuget.org/packages/Radical.Windows.Presentation.Autofac&lt;/a&gt;&lt;/li&gt; &lt;li&gt;Unity v2: &lt;a href="http://nuget.org/packages/Radical.Windows.Presentation.Unity2"&gt;http://nuget.org/packages/Radical.Windows.Presentation.Unity2&lt;/a&gt;&lt;/li&gt; &lt;li&gt;Unity v3: &lt;a href="http://nuget.org/packages/Radical.Windows.Presentation.Unity3"&gt;http://nuget.org/packages/Radical.Windows.Presentation.Unity3&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;.m&lt;/p&gt;  &lt;img src="http://feeds.feedburner.com/~r/tpx/~4/xxWwTvG6nd0" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://milestone.topics.it/feeds/7122586779780859854/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://milestone.topics.it/2013/05/expanding-radical-iocdi-support.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6511237790974218081/posts/default/7122586779780859854?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6511237790974218081/posts/default/7122586779780859854?v=2" /><link rel="alternate" type="text/html" href="http://milestone.topics.it/2013/05/expanding-radical-iocdi-support.html" title="Expanding Radical IoC/DI support" /><author><name>Mauro Servienti</name><uri>https://plus.google.com/109709600646686474961</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh4.googleusercontent.com/-KXU7umaJ7sQ/AAAAAAAAAAI/AAAAAAAAAAA/hZhvEAaYHiQ/s512-c/photo.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;D0EMQXg8eyp7ImA9WhBUGEk.&quot;"><id>tag:blogger.com,1999:blog-6511237790974218081.post-1485704427737941226</id><published>2013-05-06T15:08:00.000+02:00</published><updated>2013-05-06T15:08:00.673+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-05-06T15:08:00.673+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Domain Driven Design" /><category scheme="http://www.blogger.com/atom/ns#" term="NServiceBus" /><title>NServiceBus: error queues</title><content type="html">&lt;p&gt;&lt;a href="http://www.nservicebus.com/" target="_blank"&gt;NServiceBus&lt;/a&gt; has the concept of error queue, that is used, as the name implies, &lt;a href="http://support.nservicebus.com/customer/portal/articles/862410-how-do-i-handle-exceptions-" target="_blank"&gt;when an error occurs&lt;/a&gt;; given this behavior the debate should move to:&lt;/p&gt; &lt;h3&gt;What is an error?&lt;/h3&gt; &lt;p&gt;Many things can be categorized as an error:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;pure bugs such as unhandled exceptions;&lt;/li&gt; &lt;li&gt;validation failures: the incoming message does not satisfies the business validation rules;&lt;/li&gt; &lt;li&gt;security violations: the incoming message, due the current security context, cannot be handled;&lt;/li&gt; &lt;li&gt;etc.;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;What we get for free in NServiceBus is that if our message handler does something like this:&lt;/p&gt; &lt;blockquote&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;class&lt;/span&gt; SampleHandler : IHandleMessages&amp;lt;SampleMessage&amp;gt;
{
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Handle( SampleMessage message )
    {
        &lt;span class="kwrd"&gt;if&lt;/span&gt;( !&lt;span class="kwrd"&gt;this&lt;/span&gt;.IsValid( message ) )
        {
             &lt;span class="kwrd"&gt;throw&lt;/span&gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; ArgumentException( &lt;span class="str"&gt;"Invalid message"&lt;/span&gt; );
        }

        &lt;span class="rem"&gt;//message handling if validation succeed&lt;/span&gt;
    }
}&lt;/pre&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;
&lt;/blockquote&gt;
&lt;p&gt;and an invalid message comes in the retry logic retries for 5 times (by default) and then if the message is still invalid moves the message to the error queue.&lt;/p&gt;
&lt;h3&gt;But…&lt;/h3&gt;
&lt;p&gt;Some legitimate questions arise from the above sample:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;is it possible that if message A is considered invalid at the first attempt can be considered valid at a subsequent attempt?&lt;/li&gt;
&lt;li&gt;is a validation failure the same as an unhandled exception?&lt;/li&gt;
&lt;li&gt;does it make sense to have message failed due to a validation failure in the same can as a message failed due to a bug?&lt;br&gt;do they have the same business meaning?&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;Do all the above questions mean that the default NServiceBus behavior is wrong? &lt;strong&gt;absolutely not, period&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;The above questions simply put evidence on the fact that every little thing that happens in the world we are modeling has a meaning, from the business perspective, and that meaning must be magnified to deeply understand how to treat it.&lt;/p&gt;
&lt;p&gt;Next time we’ll see how we can leverage the message handling pipeline to change the default above behavior to satisfy our needs.&lt;/p&gt;
&lt;p&gt;.m&lt;/p&gt;  &lt;img src="http://feeds.feedburner.com/~r/tpx/~4/P4vm80RmdPg" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://milestone.topics.it/feeds/1485704427737941226/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://milestone.topics.it/2013/05/nservicebus-error-queues.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6511237790974218081/posts/default/1485704427737941226?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6511237790974218081/posts/default/1485704427737941226?v=2" /><link rel="alternate" type="text/html" href="http://milestone.topics.it/2013/05/nservicebus-error-queues.html" title="NServiceBus: error queues" /><author><name>Mauro Servienti</name><uri>https://plus.google.com/109709600646686474961</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh4.googleusercontent.com/-KXU7umaJ7sQ/AAAAAAAAAAI/AAAAAAAAAAA/hZhvEAaYHiQ/s512-c/photo.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;CkYGSXw4cCp7ImA9WhBUFUo.&quot;"><id>tag:blogger.com,1999:blog-6511237790974218081.post-4301745791167635644</id><published>2013-05-03T10:35:00.001+02:00</published><updated>2013-05-03T10:35:28.238+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-05-03T10:35:28.238+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="RavenDB" /><category scheme="http://www.blogger.com/atom/ns#" term="Azure" /><title>RavenDB: Worker Role vs. Virtual Machine</title><content type="html">&lt;p&gt;We have seen that in order to deploy &lt;a href="http://ravendb.net/" target="_blank"&gt;RavenDB&lt;/a&gt; on Windows &lt;a href="http://www.windowsazure.com/" target="_blank"&gt;Azure&lt;/a&gt; we 2 main options:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="http://milestone.topics.it/2012/11/running-ravendb-as-windows-azure-worker.html" target="_blank"&gt;Deploy RavenDB as a worker role&lt;/a&gt;;&lt;/li&gt; &lt;li&gt;&lt;a href="http://milestone.topics.it/2012/11/running-ravendb-on-windows-azure-using.html" target="_blank"&gt;Deploy using a Virtual Machine&lt;/a&gt;;&lt;/li&gt;&lt;/ul&gt; &lt;h3&gt;Which is the best bet?&lt;/h3&gt; &lt;p&gt;Now that Azure Virtual Machines are a fully supported feature I have to say that they are the preferred solution, or even the only real solution.&lt;/p&gt; &lt;h3&gt;Why?&lt;/h3&gt; &lt;p&gt;Control is the keyword. Scaling a database is not just a matter of adding power (vertical scaling) or instances (horizontal scaling), scaling a database requires full control over the scaling topology and the Azure worker roles are not thought with control over topology in mind, it is simply not their role to give us control, they are here to give us a really, and powerful, easy way to scale.&lt;/p&gt; &lt;p&gt;Worker roles live behind, and there is no way to avoid this, a network load balancer that hides from the outside the roles topology, preventing upfront to have a master-slave relation within database instances hosted in different role instances.&lt;/p&gt; &lt;p&gt;The only concrete way to host RavenDB (any db?) is to have full control over the network topology, and have full knowledge of the topology from the client perspective, for example we need to know that from a certain point on we are connected to a slave and not anymore to the master, and to have full control we need to leverage the power of the Azure Virtual Machines where we can do quite all we want in term of machine configuration and of network configuration.&lt;/p&gt; &lt;p&gt;Without loosing to much in term of time-to-react to scale requests, &lt;a href="http://milestone.topics.it/2012/11/running-ravendb-on-windows-azure-with.html" target="_blank"&gt;like we already said&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;.m&lt;/p&gt;  &lt;img src="http://feeds.feedburner.com/~r/tpx/~4/hNkyH0V4dow" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://milestone.topics.it/feeds/4301745791167635644/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://milestone.topics.it/2013/05/ravendb-worker-role-vs-virtual-machine.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6511237790974218081/posts/default/4301745791167635644?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6511237790974218081/posts/default/4301745791167635644?v=2" /><link rel="alternate" type="text/html" href="http://milestone.topics.it/2013/05/ravendb-worker-role-vs-virtual-machine.html" title="RavenDB: Worker Role vs. Virtual Machine" /><author><name>Mauro Servienti</name><uri>https://plus.google.com/109709600646686474961</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh4.googleusercontent.com/-KXU7umaJ7sQ/AAAAAAAAAAI/AAAAAAAAAAA/hZhvEAaYHiQ/s512-c/photo.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;DU4GQn86cCp7ImA9WhBUE04.&quot;"><id>tag:blogger.com,1999:blog-6511237790974218081.post-983853959714778048</id><published>2013-04-30T18:05:00.001+02:00</published><updated>2013-04-30T18:05:23.118+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-04-30T18:05:23.118+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="NServiceBus" /><title>NServiceBus, Windsor and message scopes</title><content type="html">&lt;p&gt;if you are working with &lt;a href="http://www.nservicebus.com/" target="_blank"&gt;NServiceBus&lt;/a&gt;, using as backend IoC container Castle Windsor, remember that under the hood NServiceBus utilizes the Windsor scope feature to create a scope “around” messages in order to isolate dependencies required by each message handler.&lt;/p&gt; &lt;p&gt;In this case if you need to have a component, registered in Windsor, that has its lifestyle bound to the message lifecycle it is enough to register the component using the “LifestyleScope”:&lt;/p&gt; &lt;blockquote&gt;&lt;pre class="csharpcode"&gt;container.Register
(
    Component.For&amp;lt;MyAmazingComponent&amp;gt;().&lt;font style="background-color: #ffff00"&gt;LifestyleScoped&lt;/font&gt;()
);&lt;/pre&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;
&lt;/blockquote&gt;
&lt;p&gt;.m&lt;/p&gt;  &lt;img src="http://feeds.feedburner.com/~r/tpx/~4/DbWmtZVZNUg" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://milestone.topics.it/feeds/983853959714778048/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://milestone.topics.it/2013/04/nservicebus-windsor-and-message-scopes.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6511237790974218081/posts/default/983853959714778048?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6511237790974218081/posts/default/983853959714778048?v=2" /><link rel="alternate" type="text/html" href="http://milestone.topics.it/2013/04/nservicebus-windsor-and-message-scopes.html" title="NServiceBus, Windsor and message scopes" /><author><name>Mauro Servienti</name><uri>https://plus.google.com/109709600646686474961</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh4.googleusercontent.com/-KXU7umaJ7sQ/AAAAAAAAAAI/AAAAAAAAAAA/hZhvEAaYHiQ/s512-c/photo.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;CkUAQX45fCp7ImA9WhBVEkQ.&quot;"><id>tag:blogger.com,1999:blog-6511237790974218081.post-235096000207448225</id><published>2013-04-18T15:04:00.000+02:00</published><updated>2013-04-18T15:04:00.024+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-04-18T15:04:00.024+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Software Mason" /><category scheme="http://www.blogger.com/atom/ns#" term="CQRS" /><title>Jason v0.2.1.0: retry policies</title><content type="html">&lt;p&gt;&lt;a href="http://milestone.topics.it/2013/04/jason-v02-configuration-improvements.html" target="_blank"&gt;As promised&lt;/a&gt; here we are :-)&lt;/p&gt; &lt;p&gt;One of our customer, using &lt;a href="http://jason.codeplex.com/" target="_blank"&gt;Jason&lt;/a&gt;, has a requirement to implement the concept of retry during the standard command execution flow. basically they have a situation where some infrastructure/transient exceptions can be raised during the command execution request and they want to be able to retry without bothering the client if not needed.&lt;/p&gt; &lt;h3&gt;Retry Policy&lt;/h3&gt; &lt;p&gt;In Jason v0.2.1.0, at the time of this writing in beta, we introduced the concept of retry policy; a retry policy is something that implements the ICommandExecutionRetryPolicy interface:&lt;/p&gt; &lt;blockquote&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;interface&lt;/span&gt; ICommandExecutionRetryPolicy
{
    &lt;span class="kwrd"&gt;object&lt;/span&gt; Execute( Object command, Func&amp;lt;ICommandHandler&amp;gt; handlerFactory );
}&lt;/pre&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;
&lt;/blockquote&gt;
&lt;p&gt;And can be injected into the Jason configuration in the following way:&lt;/p&gt;
&lt;blockquote&gt;&lt;pre class="csharpcode"&gt;jasonConfig.UsingAsRetryPolicy&amp;lt;MyCustomPolicy&amp;gt;();&lt;/pre&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;
&lt;/blockquote&gt;
&lt;p&gt;Where MyCustomPolicy is a class that implements ICommandExecutionRetryPolicy. In the above sample the policy is registered in the container at initialization time and used by the various Jason entry point to handle all the retry logic.&lt;/p&gt;
&lt;p&gt;There is one built-in retry policy in Jason that can be used to handle retries in case of failure:&lt;/p&gt;
&lt;blockquote&gt;&lt;pre class="csharpcode"&gt;jasonConfig.UsingAsRetryPolicy( &lt;span class="kwrd"&gt;new&lt;/span&gt; DelegateCommandExecutionRetryPolicy()
{
    DefaultRetryDelay = 200,
    ShouldRetry = e =&amp;gt; e.Retry = ( e.Error &lt;span class="kwrd"&gt;is&lt;/span&gt; NotSupportedException &amp;amp;&amp;amp; e.CurrentRetryCount &amp;lt; 5 )
} );&lt;/pre&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;

&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;
&lt;/blockquote&gt;
&lt;p&gt;In this case the policy is still registered in the container using the supplied instance, at runtime if a failure occurs the policy is queried to determine if a retry should be attempted.&lt;/p&gt;
&lt;p&gt;.m&lt;/p&gt;  &lt;img src="http://feeds.feedburner.com/~r/tpx/~4/Qcuoxp9NokM" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://milestone.topics.it/feeds/235096000207448225/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://milestone.topics.it/2013/04/jason-v0210-retry-policies.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6511237790974218081/posts/default/235096000207448225?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6511237790974218081/posts/default/235096000207448225?v=2" /><link rel="alternate" type="text/html" href="http://milestone.topics.it/2013/04/jason-v0210-retry-policies.html" title="Jason v0.2.1.0: retry policies" /><author><name>Mauro Servienti</name><uri>https://plus.google.com/109709600646686474961</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh4.googleusercontent.com/-KXU7umaJ7sQ/AAAAAAAAAAI/AAAAAAAAAAA/hZhvEAaYHiQ/s512-c/photo.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;C04ESXY6fCp7ImA9WhBVEU0.&quot;"><id>tag:blogger.com,1999:blog-6511237790974218081.post-906381735948668933</id><published>2013-04-16T10:45:00.001+02:00</published><updated>2013-04-16T10:45:08.814+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-04-16T10:45:08.814+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Jason" /><category scheme="http://www.blogger.com/atom/ns#" term="CQRS" /><title>Jason v0.2: configuration improvements and breaking changes</title><content type="html">&lt;p&gt;As we have &lt;a href="http://milestone.topics.it/2012/11/jason-way-to-handle-c-of-cqrs.html" target="_blank"&gt;already&lt;/a&gt; &lt;a href="http://milestone.topics.it/2012/11/jason-mvc-webapi-hosting.html" target="_blank"&gt;discussed&lt;/a&gt; &lt;a href="http://jason.codeplex.com/" target="_blank"&gt;Jason&lt;/a&gt; is an infrastructure framework to handle the “Command” portion of the CQRS pattern, due to some customer feedback and requests today we released a brand new version of the whole toolkit adding a lot of improvements and, unfortunately, some breaking changes.&lt;/p&gt; &lt;h3&gt;One configuration to rule them all&lt;/h3&gt; &lt;p&gt;In the previous Jason version there was one different configuration per hosting type, basically in order to host Jason as a WCF service the developer needed to build a specific configuration that was different from the one required to host Jason as a WebAPI controller. This difference leaded to one big issue: you simply cannot host, in the same application, a Jason API controller and a Jason WCF service.&lt;/p&gt; &lt;p&gt;In v0.2 we solved this scenario rebuilding the whole configuration stuff:&lt;/p&gt; &lt;blockquote&gt;&lt;pre class="csharpcode"&gt;var jasonConfig = &lt;span class="kwrd"&gt;new&lt;/span&gt; DefaultJasonServerConfiguration
(
    pathToScanForAssemblies: Path.Combine( AppDomain.CurrentDomain.BaseDirectory, &lt;span class="str"&gt;"bin"&lt;/span&gt; ),
    assemblySelectPattern: assemblySelectPattern
);

jasonConfig.AddEndpoint( &lt;span class="kwrd"&gt;new&lt;/span&gt; Jason.WebAPI.JasonWebAPIEndpoint() 
{
    TypeNameHandling = TypeNameHandling.Objects
} );

jasonConfig.AddEndpoint( &lt;span class="kwrd"&gt;new&lt;/span&gt; Jason.Server.JasonWcfEndpoint()
{
    CommandsSelector = t =&amp;gt;
    {
        &lt;span class="kwrd"&gt;return&lt;/span&gt; t.IsAttributeDefined&amp;lt;DataContractAttribute&amp;gt;()
            &amp;amp;&amp;amp; ( t.Name.EndsWith( &lt;span class="str"&gt;"Command"&lt;/span&gt; ) || t.Name.EndsWith( &lt;span class="str"&gt;"CommandResponse"&lt;/span&gt; ) );
    }
} );

jasonConfig.Initialize();&lt;/pre&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;
&lt;/blockquote&gt;
&lt;p&gt;We are building just one single configuration adding 2 different endpoints each one with its own configuration peculiarities.&lt;/p&gt;
&lt;h3&gt;Inversion of control support&lt;/h3&gt;
&lt;p&gt;Jason heavily relies on the Inversion of Control pattern to work and depends on an Inversion of Control container but we do not want, as in previous versions, to force the user to introduce an IoC container in the solution only to support Jason and we especially do not want you to remember to register the internal Jason type that are required to work.&lt;/p&gt;
&lt;p&gt;In v0.2 we leverage the power of the &lt;a href="http://radical.codeplex.com" target="_blank"&gt;Radical&lt;/a&gt; built-in &lt;a href="http://milestone.topics.it/search?q=PuzzleContainer" target="_blank"&gt;PuzzleContainer&lt;/a&gt; (that is now available in all Radical versions) to support the IoC Jason needs, the internal container is exposed by the configuration via the Container property and can be used to register custom types required during the Jason usage.&lt;/p&gt;
&lt;p&gt;Obviously the default internal container can be easily replaced in order to integrate Jason in your development lifecycle using your favorite container of choice. In order to achieve that it is enough to replace the built-in container via the configuration Container property where the IJasonContainer is just a proxy interface to abstract the container concept.&lt;/p&gt;
&lt;p&gt;Here is a sample implementation to inject Castle Windsor:&lt;/p&gt;
&lt;blockquote&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; WindsorJasonContainerProxy : Jason.Configuration.IJasonContainer
{
    IWindsorContainer container;

    &lt;span class="kwrd"&gt;public&lt;/span&gt; WindsorJasonContainerProxy( IWindsorContainer container )
    {
        &lt;span class="kwrd"&gt;this&lt;/span&gt;.container = container;
    }

    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; RegisterAsTransient( IEnumerable&amp;lt;Type&amp;gt; contracts, Type implementation )
    {
        &lt;span class="kwrd"&gt;this&lt;/span&gt;.container.Register( Component.For( contracts ).ImplementedBy( implementation ).LifestyleTransient() );
    }

    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; RegisterAsSingleton( IEnumerable&amp;lt;Type&amp;gt; contracts, Type implementation )
    {
        &lt;span class="kwrd"&gt;this&lt;/span&gt;.container.Register( Component.For( contracts ).ImplementedBy( implementation ).LifestyleSingleton() );
    }

    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; RegisterInstance( IEnumerable&amp;lt;Type&amp;gt; contracts, &lt;span class="kwrd"&gt;object&lt;/span&gt; instance )
    {
        &lt;span class="kwrd"&gt;this&lt;/span&gt;.container.Register( Component.For( contracts ).Instance( instance ).LifestyleSingleton() );
    }

    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; RegisterTypeAsTransient( Type implementation )
    {
        &lt;span class="kwrd"&gt;this&lt;/span&gt;.container.Register( Component.For( implementation ).LifestyleTransient() );
    }

    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; RegisterTypeAsSingleton( Type implementation )
    {
        &lt;span class="kwrd"&gt;this&lt;/span&gt;.container.Register( Component.For( implementation ).LifestyleSingleton() );
    }

    &lt;span class="kwrd"&gt;public&lt;/span&gt; IEnumerable&amp;lt;T&amp;gt; ResolveAll&amp;lt;T&amp;gt;()
    {
        &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;this&lt;/span&gt;.container.ResolveAll&amp;lt;T&amp;gt;();
    }

    &lt;span class="kwrd"&gt;public&lt;/span&gt; T Resolve&amp;lt;T&amp;gt;()
    {
        &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;this&lt;/span&gt;.container.Resolve&amp;lt;T&amp;gt;();
    }

    &lt;span class="kwrd"&gt;public&lt;/span&gt; IEnumerable&amp;lt;&lt;span class="kwrd"&gt;object&lt;/span&gt;&amp;gt; ResolveAll( Type t )
    {
        &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;this&lt;/span&gt;.container.ResolveAll( t ).Cast&amp;lt;Object&amp;gt;();
    }

    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;object&lt;/span&gt; Resolve( Type t )
    {
        &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;this&lt;/span&gt;.container.Resolve( t );
    }

    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Release( &lt;span class="kwrd"&gt;object&lt;/span&gt; instance )
    {
        &lt;span class="kwrd"&gt;this&lt;/span&gt;.container.Release( instance );
    }
}&lt;/pre&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;
&lt;/blockquote&gt;
&lt;p&gt;As said just a trivial proxy that can be used in the following manner:&lt;/p&gt;
&lt;blockquote&gt;&lt;pre class="csharpcode"&gt;var jasonConfig = &lt;span class="kwrd"&gt;new&lt;/span&gt; DefaultJasonServerConfiguration( Path.Combine( AppDomain.CurrentDomain.BaseDirectory, &lt;span class="str"&gt;"bin"&lt;/span&gt; ) )
{
    Container = &lt;span class="kwrd"&gt;new&lt;/span&gt; WindsorJasonContainerProxy( yourWindsorInstance )
};&lt;/pre&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;
&lt;/blockquote&gt;
&lt;p&gt;After that Jason will use your container to register its own required types and to resolve at runtime the required components.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Next time: Jason retry policies.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;.m&lt;/p&gt;  &lt;img src="http://feeds.feedburner.com/~r/tpx/~4/6mU8oB6qGmc" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://milestone.topics.it/feeds/906381735948668933/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://milestone.topics.it/2013/04/jason-v02-configuration-improvements.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6511237790974218081/posts/default/906381735948668933?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6511237790974218081/posts/default/906381735948668933?v=2" /><link rel="alternate" type="text/html" href="http://milestone.topics.it/2013/04/jason-v02-configuration-improvements.html" title="Jason v0.2: configuration improvements and breaking changes" /><author><name>Mauro Servienti</name><uri>https://plus.google.com/109709600646686474961</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh4.googleusercontent.com/-KXU7umaJ7sQ/AAAAAAAAAAI/AAAAAAAAAAA/hZhvEAaYHiQ/s512-c/photo.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;DEAMQXo_eip7ImA9WhBWF0g.&quot;"><id>tag:blogger.com,1999:blog-6511237790974218081.post-3626823813204300680</id><published>2013-04-12T10:53:00.000+02:00</published><updated>2013-04-12T10:53:00.442+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-04-12T10:53:00.442+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Software Mason" /><category scheme="http://www.blogger.com/atom/ns#" term="RavenDB" /><title>RavenDB: Integrated Windows Authentication</title><content type="html">&lt;p&gt;A couple of days ago I was at a customer and one of the raised issues, when dealing with RavenDB Windows authentication, was how to use a real “Integrated Windows Authentication” in order to have the credentials of the user currently running the client process flow to the server through the HTTP protocol.&lt;/p&gt; &lt;p&gt;After a bit of digging in the .net documentation the solution is trivial:&lt;/p&gt; &lt;blockquote&gt;&lt;pre class="csharpcode"&gt;Uri uri = &lt;span class="kwrd"&gt;new&lt;/span&gt; Uri( &lt;span class="str"&gt;"http://localhost:8080/"&lt;/span&gt; );
ICredentials credentials = CredentialCache.DefaultCredentials;
NetworkCredential credential = credentials.GetCredential( uri, &lt;span class="str"&gt;"Basic"&lt;/span&gt; );

var store = &lt;span class="kwrd"&gt;new&lt;/span&gt; DocumentStore()
{
    Url = &lt;span class="str"&gt;"http://localhost:8080/"&lt;/span&gt;,
    DefaultDatabase = &lt;span class="str"&gt;"database-name"&lt;/span&gt;,
    Credentials = credential
}.Initialize();&lt;/pre&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;
&lt;/blockquote&gt;
&lt;p&gt;The above snipped creates a new DocumentStore whose credentials are ready to transport the current user credentials.&lt;/p&gt;
&lt;p&gt;.m&lt;/p&gt;  &lt;img src="http://feeds.feedburner.com/~r/tpx/~4/u6XzB3JOxjc" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://milestone.topics.it/feeds/3626823813204300680/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://milestone.topics.it/2013/04/ravendb-integrated-windows.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6511237790974218081/posts/default/3626823813204300680?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6511237790974218081/posts/default/3626823813204300680?v=2" /><link rel="alternate" type="text/html" href="http://milestone.topics.it/2013/04/ravendb-integrated-windows.html" title="RavenDB: Integrated Windows Authentication" /><author><name>Mauro Servienti</name><uri>https://plus.google.com/109709600646686474961</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh4.googleusercontent.com/-KXU7umaJ7sQ/AAAAAAAAAAI/AAAAAAAAAAA/hZhvEAaYHiQ/s512-c/photo.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;CkcAQXw8fip7ImA9WhBXGUQ.&quot;"><id>tag:blogger.com,1999:blog-6511237790974218081.post-7451734358498891281</id><published>2013-04-03T13:54:00.000+02:00</published><updated>2013-04-03T13:54:00.276+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-04-03T13:54:00.276+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="RavenDB" /><category scheme="http://www.blogger.com/atom/ns#" term="Azure" /><title>RavenDB Worker Role on Windows Azure: create service users</title><content type="html">&lt;p&gt;When creating a Worker Role on Windows &lt;a href="http://www.windowsazure.com/" target="_blank"&gt;Azure&lt;/a&gt;, due to the nature of the worker role, we need to be fully auto-consistent: each time the role is deployed (or re-imaged) into the Azure infrastructure a brand new virtual machine is created to host the role thus if the role needs, in order to work, some OS customization we need to do those customizations at role startup.&lt;/p&gt; &lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/windowsazure/gg456327.aspx" target="_blank"&gt;Startup tasks&lt;/a&gt; are provided exactly to achieve that.&lt;/p&gt; &lt;p&gt;In order to setup &lt;a href="http://ravendb.net" target="_blank"&gt;RavenDB&lt;/a&gt;, when using Windows Authentication, you need at least 2 users:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;An administrator to perform administrative tasks, such as backups or system level operations;&lt;/li&gt; &lt;li&gt;A standard user in order to connect and operate on a database;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;Each time the role is deployed users must be created on the newly deployed virtual machine.&lt;/p&gt; &lt;p&gt;A startup task is a &lt;strong&gt;separate process&lt;/strong&gt; that can be launched at role startup, the task definition is created in the “ServiceDefinition.csdef” file:&lt;/p&gt; &lt;blockquote&gt; &lt;div id="codeSnippetWrapper"&gt;&lt;pre id="codeSnippet" style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Startup&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;      &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Task&lt;/span&gt; &lt;span style="color: #ff0000"&gt;commandLine&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="Startup\CreateWindowsUser.exe"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;executionContext&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="elevated"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;taskType&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="simple"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Environment&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;          &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Variable&lt;/span&gt; &lt;span style="color: #ff0000"&gt;name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="emulated"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;            &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;RoleInstanceValue&lt;/span&gt; &lt;span style="color: #ff0000"&gt;xpath&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="/RoleEnvironment/Deployment/@emulated"&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;br&gt;          &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Variable&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;          &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Variable&lt;/span&gt; &lt;span style="color: #ff0000"&gt;name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="username"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;            &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;RoleInstanceValue&lt;/span&gt; &lt;span style="color: #ff0000"&gt;xpath&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="/RoleEnvironment/CurrentInstance/ConfigurationSettings/ConfigurationSetting[@name='RavenUserUsername']/@value"&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;br&gt;          &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Variable&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;          &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Variable&lt;/span&gt; &lt;span style="color: #ff0000"&gt;name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="password"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;            &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;RoleInstanceValue&lt;/span&gt; &lt;span style="color: #ff0000"&gt;xpath&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="/RoleEnvironment/CurrentInstance/ConfigurationSettings/ConfigurationSetting[@name='RavenUserPassword']/@value"&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;br&gt;          &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Variable&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;          &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Variable&lt;/span&gt; &lt;span style="color: #ff0000"&gt;name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="admin"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;value&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="False"&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;br&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Environment&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;      &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Task&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Startup&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;p&gt;As you can see we are calling an external process, with elevation, and we’ll wait for the process to complete before moving on (simple taskType); if we need to pass information, defined in the role settings, to the external task the only way, as far as I know, is to use a shared environment variable. In this sample we are passing to the external task the username and password of the user we need to create, a flag that indicates if the user should be an administrator or not, and a flag that tells to the external process if we are running in the Azure emulator or not.&lt;/p&gt;
&lt;p&gt;We can launch as many tasks as we want, and in the real scenario we are launching the above task 2 times, with different parameters, in order to create the 2 required users.&lt;/p&gt;
&lt;p&gt;The external process does nothing special, it just creates a user, using the provided info, via the System.DirectoryServices.AccountManagement namespace classes.&lt;/p&gt;
&lt;p&gt;.m&lt;/p&gt;  &lt;img src="http://feeds.feedburner.com/~r/tpx/~4/-PhecJPJ9B4" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://milestone.topics.it/feeds/7451734358498891281/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://milestone.topics.it/2013/04/ravendb-worker-role-on-windows-azure.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6511237790974218081/posts/default/7451734358498891281?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6511237790974218081/posts/default/7451734358498891281?v=2" /><link rel="alternate" type="text/html" href="http://milestone.topics.it/2013/04/ravendb-worker-role-on-windows-azure.html" title="RavenDB Worker Role on Windows Azure: create service users" /><author><name>Mauro Servienti</name><uri>https://plus.google.com/109709600646686474961</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh4.googleusercontent.com/-KXU7umaJ7sQ/AAAAAAAAAAI/AAAAAAAAAAA/hZhvEAaYHiQ/s512-c/photo.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;CUYCQXw7eCp7ImA9WhBRFEo.&quot;"><id>tag:blogger.com,1999:blog-6511237790974218081.post-5623853902519612478</id><published>2013-03-05T09:46:00.000+01:00</published><updated>2013-03-05T09:46:00.200+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-03-05T09:46:00.200+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Radical" /><category scheme="http://www.blogger.com/atom/ns#" term="Model View ViewModel" /><title>Radical: focus management (preview)</title><content type="html">&lt;p&gt;In &lt;a href="http://radical.codeplex.com/" target="_blank"&gt;Radical&lt;/a&gt; we just introduced (package: &lt;a title="http://nuget.org/packages/Radical.Windows.Presentation" href="http://nuget.org/packages/Radical.Windows.Presentation"&gt;http://nuget.org/packages/Radical.Windows.Presentation&lt;/a&gt;) the focus management.&lt;/p&gt; &lt;p&gt;Here is the docs: &lt;a title="http://radical.codeplex.com/wikipage?title=Managing%20Focus%20from%20the%20ViewModel" href="http://radical.codeplex.com/wikipage?title=Managing%20Focus%20from%20the%20ViewModel"&gt;http://radical.codeplex.com/wikipage?title=Managing%20Focus%20from%20the%20ViewModel&lt;/a&gt;&lt;/p&gt; &lt;p&gt;.m&lt;/p&gt;  &lt;img src="http://feeds.feedburner.com/~r/tpx/~4/YwYjK4kNHaU" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://milestone.topics.it/feeds/5623853902519612478/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://milestone.topics.it/2013/03/radical-focus-management-preview.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6511237790974218081/posts/default/5623853902519612478?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6511237790974218081/posts/default/5623853902519612478?v=2" /><link rel="alternate" type="text/html" href="http://milestone.topics.it/2013/03/radical-focus-management-preview.html" title="Radical: focus management (preview)" /><author><name>Mauro Servienti</name><uri>https://plus.google.com/109709600646686474961</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh4.googleusercontent.com/-KXU7umaJ7sQ/AAAAAAAAAAI/AAAAAAAAAAA/hZhvEAaYHiQ/s512-c/photo.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;A0EFQH84eCp7ImA9WhNbFEQ.&quot;"><id>tag:blogger.com,1999:blog-6511237790974218081.post-7515621655634191474</id><published>2013-01-18T10:00:00.000+01:00</published><updated>2013-01-18T10:00:11.130+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-01-18T10:00:11.130+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Software Mason" /><category scheme="http://www.blogger.com/atom/ns#" term="Radical" /><title>Radical Presentation: validation support</title><content type="html">&lt;p&gt;The validation support &lt;a href="http://radical.codeplex.com/wikipage?title=Validation%20and%20Validation%20Services%3a%20ICanBeValidated"&gt;documentation&lt;/a&gt; is live on the &lt;a href="http://radical.codeplex.com/" target="_blank"&gt;Radical&lt;/a&gt;&amp;nbsp;&lt;a href="http://codeplex.com/" target="_blank"&gt;CodePlex&lt;/a&gt; web site.&lt;/p&gt; &lt;p&gt;.m&lt;/p&gt;  &lt;img src="http://feeds.feedburner.com/~r/tpx/~4/W3TUNL7wAyU" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://milestone.topics.it/feeds/7515621655634191474/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://milestone.topics.it/2013/01/radical-presentation-validation-support.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6511237790974218081/posts/default/7515621655634191474?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6511237790974218081/posts/default/7515621655634191474?v=2" /><link rel="alternate" type="text/html" href="http://milestone.topics.it/2013/01/radical-presentation-validation-support.html" title="Radical Presentation: validation support" /><author><name>Mauro Servienti</name><uri>https://plus.google.com/109709600646686474961</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh4.googleusercontent.com/-KXU7umaJ7sQ/AAAAAAAAAAI/AAAAAAAAAAA/hZhvEAaYHiQ/s512-c/photo.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;C0MMQH88fyp7ImA9WhNbEkk.&quot;"><id>tag:blogger.com,1999:blog-6511237790974218081.post-7425233339789674175</id><published>2013-01-15T10:18:00.000+01:00</published><updated>2013-01-15T10:18:01.177+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-01-15T10:18:01.177+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Software Mason" /><category scheme="http://www.blogger.com/atom/ns#" term="Radical" /><title>Radical: customer improvement program</title><content type="html">&lt;p&gt;There is a new nice and interesting feature, at least from my point of view, built-in in &lt;a href="http://radical.codeplex.com/" target="_blank"&gt;Radical&lt;/a&gt;: &lt;a href="http://radical.codeplex.com/wikipage?title=Customer%20Improvement%20Program"&gt;Official documentation&lt;/a&gt;&lt;/p&gt; &lt;h2&gt;Customer Improvement Program&lt;/h2&gt; &lt;p&gt;Have you ever thought how important is, from the perspective of an application producer, us, to know what our end users do with the application they use?&lt;/p&gt; &lt;ul&gt; &lt;li&gt;we plan a feature;  &lt;li&gt;we invest money in building a feature;  &lt;li&gt;we deploy a feature;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;…and we do not know nothing about how the user utilizes the feature we invested on, we do not even know if the user utilizes it.&lt;/p&gt; &lt;blockquote&gt; &lt;div id="codeSnippetWrapper"&gt;&lt;pre id="codeSnippet" style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;AnalyticsServices.UserActionTrackingHandler = evt =&amp;gt;&lt;br&gt;{&lt;br&gt;    &lt;span style="color: #008000"&gt;//every user action will be dispatched here asynchronously    &lt;/span&gt;&lt;br&gt;};&lt;br&gt;&lt;br&gt;AnalyticsServices.IsEnabled = &lt;span style="color: #0000ff"&gt;true&lt;/span&gt;;&lt;/pre&gt;&lt;br&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;p&gt;Writing the above code at the application startup enables the Radical AnalyticsServices what happens is that all the code that in some way invokes a DelegateCommand, in a WPF MVVM based application, will be tracked and we have the opportunity to “save” what the user is doing in order to analyze it later.&lt;/p&gt;
&lt;p&gt;What the UserActionTrackingHandler receives is an AnalyticsEvent with the following shape:&lt;/p&gt;
&lt;blockquote&gt;
&lt;div id="codeSnippetWrapper"&gt;&lt;pre id="codeSnippet" style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; AnalyticsEvent&lt;br&gt;{&lt;br&gt;    &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; AnalyticsEvent()&lt;br&gt;    {&lt;br&gt;        &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.ExecutedOn = DateTimeOffset.Now;&lt;br&gt;        &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.Identity = Thread.CurrentPrincipal.Identity;&lt;br&gt;    }&lt;br&gt;&lt;br&gt;    &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; DateTimeOffset ExecutedOn { get; set; }&lt;br&gt;&lt;br&gt;    &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; String Name { get; set; }&lt;br&gt;&lt;br&gt;    &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; Object Data { get; set; }&lt;br&gt;&lt;br&gt;    &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; IIdentity Identity { get; set; }&lt;br&gt;}&lt;/pre&gt;&lt;br&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;p&gt;If you need you can define your own events inheriting from the AnalyticsEvent class and in order to plugin your events you only need to declare a dependency on the IAnalyticsServices service:&lt;/p&gt;
&lt;blockquote&gt;
&lt;div id="codeSnippetWrapper"&gt;&lt;pre id="codeSnippet" style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;interface&lt;/span&gt; IAnalyticsServices&lt;br&gt;{&lt;br&gt;    Boolean IsEnabled { get; set; }&lt;br&gt;    &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; TrackUserActionAsync( Analytics.AnalyticsEvent action );&lt;br&gt;}&lt;/pre&gt;&lt;br&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;p&gt;And each time you call TrackUserActionAsync your UserActionTrackingHandler will be invoked.&lt;/p&gt;
&lt;p&gt;Be aware that this is still a preview subject to change.&lt;/p&gt;
&lt;p&gt;.m&lt;/p&gt;  &lt;img src="http://feeds.feedburner.com/~r/tpx/~4/8dtKvlVtsPs" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://milestone.topics.it/feeds/7425233339789674175/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://milestone.topics.it/2013/01/radical-customer-improvement-program.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6511237790974218081/posts/default/7425233339789674175?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6511237790974218081/posts/default/7425233339789674175?v=2" /><link rel="alternate" type="text/html" href="http://milestone.topics.it/2013/01/radical-customer-improvement-program.html" title="Radical: customer improvement program" /><author><name>Mauro Servienti</name><uri>https://plus.google.com/109709600646686474961</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh4.googleusercontent.com/-KXU7umaJ7sQ/AAAAAAAAAAI/AAAAAAAAAAA/hZhvEAaYHiQ/s512-c/photo.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;DUEAQX85eCp7ImA9WhNUGEw.&quot;"><id>tag:blogger.com,1999:blog-6511237790974218081.post-770341927045118201</id><published>2013-01-10T12:34:00.000+01:00</published><updated>2013-01-10T12:34:00.120+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-01-10T12:34:00.120+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Software Mason" /><category scheme="http://www.blogger.com/atom/ns#" term="Radical" /><title>Radical: Message broker support for POCO messages</title><content type="html">&lt;p&gt;Here we are finally the &lt;a href="http://radical.codeplex.com/" target="_blank"&gt;Radical&lt;/a&gt; message broker now supports POCO messages:&lt;/p&gt; &lt;p&gt;From the &lt;a href="http://radical.codeplex.com/documentation"&gt;Radical documentation&lt;/a&gt; on &lt;a href="http://codeplex.com/" target="_blank"&gt;CodePlex&lt;/a&gt;:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="http://radical.codeplex.com/wikipage?title=The%20message%20broker"&gt;Introduction to the message broker&lt;/a&gt;;&lt;/li&gt; &lt;li&gt;&lt;a href="http://radical.codeplex.com/wikipage?title=Message%20broker%3a%20POCO%20Messages"&gt;POCO Messages&lt;/a&gt;;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;.m&lt;/p&gt;  &lt;img src="http://feeds.feedburner.com/~r/tpx/~4/tpFujKuSW8Q" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://milestone.topics.it/feeds/770341927045118201/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://milestone.topics.it/2013/01/radical-message-broker-support-for-poco.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6511237790974218081/posts/default/770341927045118201?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6511237790974218081/posts/default/770341927045118201?v=2" /><link rel="alternate" type="text/html" href="http://milestone.topics.it/2013/01/radical-message-broker-support-for-poco.html" title="Radical: Message broker support for POCO messages" /><author><name>Mauro Servienti</name><uri>https://plus.google.com/109709600646686474961</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh4.googleusercontent.com/-KXU7umaJ7sQ/AAAAAAAAAAI/AAAAAAAAAAA/hZhvEAaYHiQ/s512-c/photo.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;DUAEQXw-fip7ImA9WhNUFk4.&quot;"><id>tag:blogger.com,1999:blog-6511237790974218081.post-775512228260365823</id><published>2013-01-08T10:35:00.000+01:00</published><updated>2013-01-08T10:35:00.256+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-01-08T10:35:00.256+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Software Mason" /><category scheme="http://www.blogger.com/atom/ns#" term="RavenDB" /><title>RavenDB install options</title><content type="html">&lt;p&gt;We have several options to install &lt;a href="http://ravendb.net" target="_blank"&gt;RavenDB&lt;/a&gt;, the following is a brief recap.&lt;/p&gt; &lt;h3&gt;As a IIS application&lt;/h3&gt; &lt;p&gt;this is the easiest way to setup RavenDB, just create a new web application and point to the “web” folder of the RavenDB install directory. The only important tweak is to tell to IIS the the application pool should be a “always running” application pool: &lt;a title="http://ravendb.net/docs/server/deployment/as-iis-application" href="http://ravendb.net/docs/server/deployment/as-iis-application"&gt;http://ravendb.net/docs/server/deployment/as-iis-application&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Advantages of this approach are clearly that the deployment is really easy, we can leverage the support of IIS and whenever RavenDB should crash IIS will take care of restart everything for US without any human intervention.&lt;/p&gt; &lt;h3&gt;As a Windows Service&lt;/h3&gt; &lt;p&gt;We can install RavenDB as windows service using its internal web server to expose the http endpoint on a preconfigured port, the advantages of this approach are basically that we have time to startup and especially to shutdown, the latter is the most important: when RavenDB gets shutdown needs to cleanly shutdowns all the indexes and that operation takes some time. If the cleanup/shutdown is not done correctly at startup RavenDB needs to check the healthy state of all the indexes and that takes a relative important amount of time, during which the database is not yet accessible.&lt;/p&gt; &lt;h3&gt;Embedded directly in our application&lt;/h3&gt; &lt;p&gt;Obviously this type of deployment is an option even if has nothing to do with the above options. We can build an application where everything is self contained in the application itself without the need of a separate RavenDB installation, this is the favorite solution for a typical single-user app.&lt;/p&gt; &lt;h3&gt;What do I suggest?&lt;/h3&gt; &lt;p&gt;Go with a Windows Service, especially if you have several huge indexes, because the health of RavenDB indexes if one of the core key point of the power of RavenDB.&lt;/p&gt; &lt;h3&gt;Important note&lt;/h3&gt; &lt;p&gt;Starting with RavenDB 2.0, that at the time of this writing is still under preview/unstable release, the whole startup/shutdown story has been addressed and drastically simplified, so if you have huge indexes with 2.0 is not such a big deal anymore.&lt;/p&gt; &lt;p&gt;.m&lt;/p&gt;  &lt;img src="http://feeds.feedburner.com/~r/tpx/~4/4RwdRdIEU3Q" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://milestone.topics.it/feeds/775512228260365823/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://milestone.topics.it/2013/01/ravendb-install-options.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6511237790974218081/posts/default/775512228260365823?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6511237790974218081/posts/default/775512228260365823?v=2" /><link rel="alternate" type="text/html" href="http://milestone.topics.it/2013/01/ravendb-install-options.html" title="RavenDB install options" /><author><name>Mauro Servienti</name><uri>https://plus.google.com/109709600646686474961</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh4.googleusercontent.com/-KXU7umaJ7sQ/AAAAAAAAAAI/AAAAAAAAAAA/hZhvEAaYHiQ/s512-c/photo.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;A0MERXkycCp7ImA9WhNVEEU.&quot;"><id>tag:blogger.com,1999:blog-6511237790974218081.post-7135505661594600516</id><published>2012-12-21T12:30:00.000+01:00</published><updated>2012-12-21T12:30:04.798+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-12-21T12:30:04.798+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Why not..." /><title>See you next year</title><content type="html">&lt;div id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:319c2122-912f-4c97-b7b7-476aaef36b89" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"&gt;&lt;div&gt;&lt;object width="448" height="252"&gt;&lt;param name="movie" value="http://www.youtube.com/v/7GOulDyAqHo?hl=en&amp;amp;hd=1"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/7GOulDyAqHo?hl=en&amp;amp;hd=1" type="application/x-shockwave-flash" width="448" height="252"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;.m&lt;/p&gt;  &lt;img src="http://feeds.feedburner.com/~r/tpx/~4/IHU6oxioBDI" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://milestone.topics.it/feeds/7135505661594600516/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://milestone.topics.it/2012/12/see-you-next-year.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6511237790974218081/posts/default/7135505661594600516?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6511237790974218081/posts/default/7135505661594600516?v=2" /><link rel="alternate" type="text/html" href="http://milestone.topics.it/2012/12/see-you-next-year.html" title="See you next year" /><author><name>Mauro Servienti</name><uri>https://plus.google.com/109709600646686474961</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh4.googleusercontent.com/-KXU7umaJ7sQ/AAAAAAAAAAI/AAAAAAAAAAA/hZhvEAaYHiQ/s512-c/photo.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;CUMMQX05fyp7ImA9WhNWGE8.&quot;"><id>tag:blogger.com,1999:blog-6511237790974218081.post-3377395789476211529</id><published>2012-12-18T10:38:00.000+01:00</published><updated>2012-12-18T10:38:00.327+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-12-18T10:38:00.327+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Software Mason" /><title>Never trust Environment.CurrentDirectory</title><content type="html">&lt;p&gt;If your code relies on “Environment.CurrentDirectory” to get the directory your application is “running in” you can get really surprising behaviors.&lt;/p&gt; &lt;p&gt;Environment.CurrentDirectory can be changed at any time by any piece of code, even by code not directly under your control, it is much better to build your own logic to get the “startup” directory, such as:&lt;/p&gt; &lt;blockquote&gt; &lt;div id="codeSnippetWrapper"&gt;&lt;pre id="codeSnippet" style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; FileSystem&lt;br&gt;{&lt;br&gt;    &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; String GetCurrentDirectory() &lt;br&gt;    {&lt;br&gt;        &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; Path.GetDirectoryName( Assembly.GetEntryAssembly().Location );&lt;br&gt;    }&lt;br&gt;}&lt;/pre&gt;&lt;br&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;p&gt;.m&lt;/p&gt;  &lt;img src="http://feeds.feedburner.com/~r/tpx/~4/JjAIFspJcDs" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://milestone.topics.it/feeds/3377395789476211529/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://milestone.topics.it/2012/12/never-trust-environmentcurrentdirectory.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6511237790974218081/posts/default/3377395789476211529?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6511237790974218081/posts/default/3377395789476211529?v=2" /><link rel="alternate" type="text/html" href="http://milestone.topics.it/2012/12/never-trust-environmentcurrentdirectory.html" title="Never trust Environment.CurrentDirectory" /><author><name>Mauro Servienti</name><uri>https://plus.google.com/109709600646686474961</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh4.googleusercontent.com/-KXU7umaJ7sQ/AAAAAAAAAAI/AAAAAAAAAAA/hZhvEAaYHiQ/s512-c/photo.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;CE8AQXs5eip7ImA9WhNWFEo.&quot;"><id>tag:blogger.com,1999:blog-6511237790974218081.post-8258566116934757111</id><published>2012-12-14T09:14:00.000+01:00</published><updated>2012-12-14T09:14:00.522+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-12-14T09:14:00.522+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Software Mason" /><category scheme="http://www.blogger.com/atom/ns#" term="Identity" /><title>WIF custom login pages and cookie path…</title><content type="html">&lt;p&gt;…do not try this at home…well do not try this anywhere :-)&lt;/p&gt; &lt;p&gt;Today I lost half of the day dealing with a nasty and horrible error, on a staging environment, trying to host &lt;a href="http://www.windowsazure.com/" target="_blank"&gt;Azure&lt;/a&gt; login pages locally instead that on the Azure ACS portal.&lt;/p&gt; &lt;p&gt;It was not working, even if it should be really, really trivial to setup. After dealing with the trace recorded by fiddler for a couple of hours I realized that the whole problem is related to the WIF configuration of the web application:&lt;/p&gt; &lt;blockquote&gt; &lt;div id="codeSnippetWrapper"&gt;&lt;pre id="codeSnippet" style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;system.identityModel&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;identityConfiguration&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;audienceUris&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;            &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;add&lt;/span&gt; &lt;span style="color: #ff0000"&gt;value&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="https://localhost/MyWebApp/"&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;br&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;audienceUris&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;issuerNameRegistry&lt;/span&gt; &lt;span style="color: #ff0000"&gt;type&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="System.IdentityModel.Tokens.ConfigurationBasedIssuerNameRegistry, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;            &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;trustedIssuers&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;                &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;add&lt;/span&gt; &lt;span style="color: #ff0000"&gt;thumbprint&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="---"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="---"&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;br&gt;            &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;trustedIssuers&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;issuerNameRegistry&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;certificateValidation&lt;/span&gt; &lt;span style="color: #ff0000"&gt;certificateValidationMode&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="None"&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;br&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;identityConfiguration&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;system.identityModel&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;system.identityModel.services&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;federationConfiguration&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;        &lt;font style="background-color: #ffff00"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;cookieHandler&lt;/span&gt; &lt;span style="color: #ff0000"&gt;requireSsl&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="false"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;path&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="/MyWebApp"&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;br&gt;&lt;/font&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;wsFederation&lt;/span&gt; &lt;span style="color: #ff0000"&gt;passiveRedirectEnabled&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="true"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;issuer&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="http://----/wsFederationSTS/Issue"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;realm&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="https://localhost/MyWebApp/"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;requireHttps&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="false"&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;br&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;federationConfiguration&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;system.identityModel.services&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;p&gt;Removing the “path” attribute from the “cookieHandler” element solved the problem immediately.&lt;/p&gt;
&lt;p&gt;Developer advised… :-)&lt;/p&gt;
&lt;p&gt;.m&lt;/p&gt;  &lt;img src="http://feeds.feedburner.com/~r/tpx/~4/hdQggTJJ8tE" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://milestone.topics.it/feeds/8258566116934757111/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://milestone.topics.it/2012/12/wif-custom-login-pages-and-cookie-path.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6511237790974218081/posts/default/8258566116934757111?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6511237790974218081/posts/default/8258566116934757111?v=2" /><link rel="alternate" type="text/html" href="http://milestone.topics.it/2012/12/wif-custom-login-pages-and-cookie-path.html" title="WIF custom login pages and cookie path…" /><author><name>Mauro Servienti</name><uri>https://plus.google.com/109709600646686474961</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh4.googleusercontent.com/-KXU7umaJ7sQ/AAAAAAAAAAI/AAAAAAAAAAA/hZhvEAaYHiQ/s512-c/photo.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;CUQAQX44fCp7ImA9WhNWEkw.&quot;"><id>tag:blogger.com,1999:blog-6511237790974218081.post-157364087635693329</id><published>2012-12-11T09:09:00.000+01:00</published><updated>2012-12-11T09:09:00.034+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-12-11T09:09:00.034+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Software Mason" /><title>UserPrincipal.GetAuthorizationGroups()…oh my!</title><content type="html">&lt;h2&gt;The problem&lt;/h2&gt; &lt;p&gt;There is a really &lt;a href="http://msdn.microsoft.com/EN-US/library/bb340590(v=VS.110,d=hv.2).aspx" target="_blank"&gt;convenient method&lt;/a&gt; that can be used to retrieve a flat list of &lt;strong&gt;all&lt;/strong&gt; the groups (event nested) given a known UserPrincipal, e.g. the current user, the really amazing thing is that the method saves you from doing a group recursion to retrieve the groups relationships in order to detect that a user belongs to a group A that belongs to a group B.&lt;/p&gt; &lt;p&gt;The above method utilizes, as far as I know, the security tokens attached to a given user principal and then resolves the group names given the group SID.&lt;/p&gt; &lt;p&gt;The problem is that that method can fail with a really strange exception “&lt;a href="http://msdn.microsoft.com/EN-US/library/bb336570(v=VS.110,d=hv.2).aspx" target="_blank"&gt;NoMatchingPrincipalException&lt;/a&gt;” (the group cannot be found) that is typically related to 2 different scenarios:&lt;/p&gt; &lt;ol&gt; &lt;li&gt;One, or more, of the group has &lt;a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms679833(v=vs.85).aspx" target="_blank"&gt;SID History&lt;/a&gt; enabled;&lt;/li&gt; &lt;li&gt;In a complex domain topology one of the DC is not available at the moment of the query;&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;To make a long story short: we simply cannot rely on that method, period.&lt;/p&gt; &lt;h2&gt;The solution&lt;/h2&gt; &lt;blockquote&gt; &lt;div id="codeSnippetWrapper"&gt;&lt;pre id="codeSnippet" style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;IEnumerable&amp;lt;String&amp;gt; GetGroups( String samAccountName )&lt;br&gt;{&lt;br&gt;    var userNestedMembership = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; List&amp;lt;&lt;span style="color: #0000ff"&gt;string&lt;/span&gt;&amp;gt;();&lt;br&gt;&lt;br&gt;    var domainConnection = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; DirectoryEntry();&lt;br&gt;    domainConnection.AuthenticationType = System.DirectoryServices.AuthenticationTypes.Secure;&lt;br&gt;&lt;br&gt;    var samSearcher = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; DirectorySearcher();&lt;br&gt;&lt;br&gt;    samSearcher.SearchRoot = domainConnection;&lt;br&gt;    samSearcher.Filter = &lt;span style="color: #006080"&gt;"(samAccountName="&lt;/span&gt; + samAccountName + &lt;span style="color: #006080"&gt;")"&lt;/span&gt;;&lt;br&gt;    samSearcher.PropertiesToLoad.Add( &lt;span style="color: #006080"&gt;"displayName"&lt;/span&gt; );&lt;br&gt;&lt;br&gt;    var samResult = samSearcher.FindOne();&lt;br&gt;&lt;br&gt;    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; ( samResult != &lt;span style="color: #0000ff"&gt;null&lt;/span&gt; )&lt;br&gt;    {&lt;br&gt;        var theUser = samResult.GetDirectoryEntry();&lt;br&gt;        theUser.RefreshCache( &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; &lt;span style="color: #0000ff"&gt;string&lt;/span&gt;[] { &lt;span style="color: #006080"&gt;"tokenGroups"&lt;/span&gt; } );&lt;br&gt;&lt;br&gt;        &lt;span style="color: #0000ff"&gt;foreach&lt;/span&gt; ( &lt;span style="color: #0000ff"&gt;byte&lt;/span&gt;[] resultBytes &lt;span style="color: #0000ff"&gt;in&lt;/span&gt; theUser.Properties[ &lt;span style="color: #006080"&gt;"tokenGroups"&lt;/span&gt; ] )&lt;br&gt;        {&lt;br&gt;            var SID = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; SecurityIdentifier( resultBytes, 0 );&lt;br&gt;            var sidSearcher = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; DirectorySearcher();&lt;br&gt;&lt;br&gt;            sidSearcher.SearchRoot = domainConnection;&lt;br&gt;            sidSearcher.Filter = &lt;span style="color: #006080"&gt;"(objectSid="&lt;/span&gt; + SID.Value + &lt;span style="color: #006080"&gt;")"&lt;/span&gt;;&lt;br&gt;            sidSearcher.PropertiesToLoad.Add( &lt;span style="color: #006080"&gt;"name"&lt;/span&gt; );&lt;br&gt;&lt;br&gt;            var sidResult = sidSearcher.FindOne();&lt;br&gt;            &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; ( sidResult != &lt;span style="color: #0000ff"&gt;null&lt;/span&gt; )&lt;br&gt;            {&lt;br&gt;                userNestedMembership.Add( ( &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; )sidResult.Properties[ &lt;span style="color: #006080"&gt;"name"&lt;/span&gt; ][ 0 ] );&lt;br&gt;            }&lt;br&gt;        }&lt;br&gt;    }&lt;br&gt;&lt;br&gt;    &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; userNestedMembership;&lt;br&gt;}&lt;/pre&gt;&lt;br&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;p&gt;A bunch of old good directory services related code :-) where the really really really, have I said really?, important piece is the following:&lt;/p&gt;
&lt;blockquote&gt;
&lt;div id="codeSnippetWrapper"&gt;&lt;pre id="codeSnippet" style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;theUser.RefreshCache( &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; &lt;span style="color: #0000ff"&gt;string&lt;/span&gt;[] { &lt;span style="color: #006080"&gt;"tokenGroups"&lt;/span&gt; } );&lt;/pre&gt;&lt;br&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;p&gt;That asks to the underlying system to refresh the cache of the groups security tokens attached to the given user.&lt;/p&gt;
&lt;p&gt;.m&lt;/p&gt;  &lt;img src="http://feeds.feedburner.com/~r/tpx/~4/kRSo2iG2riY" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://milestone.topics.it/feeds/157364087635693329/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://milestone.topics.it/2012/12/userprincipalgetauthorizationgroupsoh-my.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6511237790974218081/posts/default/157364087635693329?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6511237790974218081/posts/default/157364087635693329?v=2" /><link rel="alternate" type="text/html" href="http://milestone.topics.it/2012/12/userprincipalgetauthorizationgroupsoh-my.html" title="UserPrincipal.GetAuthorizationGroups()…oh my!" /><author><name>Mauro Servienti</name><uri>https://plus.google.com/109709600646686474961</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh4.googleusercontent.com/-KXU7umaJ7sQ/AAAAAAAAAAI/AAAAAAAAAAA/hZhvEAaYHiQ/s512-c/photo.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;DkcEQX8yfSp7ImA9WhNXF0Q.&quot;"><id>tag:blogger.com,1999:blog-6511237790974218081.post-5075937610529674489</id><published>2012-12-06T12:40:00.000+01:00</published><updated>2012-12-06T12:40:00.195+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-12-06T12:40:00.195+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Software Mason" /><category scheme="http://www.blogger.com/atom/ns#" term="Radical" /><category scheme="http://www.blogger.com/atom/ns#" term="Xaml" /><title>Radical “Handle” behavior</title><content type="html">&lt;p&gt;Imagine that you need to handle from the ViewModel the SelectedIndexChanged of a WPF TreeView, currently the only way (without using any particular framework) is to build your own Behavior to achieve that, or bind, via a style the IsSelected property of the node to a property of the view model, but in this second case the side effect is that to find the selected item you need to visit the whole tree.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Enter &lt;/strong&gt;&lt;a href="http://radical.codeplex.com/" target="_blank"&gt;&lt;strong&gt;Radical&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt; “Handle”&lt;/strong&gt;&lt;/p&gt; &lt;blockquote&gt; &lt;div id="codeSnippetWrapper"&gt;&lt;pre id="codeSnippet" style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;TreeView&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Margin&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="5"&lt;/span&gt;&lt;br&gt;          &lt;span style="color: #ff0000"&gt;HorizontalAlignment&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="Stretch"&lt;/span&gt; &lt;br&gt;          &lt;span style="color: #ff0000"&gt;VerticalAlignment&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="Stretch"&lt;/span&gt; &lt;br&gt;          &lt;span style="color: #ff0000"&gt;ItemsSource&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="{Binding Path=Accounts}"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;i:Interaction.Behaviors&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;behaviors:Handle&lt;/span&gt; &lt;span style="color: #ff0000"&gt;RoutedEvent&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="TreeView.SelectedItemChanged"&lt;/span&gt; &lt;br&gt;                    &lt;span style="color: #ff0000"&gt;WithCommand&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="{Binding Path=SelectOutlookPath}"&lt;/span&gt;&lt;br&gt;                    &lt;span style="color: #ff0000"&gt;PassingIn&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="$args.NewValue"&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;br&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;i:Interaction.Behaviors&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;TreeView.ItemTemplate&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;        &lt;span style="color: #008000"&gt;&amp;lt;!-- omitted --&amp;gt;&lt;/span&gt;&lt;br&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;TreeView.ItemTemplate&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;TreeView&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;p&gt;As you can imagine the value of the NewValue property of the event arguments is passed as the command parameter to the command, we currently support to placeholder:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;$args: the routed event arguments; 
&lt;li&gt;$this: the WPF element the behavior is attached to; 
&lt;li&gt;$source: the source of the routed event; 
&lt;li&gt;$originalSource: the original source of the routed event;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Obviously the event we need to handle must be a RoutedEvent.&lt;/p&gt;
&lt;p&gt;Available in the &lt;a href="http://nuget.org" target="_blank"&gt;Nuget&lt;/a&gt; package “&lt;a href="http://nuget.org/packages/Radical.Windows" target="_blank"&gt;Radical.Windows&lt;/a&gt;”&lt;/p&gt;
&lt;p&gt;.m&lt;/p&gt;  &lt;img src="http://feeds.feedburner.com/~r/tpx/~4/F7DYSKeL32c" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://milestone.topics.it/feeds/5075937610529674489/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://milestone.topics.it/2012/12/radical-handle-behavior.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6511237790974218081/posts/default/5075937610529674489?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6511237790974218081/posts/default/5075937610529674489?v=2" /><link rel="alternate" type="text/html" href="http://milestone.topics.it/2012/12/radical-handle-behavior.html" title="Radical “Handle” behavior" /><author><name>Mauro Servienti</name><uri>https://plus.google.com/109709600646686474961</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh4.googleusercontent.com/-KXU7umaJ7sQ/AAAAAAAAAAI/AAAAAAAAAAA/hZhvEAaYHiQ/s512-c/photo.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;D0IGQX0zcSp7ImA9WhNXFk8.&quot;"><id>tag:blogger.com,1999:blog-6511237790974218081.post-3578712862524279258</id><published>2012-12-04T13:52:00.000+01:00</published><updated>2012-12-04T13:52:00.389+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-12-04T13:52:00.389+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Software Mason" /><category scheme="http://www.blogger.com/atom/ns#" term="RavenDB" /><title>RavenDB: index management options</title><content type="html">&lt;p&gt;We have &lt;a href="http://milestone.topics.it/2012/11/ravendb-map-index.html" target="_blank"&gt;recently introduced the basic concepts&lt;/a&gt; about indexing in &lt;a href="http://ravendb.net" target="_blank"&gt;RavenDB&lt;/a&gt;. We left without saying nothing about the options we, as developers, have to manage indexes:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;Manually via the RavenDB Studio;  &lt;li&gt;Programmatically directly within the application;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;strong&gt;Index overview&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;If we take a look at the Indexes tab in the Studio and we edit one of the indexes we can see something that we, as .net developers, are really familiar with: linq.&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh6.ggpht.com/-a75kDxa6oGw/UKCfI4FyOcI/AAAAAAAACYI/_oTTTy2eJQo/s1600-h/image3.png"&gt;&lt;img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://lh6.ggpht.com/-v2ZDdqL1DAk/UKCfLDDZVWI/AAAAAAAACYQ/q3aTbGmB4CU/image_thumb1.png?imgmax=800" width="335" height="123"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;An index is defined using a linq expression, wow, but as we may suspect the server has no knowledge at all of what a linq expression is, what we see in the index editor is basically text, familiar to us, but text that the server can understand and use to “run” the index.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Manual index management&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;So…as we can imagine we can use the Studio to create and manage indexes, creating a new index is just a matter of defining the correct lambda expression that defines what we want to index, basically nothing more.&lt;/p&gt; &lt;p&gt;As we can imagine as the index complexity grows the manual management can become cumbersome.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Programmatic index management&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;The following map/reduce index is a good starting point:&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh3.ggpht.com/-FvCjqnGakUQ/UKCfM9cHEVI/AAAAAAAACYY/6G4WWr28Ak8/s1600-h/image%25255B4%25255D.png"&gt;&lt;img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="http://lh3.ggpht.com/-eVFlYbKcl-U/UKCfOab1-JI/AAAAAAAACYg/X-vHsPCnv-w/image_thumb%25255B1%25255D.png?imgmax=800" width="341" height="201"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;it is still a fairly simple index (a sort of tag cloud) but is a good sample of the manual management complexity we can achieve quickly. The above index can be fully managed by code:&lt;/p&gt; &lt;blockquote&gt; &lt;div id="codeSnippetWrapper"&gt;&lt;pre id="codeSnippet" style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; Genres_Count : AbstractIndexCreationTask&amp;lt;Album, Genres_Count.GenresCloud&amp;gt;&lt;br&gt;{&lt;br&gt;    &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; GenresCloud&lt;br&gt;    {&lt;br&gt;        &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; Id { get; set; }&lt;br&gt;        &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; Name { get; set; }&lt;br&gt;        &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; Count { get; set; }&lt;br&gt;    }&lt;br&gt;&lt;br&gt;    &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; Genres_Count()&lt;br&gt;    {&lt;br&gt;        &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.Map = albums =&amp;gt; from album &lt;span style="color: #0000ff"&gt;in&lt;/span&gt; albums&lt;br&gt;                        select &lt;span style="color: #0000ff"&gt;new&lt;/span&gt;&lt;br&gt;                        {&lt;br&gt;                            Id = album.Genre.Id,&lt;br&gt;                            Name = album.Genre.Name,&lt;br&gt;                            Count = 1&lt;br&gt;                        };&lt;br&gt;&lt;br&gt;        &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.Reduce = results =&amp;gt; from genreCount &lt;span style="color: #0000ff"&gt;in&lt;/span&gt; results&lt;br&gt;                            group genreCount by genreCount.Id into g&lt;br&gt;                            select &lt;span style="color: #0000ff"&gt;new&lt;/span&gt;&lt;br&gt;                            {&lt;br&gt;                                Id = g.Key,&lt;br&gt;                                Name = g.First().Name,&lt;br&gt;                                Count = g.Sum( x =&amp;gt; x.Count )&lt;br&gt;                            };&lt;br&gt;&lt;br&gt;        &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.IndexSortOptions.Add( i =&amp;gt; i.Count, Raven.Abstractions.Indexing.SortOptions.Int );&lt;br&gt;    }&lt;br&gt;}&lt;/pre&gt;&lt;br&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;p&gt;The above C# code is exactly equal to the index we have seen in the studio, in fact the index in the studio has been generated at application startup time using the following one line of code:&lt;/p&gt;
&lt;blockquote&gt;
&lt;div id="codeSnippetWrapper"&gt;&lt;pre id="codeSnippet" style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span style="color: #008000"&gt;//ds is an instance of IDocumentStore&lt;/span&gt;&lt;br&gt;IndexCreation.CreateIndexes( Assembly.GetExecutingAssembly(), ds );&lt;/pre&gt;&lt;br&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;p&gt;We have defined in a single class, inheriting from the RavenDB AbstractIndexCreationTask&amp;lt;TDocument, TReduceResult&amp;gt;:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;the name of the index, the convention is that My_Sample_Index is translated by the server into a index named My/Sample/Index;&lt;/li&gt;
&lt;li&gt;The map logic;&lt;/li&gt;
&lt;li&gt;The reduce logic;&lt;/li&gt;
&lt;li&gt;Some index options;&lt;/li&gt;
&lt;li&gt;And the shape of the reduce result;&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;Having a strongly typed index definition allows us to write some strongly typed C# code to use it:&lt;/p&gt;
&lt;blockquote&gt;
&lt;div id="codeSnippetWrapper"&gt;&lt;pre id="codeSnippet" style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;var cloud = await Task.Factory.StartNew&amp;lt;IEnumerable&amp;lt;Genres_Count.GenresCloud&amp;gt;&amp;gt;( () =&amp;gt;&lt;br&gt;{&lt;br&gt;    &lt;span style="color: #0000ff"&gt;using&lt;/span&gt;( var session = &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.documentStore.OpenSession() )&lt;br&gt;    {&lt;br&gt;        var data = session.Query&amp;lt;Genres_Count.GenresCloud, Genres_Count&amp;gt;()&lt;br&gt;            .OrderByDescending( c =&amp;gt; c.Count );&lt;br&gt;&lt;br&gt;        &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; data;&lt;br&gt;    }&lt;br&gt;} );&lt;/pre&gt;&lt;br&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;p&gt;.m&lt;/p&gt;  &lt;img src="http://feeds.feedburner.com/~r/tpx/~4/Z1pQ_KkN2Uw" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://milestone.topics.it/feeds/3578712862524279258/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://milestone.topics.it/2012/12/ravendb-index-management-options.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6511237790974218081/posts/default/3578712862524279258?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6511237790974218081/posts/default/3578712862524279258?v=2" /><link rel="alternate" type="text/html" href="http://milestone.topics.it/2012/12/ravendb-index-management-options.html" title="RavenDB: index management options" /><author><name>Mauro Servienti</name><uri>https://plus.google.com/109709600646686474961</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh4.googleusercontent.com/-KXU7umaJ7sQ/AAAAAAAAAAI/AAAAAAAAAAA/hZhvEAaYHiQ/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh6.ggpht.com/-v2ZDdqL1DAk/UKCfLDDZVWI/AAAAAAAACYQ/q3aTbGmB4CU/s72-c/image_thumb1.png?imgmax=800" height="72" width="72" /><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;AkcAQXc5fCp7ImA9WhNXEks.&quot;"><id>tag:blogger.com,1999:blog-6511237790974218081.post-1088636340889145993</id><published>2012-11-30T10:34:00.000+01:00</published><updated>2012-11-30T10:34:00.924+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-11-30T10:34:00.924+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="WinRT" /><category scheme="http://www.blogger.com/atom/ns#" term="RavenDB" /><category scheme="http://www.blogger.com/atom/ns#" term="Windows 8" /><title>Windows 8 app: application bootstrap</title><content type="html">&lt;p&gt;First of all it is important to understand the &lt;strike&gt;Metro&lt;/strike&gt; Windows Store app lifecycle and &lt;a href="http://csharperimage.jeremylikness.com/" target="_blank"&gt;Jeremy Likeness&lt;/a&gt; has &lt;a href="http://csharperimage.jeremylikness.com/2012/06/process-lifetime-management-plm-and.html" target="_blank"&gt;perfectly covered the topic&lt;/a&gt;, go and read it.&lt;/p&gt; &lt;p&gt;As you can see there are a lot of details that should be taken into account:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;is it a resume or a cold start?&lt;/li&gt; &lt;li&gt;the application state should be restored?&lt;/li&gt; &lt;ul&gt; &lt;li&gt;at which point?&lt;/li&gt;&lt;/ul&gt; &lt;li&gt;is it a “charm” request?&lt;/li&gt; &lt;li&gt;is it a custom tile request?&lt;/li&gt; &lt;li&gt;is it a toast notification request?&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;So the question should be: is my role, as app developer, to handle all those possibilities? or my role should be to handle the application business logic?&lt;/p&gt; &lt;p&gt;Using &lt;a href="http://radical.codeplex.com/" target="_blank"&gt;Radical&lt;/a&gt; you can forget the most part of the question above and concentrate on the cool part of your application:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;The boot process: &lt;a title="http://radical.codeplex.com/wikipage?title=The%20boot%20process%20demystified" href="http://radical.codeplex.com/wikipage?title=The%20boot%20process%20demystified"&gt;http://radical.codeplex.com/wikipage?title=The%20boot%20process%20demystified&lt;/a&gt;&lt;/li&gt; &lt;li&gt;WinRT peculiarities: &lt;a title="http://radical.codeplex.com/wikipage?title=WinRT%20boot%20process%20peculiarities" href="http://radical.codeplex.com/wikipage?title=WinRT%20boot%20process%20peculiarities"&gt;http://radical.codeplex.com/wikipage?title=WinRT%20boot%20process%20peculiarities&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;Any feedback is really appreciated.&lt;/p&gt; &lt;p&gt;.m&lt;/p&gt;  &lt;img src="http://feeds.feedburner.com/~r/tpx/~4/st3gAYcm_j8" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://milestone.topics.it/feeds/1088636340889145993/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://milestone.topics.it/2012/11/windows-8-app-application-bootstrap.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6511237790974218081/posts/default/1088636340889145993?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6511237790974218081/posts/default/1088636340889145993?v=2" /><link rel="alternate" type="text/html" href="http://milestone.topics.it/2012/11/windows-8-app-application-bootstrap.html" title="Windows 8 app: application bootstrap" /><author><name>Mauro Servienti</name><uri>https://plus.google.com/109709600646686474961</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh4.googleusercontent.com/-KXU7umaJ7sQ/AAAAAAAAAAI/AAAAAAAAAAA/hZhvEAaYHiQ/s512-c/photo.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;DkEEQX4yeip7ImA9WhNXEU0.&quot;"><id>tag:blogger.com,1999:blog-6511237790974218081.post-3081342710105134537</id><published>2012-11-28T13:10:00.000+01:00</published><updated>2012-11-28T13:10:00.092+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-11-28T13:10:00.092+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="RavenDB" /><category scheme="http://www.blogger.com/atom/ns#" term="Azure" /><title>Running RavenDB on Windows Azure with Replica</title><content type="html">&lt;p&gt;We &lt;a href="http://milestone.topics.it/2012/11/running-ravendb-on-windows-azure-using.html"&gt;have seen how easy&lt;/a&gt; is to setup &lt;a href="http://ravendb.net" target="_blank"&gt;RavenDB&lt;/a&gt; on &lt;a href="http://www.windowsazure.com/" target="_blank"&gt;Azure&lt;/a&gt; using a Virtual Machine, nothing so different from what we would do on a regular on premise VM/bare metal.&lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;&lt;em&gt;The funniest thing is that the RavenDB configuration for replica is just a matter of seconds, the time consuming part is the Azure configuration.&lt;/em&gt;&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;&lt;strong&gt;Service Level Agreement&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;One of the key point of providing a service in the cloud is to give to our customer a SLA, a guarantee that the service we provide with our application will be available whenever the customer needs it.&lt;/p&gt; &lt;p&gt;Using Azure Web/Worker Role(s) it is a trivial stuff, just deploy more instance of the same role, but with VM is up to us to manage the whole topology of the network and to setup VM balancing, if required, and redundancy.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Why running in a VM?&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;We &lt;a href="http://milestone.topics.it/2012/11/running-ravendb-as-windows-azure-worker.html"&gt;have seen that we can easily setup RavenDB using a Worker Role&lt;/a&gt; but &lt;/p&gt; &lt;p&gt;&lt;strong&gt;RavenDB Replica support&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;Using RavenDB we can leverage the power and simplicity of the Replication Bundle so set up a replica-set, let’s say that we want to setup the simplest possible scenario: master-slave.&lt;/p&gt; &lt;p&gt;First of all we need another virtual machine, can we “copy” the already existing one: yes, but wait a minute.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Azure networking&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;The first problem we have is to understand how we can allow communication between virtual machines laying in an Azure datacenter. There a re a couple of possible approach:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;strong&gt;Availability Set&lt;/strong&gt;: Azure has the concept of availability set, a sort of logical grouping, and the documentation states that virtual machines (and so also web and worker roles) living in the same availability set, or defined in the same cloud service, are able to communicate without any configuration (other than the machine on board firewall that obviously should be configured to accomplish your needs)…I have tried everything without any success… :-/&lt;/li&gt; &lt;li&gt;&lt;strong&gt;Virtual Network&lt;/strong&gt;: Azure has recently introduced the concept of virtual networks, it is basically a network definition that guarantees isolation and communication to the machines defined in the virtual network, the amazing thing, even if out of our current scope, is that we can use virtual networks to create a network between the cloud network and our on premise network. &lt;/li&gt;&lt;/ul&gt; &lt;p&gt;The main difference, as per the documentation, between the two is that in the first one we get name resolution for free and in the second one we should provide our own DNS service to have name resolution, but in order to setup the replica we can use machine IP addresses and the Virtual Network gives us something called persistent IP, a sort of a DHCP infinite lease; so we do not need any DNS to setup the replica.&lt;/p&gt; &lt;p&gt;At the time of this writing the biggest problem of the Virtual Networks is that there is no support to add an existing VM to a virtual network, we need to add the VM to the network at creation time.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Create the Virtual Network&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;Since we need to define the Virtual Network before creating the VMs the first step is to create di network, via the Azure management portal go to the network tab:&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh5.ggpht.com/-ouriRcjvQ3Y/UKCU1GBg5KI/AAAAAAAACV0/Z-FCQsCrrrg/s1600-h/image%25255B153%25255D.png"&gt;&lt;img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="http://lh4.ggpht.com/-eImENtihsnA/UKCU2QCqlwI/AAAAAAAACV8/5ZqMdIhHuP4/image_thumb%25255B137%25255D.png?imgmax=800" width="264" height="184"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;And create a new network, I skip the 2 creation steps since they are just a network definition made of a name, an address space and a optional subnet.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Shutdown the VM and Capture it&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;Now…we have a running VM that cannot be added to the virtual network and we need another VM with exactly the same configuration, the easiest approach is:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;“Sysprep” the OS, running sysprep.exe from Windows\System32\Sysprep, choosing the following options:&lt;br&gt;&lt;a href="http://lh3.ggpht.com/-sQ_aygXih2I/UKCU3kXw-AI/AAAAAAAACWA/rirn_4HhOoI/s1600-h/image%25255B5%25255D.png"&gt;&lt;img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="http://lh4.ggpht.com/-4EOpZK2TUsY/UKCU4lM9p5I/AAAAAAAACWM/s8CLW8tx2yk/image_thumb%25255B1%25255D.png?imgmax=800" width="244" height="189"&gt;&lt;/a&gt;&lt;/li&gt; &lt;li&gt;Wait for the sysprep process to complete, wait, wait, wait…I waited for 15 minutes…it’s along way to the top…;&lt;/li&gt; &lt;li&gt;Use the capture function of the Azure portal to create a image of the VM, once the capture is completed:&lt;/li&gt; &lt;ul&gt; &lt;li&gt;The original VM is deleted;&lt;/li&gt; &lt;li&gt;You have a new image in the gallery ready to use to create ne VMs;&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt; &lt;p&gt;&lt;strong&gt;Create 2 VMs based on the captured image&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;Create 2 new VMs using the previously created image and be sure to add the VM the existing virtual network:&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh4.ggpht.com/-CoLBL-fOfAQ/UKCU6mwR-6I/AAAAAAAACWU/Wd26fKFO9zc/s1600-h/image%25255B152%25255D.png"&gt;&lt;img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="http://lh4.ggpht.com/-QaIJlVisbAg/UKCU8CITaUI/AAAAAAAACWc/FfwecuBIRAo/image_thumb%25255B136%25255D.png?imgmax=800" width="264" height="197"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Once the VM is up &amp;amp; running and the installed RavenDB is accessible from the internet (be sure as in the single machine installation to add the both the VMs an http endpoint as usual) go to the Azure portal and take a look at the network configuration of the machines:&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh4.ggpht.com/-qGLdiMhNsjo/UKCU-SOSqWI/AAAAAAAACWk/iw0ooW_2Si0/s1600-h/image%25255B132%25255D.png"&gt;&lt;img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="http://lh3.ggpht.com/-ZejLsnyxvF0/UKCU_yd7SUI/AAAAAAAACWo/qrqhxlG5UHw/image_thumb%25255B116%25255D.png?imgmax=800" width="354" height="126"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Both machines have an internal IP address that belongs to the subnet mask defined in the virtual network.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Setup RavenDB replica&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;Install the Replication Bundle on both machines adding the Raven.Bundles.Replication assembly to the Plugins directory, now go to the RavenDB Studio of the machine that will be the master server, select the database you want to replicate the the slave server and create the replica setup document:&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh3.ggpht.com/-0V8G59eSBrY/UKCVBoi0D8I/AAAAAAAACW0/cRQGgWYbSiI/s1600-h/image%25255B119%25255D.png"&gt;&lt;img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="http://lh5.ggpht.com/-P3VdDKrU0Uw/UKCVDPCk0KI/AAAAAAAACW8/8hFuVBs09s4/image_thumb%25255B103%25255D.png?imgmax=800" width="354" height="186"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;We also add credentials info the the document since we are using Windows Authentication, there is also a option to specify a connection string in the web config and thus encrypt the config section for security purpose.&lt;/p&gt; &lt;p&gt;As soon as you save the document if you move to the Logs tab of the Studio you can see that RavenDB has immediately noticed that something interesting has happened:&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh3.ggpht.com/-yj29N5aPvWE/UKCVE9vT1YI/AAAAAAAACXE/iYJXBIlRxEo/s1600-h/image%25255B59%25255D.png"&gt;&lt;img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="http://lh5.ggpht.com/-qa6L6NnqqpA/UKCVG2nVeXI/AAAAAAAACXM/Zka9mF7Fe0Q/image_thumb%25255B43%25255D.png?imgmax=800" width="354" height="86"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;The final step is to test everything, pop up a new browser pointing to the slave server, go back to the master and create a new document:&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh5.ggpht.com/-DZVltKvumWE/UKCVJNJACdI/AAAAAAAACXU/B33o7G1M5Qs/s1600-h/image%25255B31%25255D.png"&gt;&lt;img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="http://lh4.ggpht.com/-j3nq6ReN0jU/UKCVLMcPO0I/AAAAAAAACXc/2W4EFkIwEWY/image_thumb%25255B15%25255D.png?imgmax=800" width="354" height="221"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;A couple of seconds after we created the new document (with id “Users/3”) on the primary server the same document pops up on the slave one, and the log on the master server confirms that everything is running as expected:&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh5.ggpht.com/-i1rorQNedec/UKCVMlD-SzI/AAAAAAAACXk/LFV5Sf3SNBU/s1600-h/image%25255B29%25255D.png"&gt;&lt;img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="http://lh3.ggpht.com/-wI4oixQ2Lfs/UKCVN-FLDmI/AAAAAAAACXs/D6uVZoMEmCI/image_thumb%25255B13%25255D.png?imgmax=800" width="354" height="84"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Amazing, all this stuff is simply amazing :-P&lt;/p&gt; &lt;p&gt;.m&lt;/p&gt;  &lt;img src="http://feeds.feedburner.com/~r/tpx/~4/KiEWSBo04wo" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://milestone.topics.it/feeds/3081342710105134537/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://milestone.topics.it/2012/11/running-ravendb-on-windows-azure-with.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6511237790974218081/posts/default/3081342710105134537?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6511237790974218081/posts/default/3081342710105134537?v=2" /><link rel="alternate" type="text/html" href="http://milestone.topics.it/2012/11/running-ravendb-on-windows-azure-with.html" title="Running RavenDB on Windows Azure with Replica" /><author><name>Mauro Servienti</name><uri>https://plus.google.com/109709600646686474961</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh4.googleusercontent.com/-KXU7umaJ7sQ/AAAAAAAAAAI/AAAAAAAAAAA/hZhvEAaYHiQ/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh4.ggpht.com/-eImENtihsnA/UKCU2QCqlwI/AAAAAAAACV8/5ZqMdIhHuP4/s72-c/image_thumb%25255B137%25255D.png?imgmax=800" height="72" width="72" /><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;A0ICQXs7eCp7ImA9WhNQGUw.&quot;"><id>tag:blogger.com,1999:blog-6511237790974218081.post-9037702190478636721</id><published>2012-11-26T09:46:00.000+01:00</published><updated>2012-11-26T09:46:00.500+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-11-26T09:46:00.500+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Software Mason" /><category scheme="http://www.blogger.com/atom/ns#" term="RavenDB" /><title>RavenDB: map index</title><content type="html">it’s long time that I left this topic alone, &lt;a href="http://milestone.topics.it/2012/05/ravendb-i-want-my-data.html" target="_blank"&gt;last time I promised&lt;/a&gt; we will discuss about the way document database let you get your data back to life, here we are.&lt;br /&gt;
&lt;strong&gt;Indexing&lt;/strong&gt;&lt;br /&gt;
As we already said, I hope :-), the only way to search/query data in a document database is to use an index, let see what happens using a really trivial example:&lt;br /&gt;
&lt;blockquote&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;pre id="codeSnippet" style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"&gt;&lt;span style="color: blue;"&gt;static&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; Main( &lt;span style="color: blue;"&gt;string&lt;/span&gt;[] args )
{
    var uri = &lt;span style="color: blue;"&gt;new&lt;/span&gt; Uri( &lt;span style="color: #006080;"&gt;"http://localhost:8181"&lt;/span&gt; );

    var store = &lt;span style="color: blue;"&gt;new&lt;/span&gt; DocumentStore()
    {
        DefaultDatabase = &lt;span style="color: #006080;"&gt;"Spike"&lt;/span&gt;,
        Url = uri.ToString(),
        Credentials = CredentialCache.DefaultCredentials.GetCredential( uri, &lt;span style="color: #006080;"&gt;"Basic"&lt;/span&gt; )
    }.Initialize();
    &lt;span style="color: blue;"&gt;using&lt;/span&gt; ( var session = store.OpenSession() )
    {
        session.Store( &lt;span style="color: blue;"&gt;new&lt;/span&gt; Person() { FirstName = &lt;span style="color: #006080;"&gt;"Mauro"&lt;/span&gt;, LastName = &lt;span style="color: #006080;"&gt;"Servienti"&lt;/span&gt; } );
        session.Store( &lt;span style="color: blue;"&gt;new&lt;/span&gt; Person() { FirstName = &lt;span style="color: #006080;"&gt;"Guido"&lt;/span&gt;, LastName = &lt;span style="color: #006080;"&gt;"Rossi"&lt;/span&gt; } );
        session.Store( &lt;span style="color: blue;"&gt;new&lt;/span&gt; Person() { FirstName = &lt;span style="color: #006080;"&gt;"Giorgio"&lt;/span&gt;, LastName = &lt;span style="color: #006080;"&gt;"Verdi"&lt;/span&gt; } );
        session.Store( &lt;span style="color: blue;"&gt;new&lt;/span&gt; Person() { FirstName = &lt;span style="color: #006080;"&gt;"Samuele"&lt;/span&gt;, LastName = &lt;span style="color: #006080;"&gt;"Bianchi"&lt;/span&gt; } );

        session.SaveChanges();
    }
}&lt;/pre&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/blockquote&gt;
The first thing we need is to load some test data, and then we can try to search for some of them:&lt;br /&gt;
&lt;blockquote&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;pre id="codeSnippet" style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"&gt;&lt;span style="color: blue;"&gt;using&lt;/span&gt; ( var session = store.OpenSession() )
{
    var query = session.Query&amp;lt;Person&amp;gt;().Where( p =&amp;gt; p.FirstName.StartsWith( &lt;span style="color: #006080;"&gt;"G"&lt;/span&gt; ) );
    var persons = query.ToList();
}&lt;/pre&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/blockquote&gt;
The interesting stuff is that if we execute the above query we get back the expected 2 persons (&lt;strong&gt;G&lt;/strong&gt;iorgio and &lt;strong&gt;G&lt;/strong&gt;uido): how can it be? haven’t we said that we need an index to query for data? we have created nothing.&lt;br /&gt;
&lt;strong&gt;The most amazing feature&lt;/strong&gt; (&lt;em&gt;in my humble opinion&lt;/em&gt;)&lt;br /&gt;
If we fire up the &lt;a href="http://ravendb.net/" target="_blank"&gt;RavenDB&lt;/a&gt; Studio and go to the Indexes tab we notice the following:&lt;br /&gt;
&lt;a href="http://lh4.ggpht.com/-62M7ClxpNgA/UIwd_SrSY5I/AAAAAAAACS0/7sQvOoBpvHM/s1600-h/image%25255B3%25255D.png"&gt;&lt;img alt="image" border="0" height="169" src="http://lh4.ggpht.com/-OUnWr-rkeWA/UIweAmLtxCI/AAAAAAAACS8/K63woQEFa7o/image_thumb%25255B1%25255D.png?imgmax=800" style="background-image: none; border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="image" width="320" /&gt;&lt;/a&gt;&lt;br /&gt;
RavenDB has created a brand new index (a temporary index) for us automatically as soon as the query engine has noticed that there is no index that is capable to satisfy the query we issued.&lt;br /&gt;
But…what is the shape of the index?&lt;br /&gt;
&lt;a href="http://lh3.ggpht.com/-Bsu0YZqtCug/UIweBqCw6YI/AAAAAAAACTE/9SrSSytWjgM/s1600-h/image%25255B8%25255D.png"&gt;&lt;img alt="image" border="0" height="166" src="http://lh3.ggpht.com/-4SuPSzWQXXg/UIweCzQD7aI/AAAAAAAACTM/XC4UXwMtUcA/image_thumb%25255B4%25255D.png?imgmax=800" style="background-image: none; border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="image" width="410" /&gt;&lt;/a&gt;&lt;br /&gt;
RavenDB has just created what is called a “Map Index” whose role is to map fields that can be searched so to let the Lucene search engine have something to work on.&lt;br /&gt;
What happens if we issue a new query that involves different fields? Once again we get back the expected results, but:&lt;br /&gt;
&lt;a href="http://lh6.ggpht.com/-nXMj4IovEu8/UIweGROwE0I/AAAAAAAACTU/vceDVXO_630/s1600-h/image%25255B12%25255D.png"&gt;&lt;img alt="image" border="0" height="152" src="http://lh5.ggpht.com/-VWVHP1kkjaU/UIweIi1m0sI/AAAAAAAACTc/eNTUQrJGUBY/image_thumb%25255B6%25255D.png?imgmax=800" style="background-image: none; border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="image" width="349" /&gt;&lt;/a&gt;&lt;br /&gt;
We have now 2 indexes…let’s try one thing, manually delete the first index and re-execute the first query, what happens? No index is created, the query engine realizes that the existing index can be used to satisfy the incoming query, so far so good. The new question now is: is a good practice to let RavenDB auto-magically create indexes? in my opinion the answer is no.&lt;br /&gt;
The basic idea is that since we know how we are going to use our data we can create indexes upfront and use the amazing auto-index creation feature only at development time when for example in order to understand which is the best way to create an index that satisfies a specific query.&lt;br /&gt;
Next time we’ll see options we have out-of-the-box to create and manage indexes.&lt;br /&gt;
.m&lt;img src="http://feeds.feedburner.com/~r/tpx/~4/-KbteIaSbN8" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://milestone.topics.it/feeds/9037702190478636721/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://milestone.topics.it/2012/11/ravendb-map-index.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6511237790974218081/posts/default/9037702190478636721?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6511237790974218081/posts/default/9037702190478636721?v=2" /><link rel="alternate" type="text/html" href="http://milestone.topics.it/2012/11/ravendb-map-index.html" title="RavenDB: map index" /><author><name>Mauro Servienti</name><uri>https://plus.google.com/109709600646686474961</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh4.googleusercontent.com/-KXU7umaJ7sQ/AAAAAAAAAAI/AAAAAAAAAAA/hZhvEAaYHiQ/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh4.ggpht.com/-OUnWr-rkeWA/UIweAmLtxCI/AAAAAAAACS8/K63woQEFa7o/s72-c/image_thumb%25255B1%25255D.png?imgmax=800" height="72" width="72" /><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;CUMMQXY9eSp7ImA9WhNQFks.&quot;"><id>tag:blogger.com,1999:blog-6511237790974218081.post-1133151434177708123</id><published>2012-11-23T10:38:00.000+01:00</published><updated>2012-11-23T10:38:00.861+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-11-23T10:38:00.861+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Software Mason" /><title>logging…what a mess…</title><content type="html">&lt;p&gt;During my daily work I’m currently using &lt;a href="http://nuget.org" target="_blank"&gt;nuget&lt;/a&gt; a lot and after adding some dependencies the references of one of my projects looks like the following:&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh5.ggpht.com/-i57OVdES12g/UHFqB9FQjQI/AAAAAAAACPk/Vu6i38KCYFU/s1600-h/image2.png"&gt;&lt;img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://lh4.ggpht.com/-UAqErtQm47s/UHFqDOviRBI/AAAAAAAACPs/4oVwnPvGwFA/image_thumb.png?imgmax=800" width="222" height="228"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;everyone tends to use its own favorite logging framework with the consequence that if you are the user of other’s framework you finally end up with something that is really like a traffic jam… &lt;/p&gt; &lt;p&gt;I deeply think that a framework should not impose nothing more then the framework functionalities to the user, but in those cases it was imposed to me also the dependency on 2 different logging framework.&lt;/p&gt; &lt;p&gt;I have nothing against both logging infrastructure, what I only want to point out is that now in order to have logs in one single place I am forced to adapt the output of one to the other, or, much better (or worse), of both to System.Diagnostics.Trace.&lt;/p&gt; &lt;p&gt;.m&lt;/p&gt;  &lt;img src="http://feeds.feedburner.com/~r/tpx/~4/ExACKjjioK8" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://milestone.topics.it/feeds/1133151434177708123/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://milestone.topics.it/2012/11/loggingwhat-mess.html#comment-form" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6511237790974218081/posts/default/1133151434177708123?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6511237790974218081/posts/default/1133151434177708123?v=2" /><link rel="alternate" type="text/html" href="http://milestone.topics.it/2012/11/loggingwhat-mess.html" title="logging…what a mess…" /><author><name>Mauro Servienti</name><uri>https://plus.google.com/109709600646686474961</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh4.googleusercontent.com/-KXU7umaJ7sQ/AAAAAAAAAAI/AAAAAAAAAAA/hZhvEAaYHiQ/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh4.ggpht.com/-UAqErtQm47s/UHFqDOviRBI/AAAAAAAACPs/4oVwnPvGwFA/s72-c/image_thumb.png?imgmax=800" height="72" width="72" /><thr:total>2</thr:total></entry><entry gd:etag="W/&quot;CkQCQXgyfCp7ImA9WhNQFEU.&quot;"><id>tag:blogger.com,1999:blog-6511237790974218081.post-5383061524193600743</id><published>2012-11-21T07:46:00.000+01:00</published><updated>2012-11-21T07:46:00.694+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-11-21T07:46:00.694+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="WPF" /><category scheme="http://www.blogger.com/atom/ns#" term="Software Mason" /><title>WPF hosting an Adorner in a template</title><content type="html">&lt;p&gt;take a look at this Xaml:&lt;/p&gt; &lt;blockquote&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Grid&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;behaviors:Overlay.Content&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TextBlock&lt;/span&gt; &lt;span class="attr"&gt;Text&lt;/span&gt;&lt;span class="kwrd"&gt;="Logon failed, please check your username and password."&lt;/span&gt;
                   &lt;span class="attr"&gt;Foreground&lt;/span&gt;&lt;span class="kwrd"&gt;="Red"&lt;/span&gt; &lt;span class="attr"&gt;FontWeight&lt;/span&gt;&lt;span class="kwrd"&gt;="Bold"&lt;/span&gt; &lt;span class="attr"&gt;FontSize&lt;/span&gt;&lt;span class="kwrd"&gt;="30"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;behaviors:Overlay.Content&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Grid&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;
&lt;/blockquote&gt;
&lt;p&gt;it utilizes a feature built-in in &lt;a href="http://radical.codeplex.com/" target="_blank"&gt;Radical&lt;/a&gt;: overlay adorners, that under the hood utilize a WPF Adorner and AdornerLayer to host the given content on top, as a layer, of the adorned element, in this sample a Grid.&lt;/p&gt;
&lt;p&gt;Now, everything works fine and you can use all the WPF features inside an adorner, such as data binding:&lt;/p&gt;
&lt;blockquote&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Grid&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;behaviors:Overlay.Content&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TextBlock&lt;/span&gt; &lt;span class="attr"&gt;Text&lt;/span&gt;&lt;span class="kwrd"&gt;="{Binding Path=ErrorMessage}"&lt;/span&gt;
                   &lt;span class="attr"&gt;Visibility&lt;/span&gt;&lt;span class="kwrd"&gt;="{Binding Path=IsErrorMessageVisible, Converter={StaticResource boolToVisibilityConverter}}"&lt;/span&gt;
                   &lt;span class="attr"&gt;Foreground&lt;/span&gt;&lt;span class="kwrd"&gt;="Red"&lt;/span&gt; &lt;span class="attr"&gt;FontWeight&lt;/span&gt;&lt;span class="kwrd"&gt;="Bold"&lt;/span&gt; &lt;span class="attr"&gt;FontSize&lt;/span&gt;&lt;span class="kwrd"&gt;="30"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;behaviors:Overlay.Content&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Grid&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;
&lt;/blockquote&gt;
&lt;p&gt;but the fanny thing is that if everything (in this case the Grid element) is hosted inside template (e.g. a DataTemplate)&amp;nbsp; bindings &lt;strong&gt;tend&lt;/strong&gt; to fail at runtime…&lt;/p&gt;
&lt;p&gt;Take a look at this more detailed sample Xaml:&lt;/p&gt;
&lt;blockquote&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Window&lt;/span&gt; &lt;span class="attr"&gt;DataContext&lt;/span&gt;&lt;span class="kwrd"&gt;="{Binding Path=Source}"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Grid&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ContentControl&lt;/span&gt; &lt;span class="attr"&gt;Content&lt;/span&gt;&lt;span class="kwrd"&gt;="{Binding Path=ChildOfSource}"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ContentControl.ContentTemplate&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
                &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;DataTemplate&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
                    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;behaviors:Overlay.Content&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
                        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TextBlock&lt;/span&gt; &lt;span class="attr"&gt;Text&lt;/span&gt;&lt;span class="kwrd"&gt;="{Binding Path=ErrorMessage}"&lt;/span&gt;
                                   &lt;span class="attr"&gt;Visibility&lt;/span&gt;&lt;span class="kwrd"&gt;="{Binding Path=IsErrorMessageVisible, Converter={StaticResource boolToVisibilityConverter}}"&lt;/span&gt;
                                   &lt;span class="attr"&gt;Foreground&lt;/span&gt;&lt;span class="kwrd"&gt;="Red"&lt;/span&gt; &lt;span class="attr"&gt;FontWeight&lt;/span&gt;&lt;span class="kwrd"&gt;="Bold"&lt;/span&gt; &lt;span class="attr"&gt;FontSize&lt;/span&gt;&lt;span class="kwrd"&gt;="30"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
                    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;behaviors:Overlay.Content&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
                &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;DataTemplate&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;ContentControl.ContentTemplate&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;ContentControl&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Grid&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Window&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;
&lt;/blockquote&gt;
&lt;p&gt;in this case the expected behavior is that ErrorMessage and IsErrorMessageVisible properties can be found on the object identified by the ChildOfSource property exposed, and bound as the Content of the ContentControl, by the Source element bound as the DataContext of the root Window.&lt;/p&gt;
&lt;p&gt;It does not work, &lt;em&gt;period&lt;/em&gt;. The data binding engine looks for the 2 bound properties on the object identified by the Source property bound on the Window element…why?&lt;/p&gt;
&lt;p&gt;The problem is that the adorner content, the TextBlock in this sample, is a child (in term of visual tree) of the Adorner element but the adorner element is not child of the adorned element but is child of the first AdornerLayer found in the logical tree…and in the sample above the first AdornerLayer that can be found is the implicit one, always created by WPF, child of the root Window, thus our TextBlock is a visual child of the Window and not of the Grid and this explains why the data binding engine looks for properties in a place we think is the wrong place.&lt;/p&gt;
&lt;p&gt;The solution is fairly simple:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;directly bind the DataContext of the elements in the template using the element name of the outer control;&lt;/li&gt;
&lt;li&gt;explicitly wraps the content of the DataTemplate within an AdornerLayer;&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;.m&lt;/p&gt;  &lt;img src="http://feeds.feedburner.com/~r/tpx/~4/_zy_wadIsIc" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://milestone.topics.it/feeds/5383061524193600743/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://milestone.topics.it/2012/11/wpf-hosting-adorner-in-template.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6511237790974218081/posts/default/5383061524193600743?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6511237790974218081/posts/default/5383061524193600743?v=2" /><link rel="alternate" type="text/html" href="http://milestone.topics.it/2012/11/wpf-hosting-adorner-in-template.html" title="WPF hosting an Adorner in a template" /><author><name>Mauro Servienti</name><uri>https://plus.google.com/109709600646686474961</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh4.googleusercontent.com/-KXU7umaJ7sQ/AAAAAAAAAAI/AAAAAAAAAAA/hZhvEAaYHiQ/s512-c/photo.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;Ck4EQXc-eip7ImA9WhNQE04.&quot;"><id>tag:blogger.com,1999:blog-6511237790974218081.post-371582063147785985</id><published>2012-11-19T14:15:00.000+01:00</published><updated>2012-11-19T14:15:00.952+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-11-19T14:15:00.952+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Software Mason" /><category scheme="http://www.blogger.com/atom/ns#" term="WebAPI" /><category scheme="http://www.blogger.com/atom/ns#" term="CQRS" /><title>Jason: MVC WebAPI Hosting</title><content type="html">&lt;p&gt;&lt;a href="http://lh3.ggpht.com/-97-g15beSC0/UIqK2cKL8DI/AAAAAAAACQA/nkVoGf7_RGA/s1600-h/jason22.png"&gt;&lt;img title="jason" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; float: left; padding-top: 0px; padding-left: 0px; margin: 0px 10px 5px 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="jason" align="left" src="http://lh3.ggpht.com/-nXUWj8PaXgU/UIqK3QED1oI/AAAAAAAACQI/9elkKHSO-Fo/jason_thumb20.png?imgmax=800" width="86" height="60"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://milestone.topics.it/2012/11/jason-way-to-handle-c-of-cqrs.html" target="_blank"&gt;Last time we have seen&lt;/a&gt; what &lt;a href="http://jason.codeplex.com/" target="_blank"&gt;Jason&lt;/a&gt; is, the big picture, but we still miss a lot of details and as you may have noticed even the samples of the introduction post miss some important details.&lt;/p&gt; &lt;p&gt;The important things we discovered can be summarized as follows:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;we have understood the commanding pattern exposed by Jason;  &lt;li&gt;we have understood how Jason behaves from the client perspective;  &lt;li&gt;we have understood that we can host Jason in a WebAPI controller or using a WCF service; &lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;strong&gt;Jason setup in MVC WebAPI&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;Let us start from the newest stuff but much simpler WebAPI implementation, first of all create a new MVC WebAPI project and grab a reference to the &lt;a href="https://www.nuget.org/packages/Jason.WebAPI" target="_blank"&gt;Jason.WebAPI&lt;/a&gt; package from &lt;a href="http://nuget.org" target="_blank"&gt;nuget&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;What do you get in the package?&lt;/p&gt; &lt;ul&gt; &lt;li&gt;A built-in JasonController WebAPI controller;&lt;/li&gt; &lt;li&gt;The default configuration implementation;&lt;/li&gt; &lt;li&gt;The default command handler provider;&lt;/li&gt; &lt;li&gt;1 built-in command (EchoCommand) for testing purpose and its related command handler;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;strong&gt;2, 3, go… (cit.)&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;One you have added the nuget package all we have to do is to configure Jason, I’d like to improve the configuration so if you have nay idea let me know.&lt;/p&gt; &lt;p&gt;Open up the Global.asax file of your project and:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;Jason relies on a Inversion of Control framework to work but has no explicit dependency on any specific IoC container, since the requirements are really basic I preferred to expose a simple API to let the user wire Jason with his favorite tool:&lt;/li&gt;&lt;/ul&gt; &lt;blockquote&gt; &lt;div id="codeSnippetWrapper"&gt;&lt;pre id="codeSnippet" style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;var windsor = new WindsorContainer();&lt;br&gt;&lt;br&gt;windsor.Register( Component.For&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;IServiceProvider&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;().Instance( new ServiceProviderWrapper( windsor ) ) );&lt;br&gt;windsor.Register( Component.For&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;ICommandHandlersProvider&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;().ImplementedBy&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;DefaultCommandHandlersProvider&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;() );&lt;br&gt;windsor.Register( Component.For&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;JasonController&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;().LifeStyle.Is( LifestyleType.Transient ) );&lt;/pre&gt;&lt;br&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;Right after the MVC initialization code we are creating a new instance of Castle Windsor adding a bunch of components.&lt;/p&gt;&lt;/blockquote&gt;
&lt;ul&gt;
&lt;li&gt;After setting up the IoC container we can setup the Jason configuration:&lt;/li&gt;&lt;/ul&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;pre id="codeSnippet" style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;var jasonConfig = new JasonWebAPIConfiguration&lt;br&gt;(&lt;br&gt;    pathToScanForAssemblies: Path.Combine( AppDomain.CurrentDomain.BaseDirectory, "bin" ),&lt;br&gt;    jsonTypeNameHandling: TypeNameHandling.Objects&lt;br&gt;)&lt;br&gt;{&lt;br&gt;    RegisterAsTransient = ( c, i ) =&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;    {&lt;br&gt;        windsor.Register&lt;br&gt;        (&lt;br&gt;            Component.For( c )&lt;br&gt;                .ImplementedBy( i )&lt;br&gt;                .LifeStyle.Is( Castle.Core.LifestyleType.Transient )&lt;br&gt;        );&lt;br&gt;    }&lt;br&gt;};&lt;br&gt;&lt;br&gt;jasonConfig.Initialize();&lt;/pre&gt;&lt;/div&gt;
&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;The configuration needs 3 different things:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;a path that the internal type scan engine utilizes to find all the commands and all the handlers;&lt;/li&gt;
&lt;li&gt;A type name handling behavior to handle json commands deserialization (only used if incoming content-type is application/json);&lt;/li&gt;
&lt;li&gt;A Func&amp;lt;Object, Object&amp;gt; used to ask to the external IoC container to register something in a transient manner;&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;The call to Initialize wires up everything and prepares Jason for the first run.&lt;/p&gt;&lt;/blockquote&gt;
&lt;ul&gt;
&lt;li&gt;The last thing to do is to instruct the WebAPI framework to use our IoC implementation to resolve dependencies:&lt;/li&gt;&lt;/ul&gt;
&lt;blockquote&gt;
&lt;div id="codeSnippetWrapper"&gt;&lt;pre id="codeSnippet" style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;GlobalConfiguration.Configuration.DependencyResolver = new DelegateDependencyResolver()&lt;br&gt;{&lt;br&gt;    OnGetService = t =&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;    {&lt;br&gt;        if ( windsor.Kernel.HasComponent( t ) )&lt;br&gt;        {&lt;br&gt;            return windsor.Resolve( t );&lt;br&gt;        }&lt;br&gt;&lt;br&gt;        return null;&lt;br&gt;    },&lt;br&gt;    OnGetServices = t =&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;    {&lt;br&gt;        if ( windsor.Kernel.HasComponent( t ) )&lt;br&gt;        {&lt;br&gt;            return windsor.ResolveAll( t ).OfType&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Object&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;();&lt;br&gt;        }&lt;br&gt;&lt;br&gt;        return new List&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Object&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;();&lt;br&gt;    }&lt;br&gt;};&lt;/pre&gt;&lt;br&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;here I am using a really trivial IDependencyResolver implementation to delegate to the user code the dependency resolve process and let the resolver only handle the wiring between the WebAPI infrastructure and our favorite IoC container.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Now that everything is set up we can test our brand new Jason infrastructure:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Startup the newly created WebAPI application pressing F5 in Visual Studio;&lt;/li&gt;
&lt;li&gt;fire up a new instance of Fiddler and go to the “composer”:&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;a href="http://lh3.ggpht.com/-nxdj_vIXMwU/UIqK44I9qyI/AAAAAAAACQQ/f5vTqwZ-7IU/s1600-h/image%25255B8%25255D.png"&gt;&lt;img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="http://lh6.ggpht.com/-HroOJreslQ0/UIqK6BYvDFI/AAAAAAAACQU/mSViYFhx-Fo/image_thumb%25255B3%25255D.png?imgmax=800" width="358" height="84"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Add a call to Jason controller and remember to set the post content type, in our sample json but also xml is fully supported.&lt;/p&gt;
&lt;p&gt;Finally add a boy to the posted http request:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://lh4.ggpht.com/-xS_7lLCprX4/UIqK70G2qmI/AAAAAAAACQg/bTw7QVetV8E/s1600-h/image%25255B12%25255D.png"&gt;&lt;img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="http://lh3.ggpht.com/-EPirE3ELJXQ/UIqK9gJKD2I/AAAAAAAACQk/E6IH52UifKs/image_thumb%25255B5%25255D.png?imgmax=800" width="400" height="121"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Execute&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;As soon as you press the execute button the Jason infrastructure is invoked from the WebAPI application and you get the expected response:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://lh5.ggpht.com/-rfK0ouLEX9s/UIqK-8JLjWI/AAAAAAAACQw/xjtsJRzj3Vw/s1600-h/image%25255B16%25255D.png"&gt;&lt;img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="http://lh4.ggpht.com/-N8GKBQDjZHA/UIqLAFnJu4I/AAAAAAAACQ4/FZPkggbCGqc/image_thumb%25255B7%25255D.png?imgmax=800" width="414" height="74"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Server side what is happening is that the specialized command handler for the EchoCommand is invoked by the Jason infrastructure, and has the opportunity to do some work and provide a response:&lt;/p&gt;
&lt;blockquote&gt;
&lt;div id="codeSnippetWrapper"&gt;&lt;pre id="codeSnippet" style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;public class EchoCommandHandler : AbstractCommandHandler&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;EchoCommand&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;{&lt;br&gt;    protected override object OnExecute( EchoCommand command )&lt;br&gt;    {&lt;br&gt;        return new EchoCommandResponse()&lt;br&gt;        {&lt;br&gt;            Message = String.Format( "Echo: {0}", command.Message )&lt;br&gt;        };&lt;br&gt;    }&lt;br&gt;}&lt;/pre&gt;&lt;br&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;p&gt;The cool thing is that the whole wiring is done by the infrastructure, thus we can:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Create a bunch of commands in your assemblies;&lt;/li&gt;
&lt;li&gt;Create the dedicated command handler for each command;&lt;/li&gt;
&lt;li&gt;drop all the stuff in the bin folder of the WebAPI application and restart the application;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;We can now use the newly created commands directly from our really cool JavaScript application using WebAPI as a backhand to host command handlers.&lt;/p&gt;
&lt;p&gt;.m&lt;/p&gt;  &lt;img src="http://feeds.feedburner.com/~r/tpx/~4/JD_lERXiSYw" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://milestone.topics.it/feeds/371582063147785985/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://milestone.topics.it/2012/11/jason-mvc-webapi-hosting.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6511237790974218081/posts/default/371582063147785985?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6511237790974218081/posts/default/371582063147785985?v=2" /><link rel="alternate" type="text/html" href="http://milestone.topics.it/2012/11/jason-mvc-webapi-hosting.html" title="Jason: MVC WebAPI Hosting" /><author><name>Mauro Servienti</name><uri>https://plus.google.com/109709600646686474961</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh4.googleusercontent.com/-KXU7umaJ7sQ/AAAAAAAAAAI/AAAAAAAAAAA/hZhvEAaYHiQ/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh3.ggpht.com/-nXUWj8PaXgU/UIqK3QED1oI/AAAAAAAACQI/9elkKHSO-Fo/s72-c/jason_thumb20.png?imgmax=800" height="72" width="72" /><thr:total>0</thr:total></entry></feed>
