<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-1913176053516708798</id><updated>2011-10-10T02:33:01.917-04:00</updated><category term='C#'/><category term='Resharper'/><category term='Reflection'/><category term='continuous integration'/><category term='code coverage'/><category term='Ruby'/><category term='BDD'/><category term='Rails'/><category term='optimization'/><category term='castle'/><category term='NHibernate'/><category term='Ubuntu'/><category term='Rhino Mocks'/><category term='DevExpress'/><category term='conventions'/><category term='distribution'/><category term='svn'/><category term='.NET'/><category term='dotTrace'/><category term='Random numbers'/><category term='gaussian'/><category term='FluentNHibernate'/><title type='text'>Michael Sevestre's Blog</title><subtitle type='html'>Thoughts on .NET, C#, TDD, BDD and much more :-)</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://blog.msevestre.ca/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1913176053516708798/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://blog.msevestre.ca/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Michael Sevestre</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>14</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-1913176053516708798.post-2051160601065434565</id><published>2011-08-04T10:00:00.000-04:00</published><updated>2011-08-04T10:00:02.222-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Ubuntu'/><title type='text'>Setting up a Ubuntu 10.10 machine</title><content type='html'>&lt;div style="text-align: justify;"&gt;My first thought was to start my rails journey on a Win7 machine. There are a few tutorial out there and even an &lt;a href="http://railsinstaller.org/"&gt;msi package&lt;/a&gt; installing ruby and rails for you for windows.... It did not take me long however to realize, that even if you can get rails running on windows, most tools and tutorials are tailored for a Linux based machine. If learning something new, better learn it right, eh?&lt;br /&gt;&lt;br /&gt;I am not a Linux expert whatsoever so I wasn't sure where to start. What distribution to install, which version etc... A little bit of research revealed that the Ubuntu installation is a favorite in the Rails community.... Does that mean that I have to install a Linux Ubuntu system from scratch?!? The short answer is no! You can actually download a VM Image of a fully configured &lt;a href="http://www.trendsigma.net/vmware/"&gt;Ubuntu 10.10 machine&lt;/a&gt;. How neat is that? The only thing left is to install a &lt;a href="http://www.vmware.com/download/player/"&gt;VMWare player&lt;/a&gt; and you're good to go. You have a Ubuntu machine working. Great!&lt;br /&gt;&lt;br /&gt;So Friend, don't be afraid to leave the Microsoft world completely and embrace the power of Ubuntu. It's so easy to get started. If you screw up the installation, no big deal, just unzip the downloaded image and you have a clean start! (unless you have a VMWare Workstation which allows you to take snapshot of your machine at any time...in that case, you just need to revert to a snapshot).&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1913176053516708798-2051160601065434565?l=blog.msevestre.ca' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.msevestre.ca/feeds/2051160601065434565/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.msevestre.ca/2011/08/setting-up-ubuntu-1010-machine.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1913176053516708798/posts/default/2051160601065434565'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1913176053516708798/posts/default/2051160601065434565'/><link rel='alternate' type='text/html' href='http://blog.msevestre.ca/2011/08/setting-up-ubuntu-1010-machine.html' title='Setting up a Ubuntu 10.10 machine'/><author><name>Michael Sevestre</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1913176053516708798.post-5242360613149195797</id><published>2011-08-03T13:47:00.004-04:00</published><updated>2011-08-03T14:47:51.530-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='Ruby'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><category scheme='http://www.blogger.com/atom/ns#' term='Rails'/><title type='text'>Learning Ruby and Rails</title><content type='html'>&lt;div style="text-align: justify;"&gt; I have been doing Microsoft Development for most of my career, mostly using .NET  and C#.  I feel confident in my ability to tackle any project using this platform. It is a great feeling, no question about that, and I am always excited to start a new project.&lt;br /&gt;&lt;br /&gt;Of course, even in C#, I am far from knowing everything! There is always something to learn especially with the new features such as the Asynchronous library that will be released in C# 5. But for now, I want to learn what I really don't know about the "other (non-Microsoft) side" of things. &lt;span class="st"&gt;There is a lot of noise about &lt;a href="http://www.ruby-lang.org/en/"&gt;Ruby&lt;/a&gt; and &lt;a href="http://rubyonrails.org/"&gt;Rails&lt;/a&gt; and a growing demand  for Ruby on &lt;em&gt;Rails&lt;/em&gt; developers, so &lt;em&gt;learning&lt;/em&gt; to build sites with &lt;em&gt;Rails&lt;/em&gt; is certainly not a bad idea, is it?&lt;/span&gt;&lt;br /&gt;&lt;span class="st"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="st"&gt;I spent the last few weeks deep diving into ruby and rails, feeling happy by the incredible possibilities offered by Ruby and overwhelmed at the same time by the new syntax and inherent philosophy. There is definitely a steep learning curve when coming from a static language like C#. &lt;/span&gt;&lt;br /&gt;&lt;span class="st"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="st"&gt;&lt;span style="font-style: italic;"&gt;Learning by doing&lt;/span&gt; is for me the best way to integrate and understand the core concepts of a new technology. So guess what! I will spend a lot of time trying stuff out. Be prepare to see a lot of posts relating my journey to the other side and away&lt;/span&gt; from the comfort zone!&lt;br /&gt;&lt;span class="st"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1913176053516708798-5242360613149195797?l=blog.msevestre.ca' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.msevestre.ca/feeds/5242360613149195797/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.msevestre.ca/2011/08/learning-ruby-and-rails.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1913176053516708798/posts/default/5242360613149195797'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1913176053516708798/posts/default/5242360613149195797'/><link rel='alternate' type='text/html' href='http://blog.msevestre.ca/2011/08/learning-ruby-and-rails.html' title='Learning Ruby and Rails'/><author><name>Michael Sevestre</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1913176053516708798.post-1025503004752233381</id><published>2011-07-28T10:43:00.002-04:00</published><updated>2011-07-28T11:58:58.069-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='castle'/><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='dotTrace'/><category scheme='http://www.blogger.com/atom/ns#' term='optimization'/><category scheme='http://www.blogger.com/atom/ns#' term='conventions'/><title type='text'>Optimizing components registration in Castle</title><content type='html'>&lt;div style="text-align: justify;"&gt;Some of our users complained that the time needed to start one of our desktop application was too long (~50s).  There is a lot of things happening under the hood when starting the application so I decided to use my favorite &lt;a href="http://www.jetbrains.com/profiler/"&gt;profiler&lt;/a&gt; tool (yeah I know, jetbrain again!) to profile the application.&lt;br /&gt;&lt;br /&gt;The new version of the profiler comes with a bunch of new features. Since I wanted to exactly know what was happening and where time was being lost, I went with the high accuracy mode and of course, checked the start profiling immediately since the time spent to start the application is our concerned.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/-GyfAb8NnI7M/TjAmoMVX8vI/AAAAAAAAACQ/dOxcl1IYK3s/s1600/profilerOptions.png"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 400px; height: 124px;" src="http://2.bp.blogspot.com/-GyfAb8NnI7M/TjAmoMVX8vI/AAAAAAAAACQ/dOxcl1IYK3s/s400/profilerOptions.png" alt="" id="BLOGGER_PHOTO_ID_5634045605787988722" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;The results were really interesting and I could not really believe it at first: 70% of the time was spent registering components in our IoC Container of choice. Castle! Looking closer at the profiler output, I could see that we were registering close to 1000 components in the container (991 exactly). The registration is (of course) based on some predefined convention (yeah convention again) to register the type automatically in the container. 1000 components is a lot, but nothing too crazy and there is &lt;span style="font-weight: bold;"&gt;no way &lt;/span&gt;so much time should be spent just to register them anyways.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/-7vLtK5GRIuk/TjApin2tSCI/AAAAAAAAACo/V8eapfomqqY/s1600/windsor.png"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 400px; height: 182px;" src="http://2.bp.blogspot.com/-7vLtK5GRIuk/TjApin2tSCI/AAAAAAAAACo/V8eapfomqqY/s400/windsor.png" alt="" id="BLOGGER_PHOTO_ID_5634048808631224354" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Now look at what happens here. The components validation is taking 96% of the overall registration time. I guess the kernel is always trying to check if a component being registered is valid or not. If you have a lot of invalid components (which happens obviously when registering components with convention), the time spent in validation degenerates to an O(N^2/2) operation! There had to be a way to disable the validation and optimize the registration....&lt;br /&gt;&lt;br /&gt;And indeed, I found the&lt;a href="http://issues.castleproject.org/issue/IOC-195"&gt; &lt;span id="issId_41_1912" class="issueId"&gt;  &lt;/span&gt;&lt;/a&gt; &lt;span id="id_l.I.ic.icr.it.issSum" class="issue-summary"&gt;&lt;a href="http://issues.castleproject.org/issue/IOC-195"&gt; OptimizeDependencyResolution&lt;/a&gt;!&lt;/span&gt; Apparently this is a way to optimize registration, but it breaks startable facility in &lt;span style="color: rgb(51, 102, 255);"&gt;castle 2.1&lt;/span&gt;, which happens to be the version we are using currently. I decided to take the plunge and upgrade to &lt;span style="color: rgb(51, 102, 255);"&gt;castle 2.5&lt;/span&gt;, where a fix was provided. It meant also updating to &lt;span style="color: rgb(51, 102, 255);"&gt;NHibernate 3.1&lt;/span&gt; and &lt;span style="color: rgb(51, 102, 255);"&gt;FluentNhibernate 1.2&lt;/span&gt;...ARGHHS versioning hell all  over again.  An hour later, I was back on track and the app was running. At that point, I was so glad that we had integration tests to test our FluentNhibernate mapping etc... Upgrading all at once without that security net would have been a real nightmare otherwise.&lt;br /&gt;&lt;br /&gt;Back to our &lt;span style="font-weight: bold;"&gt;OptimizeDependencyResolution&lt;/span&gt;. The only thing that was left to do was to  encapsulate the registration with&lt;/div&gt;&lt;pre class="brush:csharp"&gt;using (kernel.OptimizeDependencyResolution())&lt;br /&gt;{&lt;br /&gt;//do registration logic here&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;div style="text-align: justify;"&gt;The time to load the application with that &lt;span style="font-weight: bold;"&gt;one only code&lt;/span&gt; change dropped to 9s! Wow now we're talking!&lt;br /&gt;&lt;br /&gt;So Dear Reader, don't spend time guessing where you can optimize your code. First only optimize when a performance problem occurs, &lt;span style="font-weight: bold;"&gt;NEVER BEFORE&lt;/span&gt;! Then use a profiler to discover the bottleneck of your application.&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1913176053516708798-1025503004752233381?l=blog.msevestre.ca' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.msevestre.ca/feeds/1025503004752233381/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.msevestre.ca/2011/07/optimizing-components-registration-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1913176053516708798/posts/default/1025503004752233381'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1913176053516708798/posts/default/1025503004752233381'/><link rel='alternate' type='text/html' href='http://blog.msevestre.ca/2011/07/optimizing-components-registration-in.html' title='Optimizing components registration in Castle'/><author><name>Michael Sevestre</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/-GyfAb8NnI7M/TjAmoMVX8vI/AAAAAAAAACQ/dOxcl1IYK3s/s72-c/profilerOptions.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1913176053516708798.post-4446668983190046171</id><published>2011-07-27T10:17:00.010-04:00</published><updated>2011-07-27T15:38:10.640-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='Reflection'/><category scheme='http://www.blogger.com/atom/ns#' term='conventions'/><title type='text'>Test your conventions with reflection</title><content type='html'>&lt;div style="text-align: justify;"&gt;I am not a big fan of using reflection  in .NET. Most of the time, people believe that reflection is well  known, easy to understand and part of the standard tools available to  all .NET developers. I strongly believe that reflection can do more harm  than good. Used wisely however, it can be really helpful...let see an  example!&lt;br /&gt;&lt;br /&gt;In one of the application I am working on, we  encapsulate all the user actions changing the underlying domain in  command objects, using the well-known command pattern. Each command  should be kept into a command history so that one can track at all-time  what has changed and how. One requirement to the system is the ability  to rollback to any previous state of the project (and thus reverse all  changes made since that state) and AT ALL TIME. Yes dear readers, it  means that on top of the domain, the history of all command needs to be  persisted as well.&lt;br /&gt;&lt;br /&gt;We have an in-house Xml Serialization  Framework that we use to serialize the commands. In order to serialize a Command, let say a &lt;span style="color: rgb(51, 102, 255);"&gt;DeleteCommand&lt;/span&gt;, we need to define an object implementing the &lt;span style="color: rgb(51, 102, 255);"&gt;ISerializer&amp;lt;DeleteCommand&amp;gt;&lt;/span&gt; , for instance &lt;span style="color: rgb(51, 102, 255);"&gt;DeleteCommandSerializer&lt;/span&gt;. Now we have hundreds of commands in the system. How to make sure that  we don't forget to write a serializer for a new command? In other words,  how to &lt;b&gt;ensure&lt;/b&gt; that our convention "Each command should have a serializer" is met? Write a test!&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;It's where reflection comes into play:  &lt;pre class="brush:csharp"&gt;[Observation]&lt;br /&gt;public void each_concrete_command_should_have_a_defined_serializer()&lt;br /&gt;{&lt;br /&gt;var commandAssembly = typeof(ICommand).Assembly;&lt;br /&gt;var allCommandTypes = commandAssembly.GetConcreteTypesImplementing&amp;lt;ICommand&amp;gt;();&lt;br /&gt;&lt;br /&gt;var serializerAssembly = typeof(ISerializer).Assembly;&lt;br /&gt;var allSerializerTypes = serializerAssembly.GetConcreteTypesImplementing&amp;lt;ISerializer&amp;gt;();&lt;br /&gt;&lt;br /&gt;var allImplementationType = new Collection&amp;lt;Type&amp;gt;();&lt;br /&gt;&lt;br /&gt;foreach(var type in allSerializerTypes)&lt;br /&gt;{&lt;br /&gt;foreach(var typeForGenericType in type.GetDeclaredTypesForGeneric(typeof(ISerializer&amp;lt;&amp;gt;)))&lt;br /&gt;{&lt;br /&gt;  if (allImplementationType.Contains(typeForGenericType.DeclaredType)) continue;&lt;br /&gt;    allImplementationType.Add(typeForGenericType.DeclaredType);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;var errorList = new List&amp;lt;string&amp;gt;();&lt;br /&gt;foreach(var type inallCommandTypes)&lt;br /&gt;{&lt;br /&gt;if (allImplementationType.Contains(type))&lt;br /&gt;  errorList.Add(string.Format("No serializer found for {0}", type));&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Assert.IsTrue(errorList.Count == 0, errorList.ToString("\n"));&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;p style="text-align: justify;"&gt;Looking at the code above there are a few items I should point out&lt;/p&gt;&lt;div style="text-align: justify;"&gt;  &lt;/div&gt;&lt;ol style="text-align: justify;"&gt;&lt;li&gt;This will retrieve all the types implementing &lt;span style="color: rgb(51, 102, 255);"&gt;ICommand&lt;/span&gt; and all the types implementing &lt;span style="color: rgb(51, 102, 255);"&gt;ISerializer&lt;/span&gt;. We suppose that all commands are defined in one assembly as well as all serializers. (that might be however the same assembly). We use the  useful extension method defined &lt;a href="http://blog.msevestre.ca/2011/07/finding-types-in-assembly-implementing.html"&gt;here&lt;/a&gt;.&lt;/li&gt;&lt;li&gt;Then we retrieve the actual type used in the open type &lt;span style="color: rgb(51, 102, 255);"&gt;ISerializer&amp;lt;&amp;gt;&lt;/span&gt;. For that I use another extension method, &lt;span style="color: rgb(51, 102, 255);"&gt;GetDeclaredTypesForGeneric&lt;/span&gt; that returns &lt;span style="color: rgb(51, 102, 255);"&gt;MyType&lt;/span&gt; (the so called &lt;span style="font-weight: bold;"&gt;DeclaredType&lt;/span&gt;) for a generic &lt;span style="color: rgb(51, 102, 255);"&gt;ISerializer&amp;lt;MyType&amp;gt;&lt;/span&gt;. If you are interested in the implementation, drop me a line and I will blog about that as well.&lt;/li&gt;&lt;li&gt;Last  we want to log the error. Note the use of a list to save the error. The  assertion only happens at the very end of the test so that we get the  exhaustive list of all commands without a serializer.&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Friends,  my advice is to always test the convention in your system. That will  bring joy and happiness in the long run and enhance your productivity.&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1913176053516708798-4446668983190046171?l=blog.msevestre.ca' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.msevestre.ca/feeds/4446668983190046171/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.msevestre.ca/2011/07/test-your-conventions-with-reflection.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1913176053516708798/posts/default/4446668983190046171'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1913176053516708798/posts/default/4446668983190046171'/><link rel='alternate' type='text/html' href='http://blog.msevestre.ca/2011/07/test-your-conventions-with-reflection.html' title='Test your conventions with reflection'/><author><name>Michael Sevestre</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1913176053516708798.post-4275482066008289303</id><published>2011-07-27T09:22:00.005-04:00</published><updated>2011-07-27T10:23:31.778-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='Reflection'/><title type='text'>Finding types in an assembly implementing another type</title><content type='html'>&lt;div style="text-align: justify;"&gt;The other day I had the need to retrieve the types defined in an assembly that were implementing another given type. How would you do that? Here is my solution:&lt;/div&gt;&lt;pre class="brush:csharp"&gt;public static IEnumerable&amp;lt;Type&amp;gt; GetConcreteTypesImplementing&amp;lt;T&amp;gt;(this Assembly assembly)&lt;br /&gt;{&lt;br /&gt;  return assembly.GetConcreteTypesImplementing(typeof(T));&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public static IEnumerable&amp;lt;Type&amp;gt; GetConcreteTypesImplementing(this Assembly assembly, Type typeToImplement)&lt;br /&gt;{&lt;br /&gt;  return from type in assembly.GetConcreteTypes()&lt;br /&gt;         where type.IsAnImplementationOf(typeToImplement)&lt;br /&gt;         select type;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public static IEnumerable&amp;lt;Type&amp;gt; GetConcreteTypes(this Assembly assembly)&lt;br /&gt;{&lt;br /&gt;  return from type in assembly.GetExportedTypes()&lt;br /&gt;         where !type.IsGenericType&lt;br /&gt;         where !type.IsAbstractClass()&lt;br /&gt;         select type;&lt;br /&gt;}&lt;/pre&gt;&lt;div style="text-align: justify;"&gt;The code here is fairly simple. The idee is to query all exported type in the assembly filtering out the generic and abstract types. Note that IsAbstractClass is another extension methods:&lt;br /&gt;&lt;/div&gt;&lt;pre class="brush:csharp"&gt;public static bool IsAbstractClass(this Type type)&lt;br /&gt;{&lt;br /&gt;  return (type.IsAbstract || type.IsInterface);&lt;br /&gt;}&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1913176053516708798-4275482066008289303?l=blog.msevestre.ca' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.msevestre.ca/feeds/4275482066008289303/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.msevestre.ca/2011/07/finding-types-in-assembly-implementing.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1913176053516708798/posts/default/4275482066008289303'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1913176053516708798/posts/default/4275482066008289303'/><link rel='alternate' type='text/html' href='http://blog.msevestre.ca/2011/07/finding-types-in-assembly-implementing.html' title='Finding types in an assembly implementing another type'/><author><name>Michael Sevestre</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1913176053516708798.post-4258231659735191514</id><published>2011-04-01T09:00:00.005-04:00</published><updated>2011-04-01T09:37:02.489-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Resharper'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>Prevent Resharper from adding regions!</title><content type='html'>&lt;div style="text-align: justify;"&gt;Resharper is an amazing tool that I use every day. I could certainly not do without anymore. There is one really annoying thing with it however: Its default behavior is to wrap interface implementation in a region!&lt;br /&gt;&lt;br /&gt;Unless your code is being generated automatically, regions are just noise to me.  If you need them to make your code easier to understand, I bet that your code is doing way to much and is certainly violating the Single Responsibility Principle.&lt;br /&gt;&lt;br /&gt;The good thing with Resharper is that you can configure almost everything! Turning off regions for interface is a bit trickier than expected. I’m sure this has been blogged about thousands of times. I  was just asked again how I managed to get rid of them but could not find it,  so I wanted to capture it someplace  useful.&lt;br /&gt;&lt;br /&gt;Follow this steps, and you will be region free:&lt;br /&gt;&lt;/div&gt;&lt;ul style="text-align: justify;"&gt;&lt;li&gt;Go to Resharper -&amp;gt; Options&lt;/li&gt;&lt;li&gt;Go in the left pane to C# -&amp;gt;Formatting Style -&amp;gt;Type Members Layout&lt;/li&gt;&lt;li&gt;Unchecked "Use Default Patterns"  &lt;/li&gt;&lt;li&gt;A scary XML appears on the right pane. It looks scarier than it is so &lt;span style="font-weight: bold;"&gt;stay calm&lt;/span&gt;&lt;/li&gt;&lt;li&gt;Find the section marked by  &amp;lt;!--interface implementations--&amp;gt;&lt;/li&gt;&lt;li&gt;Find the tag  &amp;lt;entry&amp;gt;&lt;/li&gt;&lt;li&gt;Remove&lt;pre class="brush:csharp"&gt;&amp;lt;group&amp;gt;&lt;br /&gt;&amp;lt;implementsinterface immediate="true" region="${ImplementsInterface} Members"&amp;gt;&lt;br /&gt;&amp;lt;/implementsinterface&amp;gt;&lt;br /&gt;&amp;lt;/group&amp;gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div style="text-align: justify;"&gt;That's it!!&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1913176053516708798-4258231659735191514?l=blog.msevestre.ca' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.msevestre.ca/feeds/4258231659735191514/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.msevestre.ca/2011/01/prevent-resharper-from-adding-regions.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1913176053516708798/posts/default/4258231659735191514'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1913176053516708798/posts/default/4258231659735191514'/><link rel='alternate' type='text/html' href='http://blog.msevestre.ca/2011/01/prevent-resharper-from-adding-regions.html' title='Prevent Resharper from adding regions!'/><author><name>Michael Sevestre</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1913176053516708798.post-8095947089006961582</id><published>2011-03-31T20:00:00.007-04:00</published><updated>2011-03-31T20:22:04.234-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='BDD'/><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='Rhino Mocks'/><title type='text'>Nice Feature in Rhino.Mocks. The Do() handler</title><content type='html'>&lt;div style="text-align: justify;"&gt;I have been working with &lt;a href="http://www.ayende.com/wiki/Rhino+Mocks.ashx"&gt;Rhino.Mocks&lt;/a&gt; for quite a while now and believed I knew most of the goodies available in this tool. Today I was proven wrong!&lt;br /&gt;&lt;br /&gt;Using the extension methods &lt;span style="font-weight: bold;"&gt;Stub &lt;/span&gt;on a mock object, you can specify the return value for a method when being called. Keep in mind that you do not create an expectation for this method.&lt;br /&gt;&lt;br /&gt;A sample code could be something like:&lt;br /&gt;&lt;pre class="brush:csharp"&gt;_orderFactory.Stub(x=&amp;gt;x.CreateOrder()).Return(new Order());&lt;br /&gt;&lt;/pre&gt;Notice that each and every time the method &lt;span style="font-weight: bold;"&gt;CreateOrder() &lt;/span&gt;is called on the mock object _orderFactory, the &lt;span style="font-weight: bold;"&gt;same &lt;/span&gt;static object created in the first method call will be returned.&lt;br /&gt;&lt;br /&gt;Now this behaviour is more than enough for most of the tests I write. But there are times, like this morning, where I needed the &lt;span style="font-weight: bold;"&gt;CreateOrder()&lt;/span&gt; method to always return a new instance of &lt;span style="font-weight: bold;"&gt;Order &lt;/span&gt;when called. There is a really easy way to do it. Using the &lt;span style="font-weight: bold;"&gt;Do()&lt;/span&gt; handler:&lt;br /&gt;The signature of the Do() is pretty scary at first. It takes a &lt;span style="font-weight: bold; font-style: italic;"&gt;Delegate&lt;/span&gt;. That's right, an old .NET 1.0 Delegate which is not strongly typed. That's also the reason why its use can be really powerful:&lt;br /&gt;&lt;pre class="brush:csharp"&gt;_orderFactory.Stub(x=&amp;gt;x.CreateOrder()).Do((Func&amp;lt;Order&amp;gt;)(() =&amp;gt;new Order()))&lt;/pre&gt;And that's it! Every time the &lt;span style="font-weight: bold;"&gt;CreateOrder()&lt;/span&gt; method is called, the mock will return a new Order.&lt;br /&gt;&lt;br /&gt;On a side note, I don't like to use the word &lt;span style="font-weight: bold;"&gt;stub &lt;/span&gt;or &lt;span style="font-weight: bold;"&gt;mock &lt;/span&gt;in the code, since it tends to decrease the code readability. I have created an extension method that helps make the code easier to understand&lt;br /&gt;&lt;pre class="brush:csharp"&gt;public static class RhinoMocksExtensions&lt;br /&gt;{&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Setup a result for the given function call&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;public static IMethodOptions&amp;lt;R&amp;gt; SetupResultFor&amp;lt;T&amp;gt;(this T mock, Function&amp;lt;T, R&amp;gt; func) where T : class&lt;br /&gt;{&lt;br /&gt;return mock.Stub(func);&lt;br /&gt;}&lt;br /&gt;...&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;//using this extension method, stub call would be&lt;br /&gt;_orderFactory.SetupResultFor(x=&amp;gt;x.CreateOrder()).Do((Func&amp;lt;Order&amp;gt;)(() =&amp;gt; new Order()));&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Sweet!&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1913176053516708798-8095947089006961582?l=blog.msevestre.ca' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.msevestre.ca/feeds/8095947089006961582/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.msevestre.ca/2011/03/nice-feature-in-rhinomocks-do-handler.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1913176053516708798/posts/default/8095947089006961582'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1913176053516708798/posts/default/8095947089006961582'/><link rel='alternate' type='text/html' href='http://blog.msevestre.ca/2011/03/nice-feature-in-rhinomocks-do-handler.html' title='Nice Feature in Rhino.Mocks. The Do() handler'/><author><name>Michael Sevestre</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1913176053516708798.post-425202354037135689</id><published>2011-01-10T19:00:00.004-05:00</published><updated>2011-01-10T19:00:04.883-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='BDD'/><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='continuous integration'/><title type='text'>BDD Style  - How to organize your files / folders</title><content type='html'>&lt;div style="text-align: justify;"&gt;One thing that can become really tricky when using a BDD style approach to develop software is the organization of files and folders within a visual studio solution.&lt;br /&gt;&lt;br /&gt;A common approach is to create one project containing all the unit and integration tests for the application. This means in general that you have to duplicate the folder / namespace structure from the application itself in the test project. It could look something like this.&lt;br /&gt;&lt;/div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_g08CTwdACHU/TStSbamMQSI/AAAAAAAAABE/S_TkPm2HAc4/s1600/notbdd.jpg"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 304px; height: 400px;" src="http://3.bp.blogspot.com/_g08CTwdACHU/TStSbamMQSI/AAAAAAAAABE/S_TkPm2HAc4/s400/notbdd.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5560628795868463394" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Intuitive at first, this approach has one major drawback. The time spend moving file when refactoring a namespace or a folder increase drastically. You always have to keep in mind that you must duplicate the modifications made to the application folder structure in the test project, which of course might easily be forgotten.&lt;br /&gt;&lt;br /&gt;We have adopted a slightly different yet powerful approach to structure our tests in a solution. Instead of creating a project for our tests, the specs/tests file lives beside the code it is testing.&lt;br /&gt;For example, if we have a class &lt;span style="font-weight: bold;"&gt;CustomerRetriever&lt;/span&gt;, the specs/tests will be in the file &lt;span style="font-weight: bold;"&gt;CustomerRetrieverSpecs.cs&lt;/span&gt; that resides in the same project and namespace as the CustomerRetriever. Thanks to this organization, there is &lt;span style="font-weight: bold;"&gt;no need to duplicate any folder structure&lt;/span&gt; in a test project and we can see with a single glance if a portion of code has not been tested (means there is no xxxSpecs.cs file for that class). Such an organization could look something like this:&lt;br /&gt;&lt;/div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_g08CTwdACHU/TSsINFjbb1I/AAAAAAAAAA0/Wquw36FrcUU/s1600/bdd.jpg"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 291px; height: 245px;" src="http://1.bp.blogspot.com/_g08CTwdACHU/TSsINFjbb1I/AAAAAAAAAA0/Wquw36FrcUU/s400/bdd.jpg" alt="" id="BLOGGER_PHOTO_ID_5560547185841106770" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;This approach is of course only usable if the .NET system is being build using NAnt, rake, albacore etc.. since only a subset of the files should be used to build the assemblies.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;In &lt;span style="font-weight: bold;"&gt;NAnt &lt;/span&gt;for example you would have to use the &amp;lt;csc&amp;gt; Task with a fileset&lt;br /&gt;&lt;pre class="brush:csharp"&gt;&lt;br /&gt;&amp;lt;fileset id="app.sources"&amp;gt;&lt;br /&gt;  &amp;lt;include name="${src.dir}\**\*.cs"/&amp;gt;&lt;br /&gt;  &amp;lt;exclude name="${src.dir}\**\*Specs.cs"&lt;wbr&gt;/&amp;gt;&lt;br /&gt;&amp;lt;/fileset&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;In Albacore, &lt;a href="http://www.lostechies.com/blogs/derickbailey/default.aspx"&gt;Derick Bailey&lt;/a&gt; created following syntax to achieve the same goal.&lt;br /&gt;&lt;pre class="brush:csharp"&gt;&lt;br /&gt;csc :build do |csc|&lt;br /&gt;  csc.command = "csc.exe"&lt;br /&gt;  csc.compile FileList["src/**/*.cs"].exclude("src/**/*Specs.cs")&lt;br /&gt;  csc.output = "myproject.dll"&lt;br /&gt;  csc.target = :library&lt;br /&gt;end&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1913176053516708798-425202354037135689?l=blog.msevestre.ca' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.msevestre.ca/feeds/425202354037135689/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.msevestre.ca/2001/01/bdd-style-how-to-organize-your-files.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1913176053516708798/posts/default/425202354037135689'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1913176053516708798/posts/default/425202354037135689'/><link rel='alternate' type='text/html' href='http://blog.msevestre.ca/2001/01/bdd-style-how-to-organize-your-files.html' title='BDD Style  - How to organize your files / folders'/><author><name>Michael Sevestre</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_g08CTwdACHU/TStSbamMQSI/AAAAAAAAABE/S_TkPm2HAc4/s72-c/notbdd.jpg' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1913176053516708798.post-9036863568986576080</id><published>2010-12-27T18:00:00.007-05:00</published><updated>2010-12-28T11:05:26.097-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='NHibernate'/><category scheme='http://www.blogger.com/atom/ns#' term='FluentNHibernate'/><title type='text'>Migration to Fluent NHibernate</title><content type='html'>&lt;div style="text-align: justify;"&gt;A few months ago, I decided to take the plunge and migrate our existing NHibernate xml mapping to the fluent version using the Fluent NHibernate API. At that time I was following the development of the Fluent NHibernate project and felt that the product was mature enough to use in production.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;The really good surprise&lt;/span&gt;: the migration to Fluent NHibernate was really easy. For almost all our existing hbml files, the migration was straight forward. Only a few mappings required some more searching (and guessing) but nothing that could not be found...eventually.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Migration strategy:&lt;/span&gt;&lt;br /&gt;When migrating a system, the key is to try to make as few changes as possible. Obviously, the more you change at once, the higher the chance is that something is broken.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;The other good surprise&lt;/span&gt;: Fluent Nhibernate fully supports side-by-side hbml and fluent mapping which makes the migration strategy feasible. Sweet!&lt;br /&gt;Here is what I did:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;1-Let Fluent NHibernate load your existing configuration:&lt;/span&gt;&lt;br /&gt;The first thing to do is &lt;a href="http://fluentnhibernate.org/"&gt;download&lt;/a&gt; the last version of FluentNHibernate. Reference the FluentNHibernate.dll. Then I had to modify our configuration so that FluentNHibernate is now in charge of loading our hbml mapping. In our case, we used the configuration object:&lt;br /&gt;&lt;/div&gt;&lt;pre class="brush:csharp"&gt;&lt;br /&gt;private Configuration createConfigurationFor(string dataSource)&lt;br /&gt;{&lt;br /&gt;   var config= new Configuration();&lt;br /&gt;   config.SetProperty("connection.provider", "NHibernate.Connection.DriverConnectionProvider");&lt;br /&gt;   config.SetProperty("connection.driver_class", "NHibernate.Driver.SqlServerCeDriver");&lt;br /&gt;   config.SetProperty("dialect", "NHibernate.Dialect.MsSqlCeDialect");&lt;br /&gt;   config.SetProperty("connection.connection_string", string.Format("Data Source={0}", dataSource));&lt;br /&gt;   config.SetProperty("connection.release_mode", "on_close");&lt;br /&gt;   config.SetProperty("proxyfactory.factory_class", "NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle");&lt;br /&gt;   config.SetProperty("show_sql", "false");&lt;br /&gt;   config.AddAssembly(typeof(SessionFactoryProvider).Assembly);&lt;br /&gt;   return config;&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;In this example, SessionFactoryProvider is a class that creates the NHibernate Configuration object which is later used to create a SessionFactory. The only thing I had to do here is replace the last line returning the configuration with&lt;/div&gt;&lt;br /&gt;&lt;pre class="brush:csharp"&gt;&lt;br /&gt;return Fluently.Configure(config)&lt;br /&gt; .Mappings(cfg =&gt; &lt;br /&gt;    {&lt;br /&gt;       cfg.HbmMappings.AddFromAssemblyOf&amp;lt;sessionfactoryprovider&amp;gt;(); &lt;br /&gt;       cfg.FluentMappings.AddFromAssemblyOf&amp;lt;sessionfactoryprovider&amp;gt;();&lt;br /&gt;    }).BuildConfiguration();&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;And that's it. FluentNHibernate is now in command and loads our hbml mappings. It's a good first step, yet not really exciting. Time to get rid of our old hbml mappings!!&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;2-Migrate the hbml mapping files.&lt;/span&gt;&lt;br /&gt;As mentioned before, the key is to make as few changes as possible. So I decided to migrate one file at a time (and one only)&lt;br /&gt;&lt;ul&gt;&lt;li&gt;create a new ClassMap for the entity matching the file being replaced.&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;delete the original hbml file (so that it's not loaded in the configuration)&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;run the tests covering the basic CRUD operations, &lt;span style="font-style: italic;"&gt;if you have any&lt;/span&gt;, and make sure they're still green.&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;Last but not least, perform a schema compare to ensure that nothing has changed&lt;/li&gt;&lt;/ul&gt;Repeat for all hbml files!&lt;br /&gt;&lt;br /&gt;This time, that's really it! &lt;span style="font-weight: bold;"&gt;Congrats&lt;/span&gt;! If you have followed these few steps, you should have migrated all your existing hbml mappings to their fluent contra-parts. In the unlikely, yet possible event, that you are using some advanced NHibernate features which are still not supported by the fluent mapping, you can keep the hbml mapping. Remember, &lt;span style="font-weight: bold;"&gt;FluentNHibernate supports side-by-side hbml and fluent mapping&lt;/span&gt;. For the craziest among us, you can even split mapping for one entity between hbml and fluent mapping!...to use at your own risk :-)&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Happy fluent mapping!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1913176053516708798-9036863568986576080?l=blog.msevestre.ca' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.msevestre.ca/feeds/9036863568986576080/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.msevestre.ca/2010/12/migration-to-fluent-nhibernate.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1913176053516708798/posts/default/9036863568986576080'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1913176053516708798/posts/default/9036863568986576080'/><link rel='alternate' type='text/html' href='http://blog.msevestre.ca/2010/12/migration-to-fluent-nhibernate.html' title='Migration to Fluent NHibernate'/><author><name>Michael Sevestre</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1913176053516708798.post-4765164464176085418</id><published>2010-12-20T21:00:00.002-05:00</published><updated>2010-12-22T09:34:29.843-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Random numbers'/><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='distribution'/><category scheme='http://www.blogger.com/atom/ns#' term='gaussian'/><title type='text'>How to generate gaussian random numbers in .NET - Part2</title><content type='html'>&lt;div style="text-align: justify;"&gt;In one of my last &lt;a href="http://blog.msevestre.ca/2010/12/how-to-generate-gaussian-random-numbers.html"&gt;post&lt;/a&gt;, we talked about how to generate gaussian random numbers and introduced the class RandomGenerator.&lt;br /&gt;&lt;br /&gt;Let's now see how to use it and take a real life example of a variable that follows a normal distribution.&lt;br /&gt;&lt;br /&gt;According to the &lt;span style="font-style: italic;"&gt;ICRP Data 2002&lt;/span&gt;, the &lt;span style="font-weight: bold;"&gt;height &lt;/span&gt;of a 30 years old European man follows a normal distribution with a &lt;span style="font-style: italic; color: rgb(51, 51, 255);"&gt;mean of 176cm&lt;/span&gt; and a&lt;span style="font-style: italic; color: rgb(51, 51, 255);"&gt; standard deviation (std) of 8.8 cm&lt;/span&gt;. Our goal is to generate a set of random heights following this distribution.&lt;br /&gt;&lt;br /&gt;Let's first create a fairly basic NormalDistribution class that will encapsulate the behavior of the normal distribution.&lt;br /&gt;&lt;pre class="brush:csharp"&gt;&lt;br /&gt;public class NormalDistribution&lt;br /&gt;{&lt;br /&gt; private readonly double _mean;&lt;br /&gt; private readonly double _deviation;&lt;br /&gt;&lt;br /&gt; public NormalDistribution(double mean, double deviation)&lt;br /&gt; {&lt;br /&gt;    _mean = mean;&lt;br /&gt;    _deviation = deviation;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; ...&lt;br /&gt;&lt;br /&gt; public double GenerateRandomDeviate(RandomGenerator randomGenerator)&lt;br /&gt; {&lt;br /&gt;    return randomGenerator.NormalDeviate() * _deviation + _mean;&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;The only thing we need to do now is generate a few normal deviates (here 100000) and plot them in a bar chart.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush:csharp"&gt;&lt;br /&gt;var normalDistibution = new NormalDistribution(176, 8.8);&lt;br /&gt;var randomGenerator = new RandomGenerator();&lt;br /&gt;var randomNumbers = new double[100000];&lt;br /&gt;for (int i = 0; i &lt; randomNumbers.Length; i++)&lt;br /&gt;{&lt;br /&gt;  randomNumbers[i] = normalDistibution.GenerateRandomDeviate(randomGenerator);&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_g08CTwdACHU/TRAH8X6rNQI/AAAAAAAAAAg/IwSbww_zygw/s1600/heightdistribution.jpg"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 400px; height: 306px;" src="http://3.bp.blogspot.com/_g08CTwdACHU/TRAH8X6rNQI/AAAAAAAAAAg/IwSbww_zygw/s400/heightdistribution.jpg" alt="" id="BLOGGER_PHOTO_ID_5552947074341483778" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;we recognize the bell-shaped curve we were all waiting for!&lt;br /&gt;&lt;br /&gt;Hope this helps,&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1913176053516708798-4765164464176085418?l=blog.msevestre.ca' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.msevestre.ca/feeds/4765164464176085418/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.msevestre.ca/2010/12/how-to-generate-gaussian-random-numbers_14.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1913176053516708798/posts/default/4765164464176085418'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1913176053516708798/posts/default/4765164464176085418'/><link rel='alternate' type='text/html' href='http://blog.msevestre.ca/2010/12/how-to-generate-gaussian-random-numbers_14.html' title='How to generate gaussian random numbers in .NET - Part2'/><author><name>Michael Sevestre</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_g08CTwdACHU/TRAH8X6rNQI/AAAAAAAAAAg/IwSbww_zygw/s72-c/heightdistribution.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1913176053516708798.post-8239793310539361988</id><published>2010-12-16T18:25:00.002-05:00</published><updated>2010-12-16T18:52:40.257-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='code coverage'/><category scheme='http://www.blogger.com/atom/ns#' term='continuous integration'/><title type='text'>I tried dotCover and I love it!</title><content type='html'>&lt;div style="text-align: justify;"&gt;We've been using code coverage analysis as part of our continuous integration process for a while now. The tool of choice thus far was the free version of &lt;a href="http://www.ncover.com/"&gt;NCover&lt;/a&gt;. I decided to try the new coverage tool '&lt;span style="font-weight: bold;"&gt;dotCover&lt;/span&gt;' from Jetbrain. You can download a 30 day trial version &lt;a href="http://www.jetbrains.com/dotcover/"&gt;here&lt;/a&gt;. So far I am really pleased with the product:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;The integration in Visual Studio (2008 and 2010) as well as in Resharper test runner is, as always with Jetbrain, flawless.&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;An new interesting feature that was not availale in NCover (at least in the free version): you can navigate from a certain piece of code to the tests covering that code.&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;Being a huge keyboard freak, I am happy to see that shortcuts are available: &lt;span style="font-style: italic;"&gt;ALT + R + U + O &lt;/span&gt;starts a test in coverage mode, while &lt;span style="font-style: italic;"&gt;ALT + R + U + R&lt;/span&gt;  starts the Resharper runner for a given test.&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;Last but not least: It's also possible to use dotCover with Continuous Integration: A console runner is available that runs coverage reports from the command line so that you can start the tool from your rake, NAnt, MSBuild, you-name-it script. If you are using the newer version of TeamCity (Version 6 as of today) the &lt;a href="http://blogs.jetbrains.com/dotnet/tag/dotcover/"&gt;integration&lt;/a&gt; is already there, as TeamCity includes a bundled version of dotCover out of the box.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;All in all a really good product. I am a fan of Resharper and dotTrace and I believe dotCover is the natural extension to my toolbox.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1913176053516708798-8239793310539361988?l=blog.msevestre.ca' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.msevestre.ca/feeds/8239793310539361988/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.msevestre.ca/2010/12/i-tried-dotcover-and-i-love-it.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1913176053516708798/posts/default/8239793310539361988'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1913176053516708798/posts/default/8239793310539361988'/><link rel='alternate' type='text/html' href='http://blog.msevestre.ca/2010/12/i-tried-dotcover-and-i-love-it.html' title='I tried dotCover and I love it!'/><author><name>Michael Sevestre</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1913176053516708798.post-3564744663644522236</id><published>2010-12-14T20:48:00.000-05:00</published><updated>2010-12-14T20:56:45.699-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Random numbers'/><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='distribution'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><category scheme='http://www.blogger.com/atom/ns#' term='gaussian'/><title type='text'>How to generate gaussian random numbers in .NET - Part1</title><content type='html'>&lt;div style="text-align: justify;"&gt;A pompous blog title for a subject that comes up in my projects much more frequently than I would have ever expected.&lt;br /&gt;&lt;br /&gt;Our goal is to generate a series of random numbers based on a &lt;a href="http://en.wikipedia.org/wiki/Normal_distribution"&gt;given Gaussian (normal) distribution&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;There are few good mathematical methods available to achieve this goal. There is one however, that has proven to be fast, stable and reliable called the &lt;a href="http://en.wikipedia.org/wiki/Box%E2%80%93Muller_transform"&gt;Box-Muller transformation&lt;/a&gt;. It allows to transform some uniformly distributed random variables, into a new set of normally distributed random variables. I will not go into the algorithmic details of the transformation, since it has been described thoroughly &lt;a href="http://mathworld.wolfram.com/Box-MullerTransformation.html"&gt;here&lt;/a&gt; or &lt;a href="http://en.wikipedia.org/wiki/Box%E2%80%93Muller_transform"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Good implementation of that method for .NET is however hard to find! Here is one in C# that is adapted from the C implementation in &lt;a href="http://www.nrbook.com/c/"&gt;Numerical Recipes&lt;/a&gt; page 289.&lt;br /&gt;&lt;/div&gt;&lt;pre class="brush:csharp"&gt;&lt;br /&gt;public class RandomGenerator&lt;br /&gt;{&lt;br /&gt;   private readonly Random _random;&lt;br /&gt;&lt;br /&gt;   //indicates that an extra deviates was already calculated&lt;br /&gt;   private bool _hasAnotherDeviate;&lt;br /&gt;&lt;br /&gt;   //The other deviate calculated using the Box-Muller transformation&lt;br /&gt;   private double _otherGaussianDeviate;&lt;br /&gt;&lt;br /&gt;   public RandomGenerator() : this(new Random())&lt;br /&gt;   {&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   public RandomGenerator(int seed) : this(new Random(seed))&lt;br /&gt;   {&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   public RandomGenerator(Random random)&lt;br /&gt;   {&lt;br /&gt;      _random = random;&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   // returns a normally distributed deviate with zero mean and unit variance.&lt;br /&gt;   // Adapted from Numerical Recipe page 289: Normal (Gaussian) Deviates&lt;br /&gt;   public double NormalDeviate()&lt;br /&gt;   {&lt;br /&gt;      double rsq, v1, v2;&lt;br /&gt;      if (_hasAnotherDeviate)&lt;br /&gt;      {&lt;br /&gt;         //we have an extra deviate handy. Reset the flag and return it&lt;br /&gt;         _hasAnotherDeviate = false;&lt;br /&gt;         return _otherGaussianDeviate;&lt;br /&gt;      }&lt;br /&gt;      do&lt;br /&gt;      {&lt;br /&gt;         v1 = UniformDeviate(-1, 1); //pick two uniform number&lt;br /&gt;         v2 = UniformDeviate(-1, 1); //in the square extending from -1 to +1&lt;br /&gt;         rsq = v1 * v1 + v2 * v2;    //see if they are in the unit circle&lt;br /&gt;      } while (rsq &gt;= 1.0 || rsq == 0.0);&lt;br /&gt;&lt;br /&gt;      //now make the box-muller transformation to get two normal deviates.&lt;br /&gt;      double fac = Math.Sqrt(-2.0 * Math.Log(rsq) / rsq);&lt;br /&gt;      //Return one and save one for next time&lt;br /&gt;      _otherGaussianDeviate = v1 * fac;&lt;br /&gt;      _hasAnotherDeviate = true;&lt;br /&gt;      return v2 * fac;&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   // Returns a uniformly distributed random number between min and max.&lt;br /&gt;   public double UniformDeviate(double min, double max)&lt;br /&gt;   {&lt;br /&gt;      return (max - min) * _random.NextDouble() + min;&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   // Returns a random number between 0 and 1&lt;br /&gt;   public double NextDouble()&lt;br /&gt;   {&lt;br /&gt;      return _random.NextDouble();&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;This class encapsulates the generation of random uniform deviates as well as random normal deviates and has proven to be really handy.&lt;br /&gt;&lt;br /&gt;In the next post, we will use the &lt;span style="font-weight: bold;"&gt;RandomGenerator &lt;/span&gt;on a real life example and generate a ton of Gaussian random numbers....sounds like fun :-)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;Nitpicker corner:&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic;font-size:85%;" &gt;I am actually talking here about "pseudo-random" number, as the sequence of generated numbers is deterministic given the pseudo-random generator algorithm and the seed value used to initialize the generator. So be advised, that when I use "random" in this article, I actually mean "pseudo-random".&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1913176053516708798-3564744663644522236?l=blog.msevestre.ca' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.msevestre.ca/feeds/3564744663644522236/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.msevestre.ca/2010/12/how-to-generate-gaussian-random-numbers.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1913176053516708798/posts/default/3564744663644522236'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1913176053516708798/posts/default/3564744663644522236'/><link rel='alternate' type='text/html' href='http://blog.msevestre.ca/2010/12/how-to-generate-gaussian-random-numbers.html' title='How to generate gaussian random numbers in .NET - Part1'/><author><name>Michael Sevestre</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1913176053516708798.post-1481895214006051247</id><published>2010-12-08T15:46:00.000-05:00</published><updated>2010-12-10T12:46:03.396-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='DevExpress'/><title type='text'>Don't be fooled by the RealColumnEdit in a DevExpress GridView</title><content type='html'>&lt;div style="text-align: justify;"&gt;We are making heavy use of the DevExpress Components Suite for our Desktop applications. Today I stumbled upon a really weird behaviour in the GridColumn object that I wanted to share. It might help someone out there!&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Context:&lt;/span&gt;&lt;br /&gt;When binding a GridView to an object, let say a DataTable with 3 Columns, the fabulous databinding mechanism (note the sarcasm here) fills up the grid view automatically. Sweet. You don't have to specify anything and you even get for the same price a default editor for each column automatically assigned. Even better.&lt;br /&gt;&lt;br /&gt;Let's take a look at some simple code to illustrate the problem at hand:&lt;br /&gt;&lt;pre class="brush:csharp"&gt;&lt;br /&gt;public partial class Form1 : Form&lt;br /&gt;  {&lt;br /&gt;     private readonly DataTable _dataTable;&lt;br /&gt;&lt;br /&gt;     public Form1()&lt;br /&gt;      {&lt;br /&gt;         InitializeComponent();&lt;br /&gt;&lt;br /&gt;         //create table&lt;br /&gt;         _dataTable = new DataTable();&lt;br /&gt;         _dataTable.Columns.Add(new DataColumn("double", typeof(double)));&lt;br /&gt;         _dataTable.Columns.Add(new DataColumn("int", typeof(int)));&lt;br /&gt;         _dataTable.Columns.Add(new DataColumn("bool", typeof(bool)));&lt;br /&gt;         _dataTable.Columns.Add(new DataColumn("date", typeof(DateTime)));&lt;br /&gt;         _dataTable.Columns.Add(new DataColumn("text", typeof(string)));&lt;br /&gt;         //add a few rows&lt;br /&gt;         AddData(1.1,1,true,new DateTime(2010,01,01),"hello");&lt;br /&gt;         AddData(2.2,2,false,new DateTime(2010,02,02),"bonjour");&lt;br /&gt;         AddData(3.3,3,true,new DateTime(2010,03,03),"guten tag");&lt;br /&gt;         //bind to grid&lt;br /&gt;         gridControl1.DataSource = _dataTable;&lt;br /&gt;      }&lt;br /&gt;&lt;br /&gt;     public void AddData(double value0, int value1, bool value2, DateTime value3,string value4)&lt;br /&gt;      {&lt;br /&gt;         var row = _dataTable.NewRow();&lt;br /&gt;         row[0] = value0;&lt;br /&gt;         row[1] = value1;&lt;br /&gt;         row[2] = value2;&lt;br /&gt;         row[3] = value3;&lt;br /&gt;         row[4] = value4;&lt;br /&gt;         _dataTable.Rows.Add(row);&lt;br /&gt;      }&lt;br /&gt;  }&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;These few lines of code and we get a nice grid with already some built-in editors:&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_g08CTwdACHU/TP_5fw3Le-I/AAAAAAAAAAM/uMT5jJJroqU/s1600/RealColumnEdit.jpg"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 320px; height: 160px;" src="http://4.bp.blogspot.com/_g08CTwdACHU/TP_5fw3Le-I/AAAAAAAAAAM/uMT5jJJroqU/s320/RealColumnEdit.jpg" alt="" id="BLOGGER_PHOTO_ID_5548427590031342562" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Problem:&lt;/span&gt;&lt;br /&gt;Now comes the tricky part. According to the &lt;a href="http://documentation.devexpress.com/#WindowsForms/DevExpressXtraGridColumnsGridColumn_RealColumnEdittopic"&gt;documentation&lt;/a&gt;, if a repository item is assigned to the ColumnEdit property, &lt;span style="font-weight: bold;"&gt;RealColumnEdit &lt;/span&gt;returns this repository item. Otherwise it returns the &lt;span style="font-weight: bold;"&gt;default edit&lt;/span&gt; with respect to the column type.&lt;br /&gt;&lt;br /&gt;What the documentation does not say, is that the &lt;span style="font-style:italic;"&gt;default edit&lt;/span&gt; is actually the same &lt;span style="font-style: italic;"&gt;instance&lt;/span&gt; of the editor with respect to the column type.In our example, the double, int and text column would actually be assigned the same instance of the editor. If you start to define some behavior to one of the assigned editor, you might get some weird bugs in your application.&lt;br /&gt;&lt;br /&gt;Let say I decide to ensure that only numerical values can be entered in the double column. (index 0)&lt;br /&gt;I could do that by simply defining a mask to the editor&lt;br /&gt;&lt;pre class="brush:csharp"&gt;&lt;br /&gt;var editor = (RepositoryItemTextEdit) gridView1.Columns[0].RealColumnEdit;&lt;br /&gt;editor.Mask.MaskType = MaskType.Numeric;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;It works fine for the double column. However the last column, which is sharing the same instance of the RealColumnEdit, only accepts numerical values as well!!&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_g08CTwdACHU/TQJg0DxhxMI/AAAAAAAAAAU/UVDeDLhzpRk/s1600/RealColumnEditBug.jpg"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 320px; height: 77px;" src="http://2.bp.blogspot.com/_g08CTwdACHU/TQJg0DxhxMI/AAAAAAAAAAU/UVDeDLhzpRk/s320/RealColumnEditBug.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5549104138356376770" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Solution:&lt;/span&gt;&lt;br /&gt;When assigning special behavior to column editors, never use the RealColumnEdit. Instead, specify a new instance of the required editor by setting the property ColumnEditor and you will be good to go&lt;br /&gt;&lt;pre class="brush:csharp"&gt;&lt;br /&gt;var editor = new RepositoryItemTextEdit();&lt;br /&gt;gridView1.Columns[0].ColumnEdit = editor;&lt;br /&gt;editor.Mask.MaskType =MaskType.Numeric;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Hope this helps,&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1913176053516708798-1481895214006051247?l=blog.msevestre.ca' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.msevestre.ca/feeds/1481895214006051247/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.msevestre.ca/2010/12/dont-be-fooled-by-realcolumnedit-in.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1913176053516708798/posts/default/1481895214006051247'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1913176053516708798/posts/default/1481895214006051247'/><link rel='alternate' type='text/html' href='http://blog.msevestre.ca/2010/12/dont-be-fooled-by-realcolumnedit-in.html' title='Don&apos;t be fooled by the RealColumnEdit in a DevExpress GridView'/><author><name>Michael Sevestre</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_g08CTwdACHU/TP_5fw3Le-I/AAAAAAAAAAM/uMT5jJJroqU/s72-c/RealColumnEdit.jpg' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1913176053516708798.post-6731476650400763864</id><published>2010-12-05T20:33:00.000-05:00</published><updated>2010-12-14T15:44:38.496-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='svn'/><category scheme='http://www.blogger.com/atom/ns#' term='continuous integration'/><title type='text'>How to Move a Subversion Repository to Another Server</title><content type='html'>Today I had to mirror our svn repository to another server. The task has been luckily made really simple by the svn team (thanx guys!):&lt;br /&gt;&lt;br /&gt;Here is the procedure to follow:&lt;br /&gt;&lt;ul style="font-weight: bold;"&gt;&lt;li&gt;Create a dump of the old repository&lt;/li&gt;&lt;/ul&gt;The best way to do it is to use the tool svnadmin in the console&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;br /&gt;svnadmin dump old_repository_path &gt; repository.svn_dump&lt;br /&gt;example: svnadmin dump c:\dev\svnrepos &gt; repository.svn_dump&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: left; font-weight: bold;"&gt;&lt;ul&gt;&lt;li&gt;Create a new repository on the new server&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;br /&gt;svnadmin create path_to_new_repository&lt;br /&gt;example: svnadmin create d:\dev\svnrepos&lt;br /&gt;&lt;div style="text-align: left;"&gt;&lt;ul style="font-weight: bold;"&gt;&lt;li&gt;Import the backup repository into the newly created repository&lt;/li&gt;&lt;/ul&gt;&lt;div style="text-align: center;"&gt;&lt;br /&gt;svnadmin load path_to_new_repository &lt; repository.svn_dump&lt;br /&gt;example: svnadmin load d:\dev\svnrepos &lt; repository.svn_dump&lt;br /&gt;&lt;div style="text-align: left;"&gt;That's pretty much it.  Hope this helps!&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Note: &lt;/span&gt;To avoid any conflict during the process, make sure that none of your team mate is updating the old repository while creating the new repository...&lt;br /&gt;&lt;br /&gt;Till next time,&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1913176053516708798-6731476650400763864?l=blog.msevestre.ca' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1913176053516708798/posts/default/6731476650400763864'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1913176053516708798/posts/default/6731476650400763864'/><link rel='alternate' type='text/html' href='http://blog.msevestre.ca/2008/12/how-to-move-subversion-repository-to.html' title='How to Move a Subversion Repository to Another Server'/><author><name>Michael Sevestre</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry></feed>
