C#

Everything regarding NET Technologies with C# language.

NHibernate cache system. Part 1

31 December 2011 |

In this series of articles I will try to explain you how NHibernate cache system works and how it should be used in order to get the best performance/configuration from this product. Introduction  Architecture Cache Level 1 mechanism Load and Get, what’s the difference Session maintenance: Evict, Flush and Clear 2nd Level Cache...

NHibernate cache system. Part 2

31 December 2011 |

In the previous post we saw how the cache system is structured in NHibernate and how it works. We saw that we have different methods to play with the cache (Evict, Clear, Flush …) and they are all associated with the ISession object because the cache of level 1 is associated with the lifecycle of an ISession object. In this second article we will see how the second level cache works and how it is associated with the ISessionFactory object that is in charge of controlling this cache mechanism. Second Level cache architecture How does the second...

NHibernate cache system. Part 3

31 December 2011 |

In this series of articles we saw how the cache system is implemented in NHibernate and what can we do in order to use it. We also saw that we can choose a cache provider but we didn’t have a look yet at what providers we can use. I personally have my own opinion about the 2nd level cache providers available for NHibernate 3.2 and I am more than happy if you would like to share with me your experience about it. Below is a list of the major and the most famous 2nd level cache providers I...

Sharing assembly version in Visual Studio 2010.

11 December 2011 |

Last week I came up with a fancy requirement that forced me to struggle a little bit in order to find an appropriate solution. Let’s say that we have a massive solution file, containing something like 100ish projects and we would like to keep the same assembly version number for all these projects. In this article I will show you how the assembly version number works in .NET and what are the possible solutions, using Visual Studio. Assembly version in .NET As soon as you add a new project (of any type) in Visual Studio 2010, you...

Speaking about WPF in Bermuda.

11 July 2011 |

Last year in Bermuda we had a new born, a NET community. The community has been created by some locals companies to attract developers, architects and analyst; but also anybody passionate of development. You can check-out the web site here: http://www.dnug.bm/. This month I will have the opportunity to present my two books: Applied WPF in context (APRESS) Build enterprise application with WPF and MVVM (MS PRESS) and to talk about WPF/Silverlight. During this event I will explain what are...

TypeMock tutorial #03. Control behaviors.

01 July 2011 |

Note for purists: In this tutorial I am showing you a simplified example of a Unit of Work and a Repository, please do not care about the complexity or simplicity of these objects but look at the TypeMock implementations. We are now at the third post of this series and I found out that there are a lot of readers interested in learning TypeMock, which means that series will have to continue! Last time, we have created some object’s mocks using TypeMock but they were simple Value Objects with nothing or very few business logic in it....

TypeMock tutorial #02. Object creation.

25 June 2011 |

In this new  part of the TypeMock series I am going to show you how to deal with objects and classes in general, how you can create them and what are (honestly aren’t) the limit of TypeMock on dealing with objects. First of all I have just drawn down a little domain that I have added to the demo application. I am planning to upload this demo the next week on Codeplex.com so that every geek reading this blog can just go there and download the source code. The Demo domain The domain is a very simple...

TypeMock tutorial #01. Startup.

17 June 2011 |

The best way to learn a tool is to try it, test it and then finally use it over your code. Of course if the tool provides also a great community support and a great documentation the task will be easier. Some weeks ago we started to adopt a wonderful tool to create mockups and other TDD fancy stuff, the tool is TypeMock. The idea I got is to create a series of tutorials about TypeMock and provide to you a piece of a code to download a full license of this tool. At the end of the...

New content for my Microsoft book

15 June 2011 |

The Microsoft’s book I have published few months ago: “Building Enterprise Applications with WPF and MVVM” has been a success but I still got some negative feedbacks that me and my editor we want to get rid off. This book is my first real book and of course it was my first experience on writing a book (for this reason we kept the price of the book very low). Anyway .. I got some bad feedbacks about missing parts, parts not explained as expected and a misunderstanding of the book audience and target. I personally believe that the...

Unity and injection with factories.

14 June 2011 |

Last week in the office I just found a bug on how I was implementing a series of Inversion of Control chain using Microsoft Unity. To be precise, the bug has been found by one of the new guy in the team, Gary McLean Hall, the author of the book “APRESS - Pro WPF and Silverlight MVVM”. Before starting with the explanation of the problem, let’s see what I am talking about. I believe that anyone of you know already concepts like “Inversion of Control” and ‘Dependency Injection”; if you don’t, just follow the links. A classic...

Applied WPF in context is out.

05 June 2011 |

During the last two months I have been away from Bermuda and I didn’t have a lot of time to write or post any news on this blog. In the meantime, I didn’t realize that my new book from APRESS: “Applied WPF 4 in context” has been published so it is time to post some info about it. The cover of the book is following the APRESS new style and it is the following one: The new series “applied in context” of APRESS deliver content by example and practical code, so in this book you...

Updates for my Microsoft Book

03 April 2011 |

After one week that my book about LOB applications has been published I started to receive some additional questions that I am trying to address in this post. First of all I want to thank all the guys and girls that are buying the book and all the people that are providing feedbacks for the book. I really appreciate. I want also to specify that the Microsoft book has not been released as a “Book about MVVM” but more as a “book to discover LOB and layered applications”. I believe that part of the misunderstanding as been caused by...

My book for Model View ViewModel (MVVM) and n-tier applications is out

22 March 2011 |

(a.k.a. Buy one copy!) Finally I am excited and glad to let you know that my first book: “Building Enterprise Applications with Windows® Presentation Foundation and the Model View ViewModel Pattern” is out and available through the major IT books distributors like: www.amazon.com, kindle, www.oReilly.com and more. Distributors Please forgive me if I am missing some of my distributors but I do not have yet the full list. The book is available through the oReilly website at this address: http://oreilly.com/catalog/0790145309686/ in the following formats: PDF, EBOOK, KINDLE and PAPERBACK (hard copy); of course the hard...

State pattern using C#. Part 02.

20 February 2011 |

In the previous post we saw how we can implement the state pattern (I know, I didn’t show you the purist way of using the State pattern …) and include in the state execution the flow logic. This technique is fine but … it requires a lot of effort in the implementation and requires a lot of maintenance, plus it has the GAP of forcing us to re-run the CanExecute delegate every time we want to execute a specific action. On the web I have found some solutions that personally didn’t satisfy me at all. I personally believe...

State pattern using C#. Part 01

13 February 2011 |

I have been busy for a while writing my two books about MVVM and WPF but I am almost done so be ready to get more posts in the next months. This one is the first of a series that I will write to solve the state pattern issue. Today I want to start to talk about the state pattern, a design pattern used to represent the state of an object and how we can apply this pattern in a normal WPF application. The problem we have is that based on the state of an Order we can...

WPf and Prism Tab Region Adapter, Part 02.

04 July 2010 |

As we saw in the previous post, it’s pretty complicate to create a custom design in WPF to override the default style of the TabControl, but it’s pretty simple to extend the behavior of it. As a senior dev, I usually don’t like to: 1) touch what is already working, 2) reinvent the wheel just to write the same code twice. For that there is the refactoring process, at most! So, let’s start by the requirement we had in the previous post, we need to emulate the VS IDE in our applications, that’s it! We also saw...

Prism and WPF. Custom Tab region adapter. Part 01.

04 July 2010 |

The second part of this tutorial is here. Enjoy! One thing that I really hate when I started working on Prism was the fact that the developers didn’t provide a nice tab region adapter. Well, the items adapter provided in Prism fits perfectly with the tab control, but if you use it “as is” it pretty sucks. I am pretty sure that as soon as you will release your first Prism “Visual Studio style” Prism application your manager will ask you for a cook tab like the one below: This is an add-in...

How to write fluent interface with C# and Lambda.

26 June 2010 |

Last week I had a nice discussion in the office about “how to write fluent interface” and I have found a couple of articles over the internet about that. As usual I disagree with some of them and, as usual, my friend Mauro Servienti (MVP C#) has a nice article about it, unfortunately in Italian. He just gave me the startup input. If you think about the Fluent Interface, it is just a trick that you use with C# in order to cheat the intellisense of Visual Studio and in order to create a nice style for your code....

Build enterprise applications with WPF, WCF, EF and Prism. Tutorial 09.

13 February 2010 |

Today we will see the modularity concept of Prism. Probably the best part of it, as it will allow us to build a real plug-and-play application where the main Shell won’t know anything about the modules. Discover and load the module. What does it mean? As we saw in the previous article, we have declared a reference in our Shell for the hello world module. In this way we force the Shell to be compiled including in the shell project a reference to the Hello World module. Fine, but what happen if we want to replace this module...

Build enterprise application with WPF, WCF, Prism and Entity Framework. Tutorial 08.

07 February 2010 |

Update: source code and documentation are now available on CodePlex at this address: http://prismtutorial.codeplex.com/ Today we will build the skeleton of our application using the latest version of Prism, available in this section of MSDN: Prism February 2009. One of the reasons that I didn't write anything concrete until now is the fact that I knew that the new version of Prism was coming this month. The classic Hello World application. As for every tutorial, is always better to start with the classic Hello World in order to understand, step by step, how...