<?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-7984833534934011506</id><updated>2012-01-19T08:09:33.520-08:00</updated><category term='Unity'/><category term='C#'/><category term='LINQ'/><category term='.net'/><category term='User Group'/><category term='Prism'/><category term='IoC'/><category term='Entity Framework'/><category term='Dependency Injection'/><category term='Book review'/><category term='Technical Review'/><category term='SQL Server'/><title type='text'>ITranscendable</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://itranscendable.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7984833534934011506/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://itranscendable.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Gustavo Cavalcanti</name><uri>http://www.blogger.com/profile/14733952116202634514</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://2.bp.blogspot.com/_ppjnAc2b4wo/SvpoFpyfnaI/AAAAAAAAFHY/75JV8M3HwhE/S220/Gus.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>12</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-7984833534934011506.post-1364533976808734581</id><published>2011-04-22T21:59:00.000-07:00</published><updated>2011-04-22T22:03:37.953-07:00</updated><title type='text'>Visual Studio 2010 SP1 - hoops to jump</title><content type='html'>&lt;span class="Apple-style-span" style="border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px; "&gt;&lt;div&gt;I have been running Visual Studio 2010 with &lt;a href="www.jetbrains.com/resharper"&gt;Resharper&lt;/a&gt; and &lt;a href="http://visualstudiogallery.msdn.microsoft.com/d0d33361-18e2-46c0-8ff2-4adea1e34fef"&gt;Productivity Power Tools extension&lt;/a&gt; in a Virtual Machine (Windows 7's &lt;a href="http://www.microsoft.com/windows/virtual-pc/"&gt;Windows Virtual PC&lt;/a&gt;). Everything has been working fine until I decided to apply &lt;a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=75568aa6-8107-475d-948a-ef22627e57a5"&gt;Visual Studio 2010 Service Pack 1&lt;/a&gt;. Here are the problems I've experienced:&lt;/div&gt;&lt;div&gt;1) To begin with, I made a mistake of running the SP1 installation "not" as an Administrator. The setup application didn't complain at all, but it ran for a loooong time (2+ hours!). It failed and rolled back fine, but it took too long. After I right-clicked, "Run as Administrator", it ran fine and finished after 20~30min.&lt;/div&gt;&lt;div&gt;2) After SP1 had been applied Visual Studio was veeery slow, even freezing at times. After some research I found that the culprit could be the Productivity Power Tools not playing well with ReSharper. I have to say that shortly before installing the SP1 I installed the latest version of the extension. After "disabling" the extension and restarting Visual Studio, everything seems to be ok, performance wise.&lt;/div&gt;&lt;div&gt;3) I experienced some flickering in Visual Studio after applying SP1 and noticed that the "Hardware Graphics Acceleration" checkbox was unchecked (Tools - Options - Visual Experience area). I set it back to checked, restarted VS and the flickering stopped... &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Hopefully this will save yout time should you have these issues as well. Enjoy normality once again.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7984833534934011506-1364533976808734581?l=itranscendable.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://itranscendable.blogspot.com/feeds/1364533976808734581/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7984833534934011506&amp;postID=1364533976808734581&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7984833534934011506/posts/default/1364533976808734581'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7984833534934011506/posts/default/1364533976808734581'/><link rel='alternate' type='text/html' href='http://itranscendable.blogspot.com/2011/04/visual-studio-2010-sp1-hoops-to-jump.html' title='Visual Studio 2010 SP1 - hoops to jump'/><author><name>Gustavo Cavalcanti</name><uri>http://www.blogger.com/profile/14733952116202634514</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://2.bp.blogspot.com/_ppjnAc2b4wo/SvpoFpyfnaI/AAAAAAAAFHY/75JV8M3HwhE/S220/Gus.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7984833534934011506.post-3108316159571931186</id><published>2009-07-28T15:36:00.000-07:00</published><updated>2010-08-25T08:49:07.593-07:00</updated><title type='text'>iTextSharp - Sending in-memory pdf in an email attachment</title><content type='html'>I was helping a client with the good old task of printing reports in a pdf format from an Asp.Net page, without having to use a commercial tool. I did a bit of research on &lt;a href="http://sourceforge.net/projects/itextsharp/"&gt;&lt;span style="font-weight: bold;"&gt;iTextSharp&lt;/span&gt;&lt;/a&gt; and it appears to do everything I need. For instance, one of my goals was to be able to create a pdf file in memory and send it as an email attachment. Here's the code I used to do that:&lt;br /&gt;(&lt;span style="font-style: italic;"&gt;In this example I use gmail as my smtp server, so it makes it easier for you to try it for yourself&lt;/span&gt;)&lt;br /&gt;&lt;pre class="scode"&gt;&lt;br /&gt;var doc = new Document();&lt;br /&gt;MemoryStream memoryStream = new MemoryStream();&lt;br /&gt;PdfWriter writer = PdfWriter.GetInstance(doc, memoryStream);&lt;br /&gt;&lt;br /&gt;doc.Open();&lt;br /&gt;doc.Add(new Paragraph("First Paragraph"));&lt;br /&gt;doc.Add(new Paragraph("Second Paragraph"));&lt;br /&gt;&lt;br /&gt;//Keeps the memoryStream object open when closing the Document (doc)&lt;br /&gt;writer.CloseStream = false;&lt;br /&gt;doc.Close();&lt;br /&gt;&lt;br /&gt;//Moves the pointer to the beginning of the stream. Without this&lt;br /&gt;//line an empty file is generated and attached to the email.&lt;br /&gt;memoryStream.Position = 0;&lt;br /&gt;&lt;br /&gt;MailMessage mm = new MailMessage("username@gmail.com",&lt;br /&gt;                                "username@gmail.com")&lt;br /&gt;{&lt;br /&gt;Subject = "subject",&lt;br /&gt;IsBodyHtml = true,&lt;br /&gt;Body = "body"&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;mm.Attachments.Add(new Attachment(memoryStream, "filename.pdf"));&lt;br /&gt;SmtpClient smtp = new SmtpClient&lt;br /&gt;{&lt;br /&gt;Host = "smtp.gmail.com",&lt;br /&gt;Port = 587,&lt;br /&gt;EnableSsl = true,&lt;br /&gt;Credentials = new NetworkCredential("username@gmail.com",&lt;br /&gt;                                    "password")&lt;br /&gt;&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;smtp.Send(mm);&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/7984833534934011506-3108316159571931186?l=itranscendable.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://itranscendable.blogspot.com/feeds/3108316159571931186/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7984833534934011506&amp;postID=3108316159571931186&amp;isPopup=true' title='10 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7984833534934011506/posts/default/3108316159571931186'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7984833534934011506/posts/default/3108316159571931186'/><link rel='alternate' type='text/html' href='http://itranscendable.blogspot.com/2009/07/itextsharp-sending-in-memory-pdf-in.html' title='iTextSharp - Sending in-memory pdf in an email attachment'/><author><name>Gustavo Cavalcanti</name><uri>http://www.blogger.com/profile/14733952116202634514</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://2.bp.blogspot.com/_ppjnAc2b4wo/SvpoFpyfnaI/AAAAAAAAFHY/75JV8M3HwhE/S220/Gus.jpg'/></author><thr:total>10</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7984833534934011506.post-42011421944193455</id><published>2009-04-17T17:31:00.001-07:00</published><updated>2009-04-17T17:37:49.879-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.net'/><category scheme='http://www.blogger.com/atom/ns#' term='Entity Framework'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server'/><title type='text'>Using views from EDM - Entity Framework</title><content type='html'>In one of my recent projects using Entity Framework/WPF I needed to have read-only data from 10+ different tables, and I decided to have a view in SQL Server, as opposed to have the joins generated from the EDM (Entity Data Model). The view exposed both nullable and non-nullable fields, including primary keys of the underlying tables. However, since I had outer joins, some of these primary keys exposed from the view could actually be null. In this scenario one must be careful and tweak the model, so that all data returned from the database can be materialized into entities.&lt;br /&gt;If I used an indexed view I wouldn't have any issues, but the query in my view had multiple self-joins, which is a limitation of indexed-views, at least in SQL Server 2005 and 2008.&lt;br /&gt;&lt;br /&gt;When a non-indexed view is added to the EDM, the framework tries to infer one of more entity keys from the database - it generates entity keys from the non-nullable fields. In the scenario described above, I had non-nullable fields (PKs) that could actually be null (because of outer joins in the view). In this case, during the enumeration of the items in the EntitySet, the data is retrieved from the database but it would not be able to be available as an Entity. In the middle of a foreach you could get an Object Null Reference exception.&lt;br /&gt;&lt;br /&gt;To fix this problem you need to find one field in your view that won't be null, set it as the Entity Key, and remove the other keys the system automatically generates. You'd be tempted to right-click on the entity's field and uncheck "Entity Key", or to go to properties and set the Entity Key property to false. You can do these things, but you'd be only affecting the conceptual model - the CSDL. This is not enough. You need to view the EDM in its XML format, and remove the unwanted keys from the Storage Model (SSDL) as well.&lt;br /&gt;&lt;br /&gt;Unfortunately, this works until you need to update the EDM from the database, which will regenerate the models and you'll lose your changes. The Entity Framework team knows about these sort of problems and will most likely try to address them shortly, whenever this may be.&lt;br /&gt;&lt;br /&gt;I hope this post can help you prevent wasted debugging time.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7984833534934011506-42011421944193455?l=itranscendable.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://itranscendable.blogspot.com/feeds/42011421944193455/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7984833534934011506&amp;postID=42011421944193455&amp;isPopup=true' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7984833534934011506/posts/default/42011421944193455'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7984833534934011506/posts/default/42011421944193455'/><link rel='alternate' type='text/html' href='http://itranscendable.blogspot.com/2009/04/using-views-from-edm-entity-framework.html' title='Using views from EDM - Entity Framework'/><author><name>Gustavo Cavalcanti</name><uri>http://www.blogger.com/profile/14733952116202634514</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://2.bp.blogspot.com/_ppjnAc2b4wo/SvpoFpyfnaI/AAAAAAAAFHY/75JV8M3HwhE/S220/Gus.jpg'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7984833534934011506.post-8798344045119568059</id><published>2008-12-30T14:24:00.000-08:00</published><updated>2008-12-31T07:36:37.282-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Book review'/><title type='text'>Windows Presentation Foundation Unleashed (WPF) by Adam Nathan</title><content type='html'>&lt;a href="http://www.amazon.com/Windows-Presentation-Foundation-Unleashed-WPF/dp/0672328917/ref=cm_cr-mr-title"&gt;&lt;/a&gt;I have read (or tried to read) other WPF books but this one is by far the easiest one to learn from, both in terms of readability (the colors really make a difference) and contents. It feels like each page has a gem of information. If I were to buy only one book about WPF, this would be the one.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7984833534934011506-8798344045119568059?l=itranscendable.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='related' href='http://www.amazon.com/Windows-Presentation-Foundation-Unleashed-WPF/dp/0672328917/ref=cm_cr-mr-title' title='Windows Presentation Foundation Unleashed (WPF) by Adam Nathan'/><link rel='replies' type='application/atom+xml' href='http://itranscendable.blogspot.com/feeds/8798344045119568059/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7984833534934011506&amp;postID=8798344045119568059&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7984833534934011506/posts/default/8798344045119568059'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7984833534934011506/posts/default/8798344045119568059'/><link rel='alternate' type='text/html' href='http://itranscendable.blogspot.com/2008/12/windows-presentation-foundation.html' title='Windows Presentation Foundation Unleashed (WPF) by Adam Nathan'/><author><name>Gustavo Cavalcanti</name><uri>http://www.blogger.com/profile/14733952116202634514</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://2.bp.blogspot.com/_ppjnAc2b4wo/SvpoFpyfnaI/AAAAAAAAFHY/75JV8M3HwhE/S220/Gus.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7984833534934011506.post-5119856640506124089</id><published>2008-12-26T09:44:00.000-08:00</published><updated>2008-12-31T08:06:37.061-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Unity'/><category scheme='http://www.blogger.com/atom/ns#' term='Dependency Injection'/><category scheme='http://www.blogger.com/atom/ns#' term='IoC'/><category scheme='http://www.blogger.com/atom/ns#' term='Prism'/><title type='text'>Unity</title><content type='html'>&lt;span style="font-family:arial;"&gt;I am trying to use the &lt;/span&gt;&lt;a style="font-family: arial;" href="http://www.codeplex.com/CompositeWPF"&gt;Composite Application Guidance&lt;/a&gt;&lt;span style="font-family:arial;"&gt; (aka Prism or Composite WPF) for an application at work. It all sounded very interesting and easy to use, but when the rubber hit the road it turned out that I needed to be educated in some of the concepts it uses. For instance, I was not familiar with &lt;a href="http://en.wikipedia.org/wiki/Dependency_injection"&gt;Dependency Injection&lt;/a&gt;. Prism uses Unity as the DI container and I thought I'd highlight some examples on how to use the Unity container:&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 204, 0); font-weight: bold;font-family:arial;" &gt;Type Mapping - registered class&lt;/span&gt;&lt;span style="color: rgb(255, 204, 0); font-weight: bold;"&gt;:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;pre class="scode"&gt;container.RegisterType&amp;#60;&lt;code&gt;IModule, ConcreteModule&lt;/code&gt;&amp;#62;&lt;imodule,&gt;&lt;imodule,&gt;();&lt;code&gt;&lt;br /&gt;IModule ModuleA = container.Resolve&lt;imodule&gt;&lt;imodule&gt;(&amp;#60;IModule&amp;#62;);&lt;/imodule&gt;&lt;/imodule&gt;&lt;/code&gt;&lt;/imodule,&gt;&lt;/imodule,&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The first line is a type mapping. Anytime you need &lt;span style="font-family:courier new;"&gt;IModule&lt;/span&gt;, the container will return a &lt;span style="font-family:courier new;"&gt;ConcreteModule&lt;/span&gt;. &lt;span style="font-family:arial;"&gt;the &lt;span style="font-family:courier new;"&gt;ModuleA &lt;/span&gt;object will have an instance of &lt;span style="font-family:courier new;"&gt;ConcreteModule&lt;/span&gt;.&lt;/span&gt;&lt;br /&gt;&lt;p style="color: rgb(255, 204, 0);"&gt;&lt;span style="font-weight: bold;font-family:arial;" &gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-weight: bold; color: rgb(255, 204, 0);font-family:arial;" &gt;Type Mapping - non-registered class:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;The following class needs an instance of IModule:&lt;/span&gt;&lt;/p&gt;&lt;pre class="scode"&gt;Class ModuleA&lt;br /&gt;{&lt;br /&gt;&amp;#32;&amp;#32;ModuleA(IModule module)&lt;br /&gt;&amp;#32;&amp;#32;{&lt;br /&gt;&amp;#32;&amp;#32;&amp;#32;&amp;#32;...&lt;br /&gt;&amp;#32;&amp;#32;}&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;Using Unity you can do the following:&lt;/span&gt;&lt;br /&gt;&lt;pre   style="border: 1px dashed rgb(153, 153, 153); padding: 5px; overflow: auto; color: rgb(255, 255, 255); background-color: rgb(0, 0, 0); line-height: 14px; width: 100%;font-family:Andale Mono,Lucida Console,Monaco,fixed,monospace;font-size:12px;"&gt;&lt;code&gt;container.RegisterType&lt;imodule,&gt;&amp;#60;&lt;/imodule,&gt;&lt;/code&gt;&lt;code&gt;IModule, ConcreteModule&lt;/code&gt;&lt;code&gt;&lt;imodule,&gt;&amp;#62;();&lt;br /&gt;ModuleA modA = container.Resolve&lt;&lt;span style="font-weight: bold;"&gt;ModuleA&lt;/span&gt;&gt;();&lt;/imodule,&gt;&lt;/code&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;The first line is a type mapping. Anytime you need IModule, the container will return a ConcreteModule.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;The second line requests a new instance of ModuleA. ModuleA is not registered with the container. But Unity will look at ModuleA's constructor and see that it needs a IModule. It will then inject an instance of ConcreteModule because of the 1st line's mapping.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 204, 0);font-family:arial;" &gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold; color: rgb(255, 204, 0);font-family:arial;" &gt;Type Mapping - Singleton&lt;/span&gt;&lt;span style="font-weight: bold; color: rgb(255, 204, 0);"&gt;:&lt;/span&gt;&lt;br /&gt;&lt;pre face="Andale Mono,Lucida Console,Monaco,fixed,monospace" size="12px" style="border: 1px dashed rgb(153, 153, 153); padding: 5px; overflow: auto; color: rgb(255, 255, 255); background-color: rgb(0, 0, 0); line-height: 14px; width: 100%;"&gt;&lt;code&gt;container.RegisterType&lt;imodule,&gt;&lt;/imodule,&gt;&lt;/code&gt;&lt;code&gt;&lt;imodule,&gt;&amp;#60;&lt;/imodule,&gt;&lt;/code&gt;&lt;code&gt;IModule, ConcreteModule&lt;/code&gt;&lt;code&gt;&lt;imodule,&gt;&amp;#62;&lt;/imodule,&gt;&lt;/code&gt;&lt;code&gt;&lt;imodule,&gt;(new ContainerControlledLifetimeManager());&lt;/imodule,&gt;&lt;/code&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;span style="font-family:arial;"&gt;Every time you ask for an new instance, the same one is returned.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold; color: rgb(255, 204, 0);font-family:arial;" &gt;Named instances&lt;/span&gt;&lt;span style="color: rgb(255, 204, 0);"&gt;:&lt;/span&gt;&lt;br /&gt;&lt;pre face="Andale Mono,Lucida Console,Monaco,fixed,monospace" size="12px" style="border: 1px dashed rgb(153, 153, 153); padding: 5px; overflow: auto; color: rgb(255, 255, 255); background-color: rgb(0, 0, 0); line-height: 14px; width: 100%;"&gt;&lt;code&gt;container.RegisterType&lt;database,&gt;&amp;#60;&lt;/database,&gt;&lt;/code&gt;&lt;code&gt;Database, SQLDatabase&lt;/code&gt;&lt;code&gt;&lt;database,&gt;&amp;#62;("Sql");&lt;br /&gt;container.RegisterType&lt;database,&gt;&amp;#60;&lt;/database,&gt;&lt;/database,&gt;&lt;/code&gt;&lt;code&gt;Database, OracleDatabase&lt;/code&gt;&lt;code&gt;&lt;database,&gt;&lt;database,&gt;&amp;#62;("Oracle");&lt;/database,&gt;&lt;/database,&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-family:courier new;"&gt;&lt;database,&gt;&lt;/database,&gt;&lt;/span&gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;span style="font-family:arial;"&gt;This will register two mappings of type Database and name these mappings for future use.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;You can access the type by the name like so:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;pre style="border: 1px dashed rgb(153, 153, 153); padding: 5px; overflow: auto; color: rgb(255, 255, 255); background-color: rgb(0, 0, 0); line-height: 14px; width: 100%; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px;"&gt;&lt;code&gt;Database db = container.Resolve&lt;database&gt;&amp;#60;Database&amp;#62;("Sql");&lt;/database&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-family:courier new;"&gt;&lt;database&gt;&lt;/database&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/span&gt;&lt;span style="font-family:arial;"&gt;In this case, db will be a SQLDatabase.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 204, 0); font-weight: bold;font-family:arial;" &gt;Resolving all named instances&lt;/span&gt;&lt;br /&gt;&lt;pre style="border: 1px dashed rgb(153, 153, 153); padding: 5px; overflow: auto; color: rgb(255, 255, 255); background-color: rgb(0, 0, 0); line-height: 14px; width: 100%; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px;"&gt;&lt;code&gt;container.RegisterType&amp;#60;&lt;/code&gt;&lt;code&gt;Database, SQLDatabase&lt;/code&gt;&lt;code&gt;&amp;#62;&lt;database,&gt;("Sql");&lt;br /&gt;container.RegisterType&lt;database,&gt;&amp;#60;&lt;/database,&gt;&lt;/database,&gt;&lt;/code&gt;&lt;code&gt;Database, OracleDatabase&lt;/code&gt;&lt;code&gt;&lt;database,&gt;&lt;database,&gt;&amp;#62;("Oracle");&lt;br /&gt;IEnumerable&amp;#60;&lt;/database,&gt;&lt;/database,&gt;&lt;/code&gt;&lt;code&gt;Database&lt;/code&gt;&lt;code&gt;&lt;database,&gt;&lt;database,&gt;&amp;#62;&lt;database&gt; databases = container.ResolveAll&amp;#60;&lt;/database&gt;&lt;/database,&gt;&lt;/database,&gt;&lt;/code&gt;&lt;code&gt;Database&lt;/code&gt;&lt;code&gt;&lt;database,&gt;&lt;database,&gt;&lt;database&gt;&amp;#62;&lt;database&gt;();&lt;/database&gt;&lt;/database&gt;&lt;/database,&gt;&lt;/database,&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-family:courier new;"&gt;&lt;database&gt;&lt;database&gt;&lt;/database&gt;&lt;/database&gt;&lt;/span&gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;span style="font-family:arial;"&gt;The object databases will contain two objects; one of type SQLDatabase and one of type OracleDatabase.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 204, 0);font-family:arial;" &gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 204, 0); font-weight: bold;font-family:arial;" &gt;Adding instances to the container&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;Use container.RegisterInstance to add pre-created objects to the container. Unity assumes that these objects are to be kept as singleton.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;pre style="border: 1px dashed rgb(153, 153, 153); padding: 5px; overflow: auto; color: rgb(255, 255, 255); background-color: rgb(0, 0, 0); line-height: 14px; width: 100%; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px;"&gt;&lt;code&gt;container.RegisterInstance&lt;database&gt;&amp;#60;Database&amp;#62;(new SQLDatabase());&lt;br /&gt;container.RegisterInstance&lt;database&gt;&amp;#60;Database&amp;#62;("Oracle", new OracleDatabase());&lt;/database&gt;&lt;/database&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-family:courier new;"&gt;&lt;database&gt;&lt;/database&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold; color: rgb(255, 204, 0);font-family:arial;" &gt;Adding dependencies to pre-existing objects with attributes&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;&lt;br /&gt;Assume the following class:&lt;/span&gt;&lt;br /&gt;&lt;pre style="border: 1px dashed rgb(153, 153, 153); padding: 5px; overflow: auto; color: rgb(255, 255, 255); background-color: rgb(0, 0, 0); line-height: 14px; width: 100%; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px;"&gt;&lt;code&gt;&lt;span style="font-family:courier new;"&gt;public class ModuleA: Module&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&amp;#32;&amp;#32;[Dependency]&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&amp;#32;&amp;#32;public IModuleInfo ModuleInfo {get; set; }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;In this case, &lt;span style="font-family:courier new;"&gt;ModuleA &lt;/span&gt;has &lt;span style="font-family:courier new;"&gt;IModuleInfo &lt;/span&gt;as a dependency.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;Below we're registering the &lt;span style="font-family:courier new;"&gt;IModuleInfo &lt;/span&gt;type with the container, instantiating a new &lt;span style="font-family:courier new;"&gt;ModuleA&lt;/span&gt; and asking Unity to add dependencies to the object:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;pre style="border: 1px dashed rgb(153, 153, 153); padding: 5px; overflow: auto; color: rgb(255, 255, 255); background-color: rgb(0, 0, 0); line-height: 14px; width: 100%; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px;"&gt;&lt;code&gt;container.RegisterType&lt;imoduleinfo,&gt;&amp;#60;&lt;/imoduleinfo,&gt;&lt;/code&gt;&lt;code&gt;IModuleInfo, TISModuleInfo&lt;/code&gt;&lt;code&gt;&lt;imoduleinfo,&gt;&amp;#62;();&lt;br /&gt;ModuleA modA = new ModuleA();&lt;br /&gt;container.BuildUp(modA);&lt;/imoduleinfo,&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-family:courier new;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;&lt;span style="font-family:courier new;"&gt;modA &lt;/span&gt;will then get an instance of &lt;span style="font-family:courier new;"&gt;TISModuleInfo &lt;/span&gt;in its &lt;span style="font-family:courier new;"&gt;ModuleInfo &lt;/span&gt;property.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 204, 0);font-family:arial;" &gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold; color: rgb(255, 204, 0);font-family:arial;" &gt;Specifying dependencies through configuration (no attributes)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;Assume the following class:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;pre style="border: 1px dashed rgb(153, 153, 153); padding: 5px; overflow: auto; color: rgb(255, 255, 255); background-color: rgb(0, 0, 0); line-height: 14px; width: 100%; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px;"&gt;&lt;code&gt;&lt;span style="font-family:courier new;"&gt;public class GenericDatabase: Database&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    private string connectionString;&lt;/span&gt;&lt;br /&gt;&lt;span style=";font-family:Verdana;font-size:85%;"  &gt;&lt;b&gt;    &lt;/b&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;  public ILogger Logger { get; set; }&lt;/span&gt;&lt;br /&gt;&lt;span style=";font-family:Verdana;font-size:85%;"  &gt;&lt;b&gt;    &lt;/b&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;  public GenericDatabase(string connectionString)&lt;/span&gt;&lt;br /&gt;&lt;span style=";font-family:Verdana;font-size:85%;"  &gt;&lt;b&gt;    &lt;/b&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;  {&lt;/span&gt;&lt;br /&gt;&lt;span style=";font-family:Verdana;font-size:85%;"  &gt;&lt;b&gt; &lt;/b&gt;&lt;/span&gt;&lt;span style=";font-family:Verdana;font-size:85%;"  &gt;&lt;b&gt; &lt;/b&gt;&lt;/span&gt;&lt;span style=";font-family:Verdana;font-size:85%;"  &gt;&lt;b&gt; &lt;/b&gt;&lt;/span&gt;&lt;span style=";font-family:Verdana;font-size:85%;"  &gt;&lt;b&gt; &lt;/b&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;      this.connectionString = connectionString;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    &lt;/span&gt;&lt;span style="font-family:courier new;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;pre style="border: 1px dashed rgb(153, 153, 153); padding: 5px; overflow: auto; color: rgb(255, 255, 255); background-color: rgb(0, 0, 0); line-height: 14px; width: 100%; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px;"&gt;&lt;code&gt;container.RegisterType&lt;ilogger,&gt;&amp;#60;&lt;/ilogger,&gt;&lt;/code&gt;&lt;code&gt;ILogger, NullLogger&lt;/code&gt;&lt;code&gt;&lt;ilogger,&gt;&amp;#62;();&lt;br /&gt;container.RegisterType&amp;#60;&lt;/ilogger,&gt;&lt;/code&gt;&lt;code&gt;Database, GenericDatabase&lt;/code&gt;&lt;code&gt;&lt;ilogger,&gt;&amp;#62;&lt;database,&gt;();&lt;br /&gt;string connStrFromAppConfig = ConfigurationManager.ConnectionStrings["MyConnectionString"];&lt;br /&gt;container.Configure&amp;#60;&lt;/database,&gt;&lt;/ilogger,&gt;&lt;/code&gt;&lt;code&gt;InjectedMembers&lt;/code&gt;&lt;code&gt;&lt;ilogger,&gt;&lt;database,&gt;&amp;#62;&lt;injectedmembers&gt;().ConfigureInjectionFor&lt;genericdatabase&gt;&amp;#60;GenericDatabase&amp;#62;( new InjectionConstructor(connStrFromAppConfig), new InjectionProperty("Logger"));&lt;br /&gt;Database db = container.Resolve&amp;#60;Database&amp;#62;&lt;database&gt;();&lt;br /&gt;container.RegisterInstance&amp;#60;Database&amp;#62;&lt;database&gt;("Oracle", new OracleDatabase());&lt;/database&gt;&lt;/database&gt;&lt;/genericdatabase&gt;&lt;/injectedmembers&gt;&lt;/database,&gt;&lt;/ilogger,&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-family:courier new;"&gt;&lt;database&gt;&lt;/database&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;Here we're injecting dependencies through the Configure method of the container. Since the connection string is constructor parameter, we must use the &lt;span style="font-family:courier new;"&gt;InjectionConstructor &lt;/span&gt;class, and because Logger is just a property in &lt;span style="font-family:courier new;"&gt;GenericDatabase&lt;/span&gt;, we use the &lt;span style="font-family:courier new;"&gt;InjectionProperty &lt;/span&gt;class.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 204, 0); font-weight: bold;font-family:arial;" &gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 204, 0); font-weight: bold;font-family:arial;" &gt;Nested containers&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;If the child container doesn't have what you're asking from it, it will look at the parent container.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;To register child containers:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;pre face="Andale Mono,Lucida Console,Monaco,fixed,monospace" size="12px" style="border: 1px dashed rgb(153, 153, 153); padding: 5px; overflow: auto; color: rgb(255, 255, 255); background-color: rgb(0, 0, 0); line-height: 14px; width: 100%;"&gt;&lt;code&gt;&lt;span style="font-family:courier new;"&gt;UnityContainer parent = new UnityContainer();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;IUnityContainer child1 = parent.CreateChildContainer();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;IUnityContainer child2 = parent.CreateChildContainer();&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/code&gt;&lt;code&gt;parent.RegisterType&lt;imodule,&gt;&amp;#60;&lt;/imodule,&gt;&lt;/code&gt;&lt;code&gt;IModule, GenericModule&lt;/code&gt;&lt;code&gt;&lt;imodule,&gt;&amp;#62;(new ContainerControlledLifetimeManager());&lt;br /&gt;child1.RegisterType&lt;imodule,&gt;&amp;#60;&lt;/imodule,&gt;&lt;/imodule,&gt;&lt;/code&gt;&lt;code&gt;IModule, ModuleA&lt;/code&gt;&lt;code&gt;&lt;imodule,&gt;&lt;imodule,&gt;&amp;#62;(new ContainerControlledLifetimeManager());&lt;br /&gt;&lt;br /&gt;IModule module1 = child1.Resolve&lt;imodule&gt;&amp;#60;IModule&amp;#62;();&lt;br /&gt;IModule module2 = child2.Resolve&lt;imodule&gt;&amp;#60;IModule&amp;#62;();&lt;/imodule&gt;&lt;/imodule&gt;&lt;/imodule,&gt;&lt;/imodule,&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-family:courier new;"&gt;&lt;imodule&gt;&lt;/imodule&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;In the code above, module1 will be of type &lt;span style="font-family:courier new;"&gt;ModuleA&lt;/span&gt;, and &lt;span style="font-family:courier new;"&gt;module2 &lt;/span&gt;will be of type &lt;span style="font-family:courier new;"&gt;GenericModule&lt;/span&gt;, since &lt;span style="font-family:courier new;"&gt;child2 &lt;/span&gt;looks at the parent container because it doesn't have the type &lt;span style="font-family:courier new;"&gt;IModule&lt;/span&gt; registered. &lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7984833534934011506-5119856640506124089?l=itranscendable.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='related' href='http://www.codeplex.com/unity' title='Unity'/><link rel='replies' type='application/atom+xml' href='http://itranscendable.blogspot.com/feeds/5119856640506124089/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7984833534934011506&amp;postID=5119856640506124089&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7984833534934011506/posts/default/5119856640506124089'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7984833534934011506/posts/default/5119856640506124089'/><link rel='alternate' type='text/html' href='http://itranscendable.blogspot.com/2008/12/unity.html' title='Unity'/><author><name>Gustavo Cavalcanti</name><uri>http://www.blogger.com/profile/14733952116202634514</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://2.bp.blogspot.com/_ppjnAc2b4wo/SvpoFpyfnaI/AAAAAAAAFHY/75JV8M3HwhE/S220/Gus.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7984833534934011506.post-2298466906066404674</id><published>2008-03-25T11:46:00.000-07:00</published><updated>2008-03-25T12:53:16.719-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><category scheme='http://www.blogger.com/atom/ns#' term='LINQ'/><title type='text'>Object Initializers and LINQ</title><content type='html'>&lt;span style=";font-family:arial;font-size:100%;"  &gt;&lt;br /&gt;I first saw the &lt;a href="http://msdn2.microsoft.com/en-us/vcsharp/aa336745.aspx"&gt;C#3.0&lt;/a&gt;'s "object initializers" in March 2007, at the &lt;a href="http://mvp.support.microsoft.com/MVPsummit"&gt;Microsoft MVP Summit&lt;/a&gt; in Redmond, WA. The feature didn't strike me as a big deal. Ok, you can save lots of lines of code&lt;/span&gt; &lt;span style=";font-family:arial;font-size:100%;"  &gt;and make your code more readable, but I thought, that's about it.&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:arial;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:arial;font-size:100%;"  &gt;&lt;br /&gt;After some time learning about LINQ, lambda expressions, expression trees, etc, I now realize that object initializers are a fundamental and important part of C# 3.0.&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:arial;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:arial;font-size:100%;"  &gt;They aren't just syntactical sugar. &lt;/span&gt; &lt;span style=";font-family:arial;font-size:100%;"  &gt;Take a look at an example:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=";font-family:arial;font-size:100%;"  &gt;Class Person is a plain old class:&lt;/span&gt;&lt;br /&gt;&lt;span style=";font-family:arial;font-size:100%;"  &gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 204, 102);font-family:courier new;font-size:130%;"  &gt;    public class Person&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 204, 102);font-family:courier new;font-size:130%;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 204, 102);font-family:courier new;font-size:130%;"  &gt;    {&lt;/span&gt;&lt;span style="color: rgb(255, 204, 102);font-family:courier new;font-size:130%;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 204, 102);font-family:courier new;font-size:130%;"  &gt;        public string FName { get; set; }&lt;/span&gt;&lt;span style="color: rgb(255, 204, 102);font-family:courier new;font-size:130%;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 204, 102);font-family:courier new;font-size:130%;"  &gt;        public string Country { get; set; }&lt;/span&gt;&lt;span style="color: rgb(255, 204, 102);font-family:courier new;font-size:130%;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 204, 102);font-family:courier new;font-size:130%;"  &gt;    }&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;span style="font-family:arial;"&gt;Before C# 3.0, in order to create a list of Person and populate with 5 new Person with the properties initialized, I would have do the following:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;&lt;br /&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(255, 204, 102);font-family:courier new;font-size:100%;"  &gt;            List&lt;person&gt; people = new List&lt;person&gt;();&lt;/person&gt;&lt;/person&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 204, 102);font-family:courier new;font-size:100%;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 204, 102);font-family:courier new;font-size:100%;"  &gt;            Person p1 = new Person();&lt;/span&gt;&lt;span style="color: rgb(255, 204, 102);font-family:courier new;font-size:100%;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 204, 102);font-family:courier new;font-size:100%;"  &gt;            p1.FName = "Mary";&lt;/span&gt;&lt;span style="color: rgb(255, 204, 102);font-family:courier new;font-size:100%;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 204, 102);font-family:courier new;font-size:100%;"  &gt;            p1.Country = "United States";&lt;/span&gt;&lt;span style="color: rgb(255, 204, 102);font-family:courier new;font-size:100%;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 204, 102);font-family:courier new;font-size:100%;"  &gt;            people.Add(p1);   &lt;/span&gt;&lt;span style="color: rgb(255, 204, 102);font-family:courier new;font-size:100%;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 204, 102);font-family:courier new;font-size:100%;"  &gt;            Person p2 = new Person();&lt;/span&gt;&lt;span style="color: rgb(255, 204, 102);font-family:courier new;font-size:100%;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 204, 102);font-family:courier new;font-size:100%;"  &gt;            p2.FName = "Raul";&lt;/span&gt;&lt;span style="color: rgb(255, 204, 102);font-family:courier new;font-size:100%;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 204, 102);font-family:courier new;font-size:100%;"  &gt;            p2.Country = "Argetina";&lt;/span&gt;&lt;span style="color: rgb(255, 204, 102);font-family:courier new;font-size:100%;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 204, 102);font-family:courier new;font-size:100%;"  &gt;            people.Add(p2);   &lt;/span&gt;&lt;span style="color: rgb(255, 204, 102);font-family:courier new;font-size:100%;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 204, 102);font-family:courier new;font-size:100%;"  &gt;            Person p3 = new Person();&lt;/span&gt;&lt;span style="color: rgb(255, 204, 102);font-family:courier new;font-size:100%;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 204, 102);font-family:courier new;font-size:100%;"  &gt;            p3.FName = "Sergio";&lt;/span&gt;&lt;span style="color: rgb(255, 204, 102);font-family:courier new;font-size:100%;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 204, 102);font-family:courier new;font-size:100%;"  &gt;            p3.Country = "Brazil";&lt;/span&gt;&lt;span style="color: rgb(255, 204, 102);font-family:courier new;font-size:100%;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 204, 102);font-family:courier new;font-size:100%;"  &gt;            people.Add(p3);   &lt;/span&gt;&lt;span style="color: rgb(255, 204, 102);font-family:courier new;font-size:100%;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 204, 102);font-family:courier new;font-size:100%;"  &gt;            Person p4 = new Person();&lt;/span&gt;&lt;span style="color: rgb(255, 204, 102);font-family:courier new;font-size:100%;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 204, 102);font-family:courier new;font-size:100%;"  &gt;            p4.FName = "Giuseppe";&lt;/span&gt;&lt;span style="color: rgb(255, 204, 102);font-family:courier new;font-size:100%;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 204, 102);font-family:courier new;font-size:100%;"  &gt;            p4.Country = "Italy";&lt;/span&gt;&lt;span style="color: rgb(255, 204, 102);font-family:courier new;font-size:100%;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 204, 102);font-family:courier new;font-size:100%;"  &gt;            people.Add(p4);   &lt;/span&gt;&lt;span style="color: rgb(255, 204, 102);font-family:courier new;font-size:100%;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 204, 102);font-family:courier new;font-size:100%;"  &gt;            Person p5 = new Person();&lt;/span&gt;&lt;span style="color: rgb(255, 204, 102);font-family:courier new;font-size:100%;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 204, 102);font-family:courier new;font-size:100%;"  &gt;            p5.FName = "Jean";&lt;/span&gt;&lt;span style="color: rgb(255, 204, 102);font-family:courier new;font-size:100%;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 204, 102);font-family:courier new;font-size:100%;"  &gt;            p5.Country = "France";&lt;/span&gt;&lt;span style="color: rgb(255, 204, 102);font-family:courier new;font-size:100%;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 204, 102);font-family:courier new;font-size:100%;"  &gt;            people.Add(p5);   &lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:arial;"&gt;&lt;br /&gt;With C# 3.0 we can initialize a collection of Person like so:&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 204, 102);font-family:courier new;font-size:100%;"  &gt;            var people = new List&lt;person&gt; {&lt;/person&gt;&lt;br /&gt;              new Person { FName="Mary", Country="United States" },&lt;br /&gt;              new Person { FName="Raul", Country="Argentina" },&lt;br /&gt;              new Person { FName="Sergio", Country="Brazil" },&lt;br /&gt;              new Person { FName="Giuseppe", Country="Italy" },&lt;br /&gt;              new Person { FName="Jean", Country="France" } };&lt;/span&gt;&lt;span style="font-weight: bold;font-family:courier new;font-size:100%;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;&lt;br /&gt;As you can see, using object (and collection) initializers results in a much more compact and readable code. Notice that the code in between the {} is actually an expression. Therefore, we can say that object initializers give us the "ability to initialize an object in an expression context".&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;&lt;br /&gt;Now, let's see how this feature relates to LINQ. I am assuming you know what LINQ is and have at least seen LINQ queries. The result of a LINQ query is a "projection", or in other words, it is a brand new object created on the fly. The structure of the object is really unknown, and that's the reason the "var" keyword is so important in LINQ (see Anonymous Types).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;span style=";font-family:arial;font-size:100%;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:arial;"&gt;You can project the entire object as is:&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color: rgb(255, 204, 102);font-family:courier new;font-size:130%;"  &gt;            var FrenchPeople = from p in people&lt;/span&gt;&lt;span style="color: rgb(255, 204, 102);font-family:courier new;font-size:130%;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 204, 102);font-family:courier new;font-size:130%;"  &gt;                               where p.Country == "France"&lt;/span&gt;&lt;span style="color: rgb(255, 204, 102);font-family:courier new;font-size:130%;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 204, 102);font-family:courier new;font-size:130%;"  &gt;                               select p; &lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:arial;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:arial;"&gt;Or project a completely different object. In the case below, I am projecting a string (Person's first name) preceded by "Mr. ":&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color: rgb(255, 204, 102);font-family:courier new;font-size:130%;"  &gt;            var FrenchPeople = from p in people&lt;/span&gt;&lt;span style="color: rgb(255, 204, 102);font-family:courier new;font-size:130%;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 204, 102);font-family:courier new;font-size:130%;"  &gt;                               where p.Country == "France"&lt;/span&gt;&lt;span style="color: rgb(255, 204, 102);font-family:courier new;font-size:130%;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 204, 102);font-family:courier new;font-size:130%;"  &gt;                               select "Mr. " + p.FName; &lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;When you do these projections, all you're really doing is using an "expression that creates a new object out of existing objects". &lt;o:p&gt;&lt;/o:p&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;p class="MsoNormal"  style="font-family:arial;"&gt;&lt;span style=";font-family:arial;font-size:100%;"  &gt;&lt;o:p&gt;&lt;/o:p&gt;T&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:arial;"&gt;he point I am trying to make is that, when we use expressions like these in LINQ, we are inherently using object initializers. Without them, projections in LINQ the way we know them would be impossible. The whole LINQ feature would be a lot clunkier and the code would look a lot messier.&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7984833534934011506-2298466906066404674?l=itranscendable.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://itranscendable.blogspot.com/feeds/2298466906066404674/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7984833534934011506&amp;postID=2298466906066404674&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7984833534934011506/posts/default/2298466906066404674'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7984833534934011506/posts/default/2298466906066404674'/><link rel='alternate' type='text/html' href='http://itranscendable.blogspot.com/2008/03/object-initializers-and-linq.html' title='Object Initializers and LINQ'/><author><name>Gustavo Cavalcanti</name><uri>http://www.blogger.com/profile/14733952116202634514</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://2.bp.blogspot.com/_ppjnAc2b4wo/SvpoFpyfnaI/AAAAAAAAFHY/75JV8M3HwhE/S220/Gus.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7984833534934011506.post-8204016438158919486</id><published>2008-03-05T10:52:00.000-08:00</published><updated>2008-11-12T18:28:12.743-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>Implicitly-typed variables in Resharper 4.0</title><content type='html'>&lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Arial;font-size:100%;"  &gt;By now, most of us already know that &lt;a href="http://msdn.microsoft.com/msdnmag/issues/07/06/CSharp30/"&gt;Linq&lt;/a&gt; is everywhere, and therefore, also are anonymous types. To make anonymous types usable with &lt;a href="http://msdn.microsoft.com/msdnmag/issues/07/06/CSharp30/"&gt;Linq&lt;/a&gt;, implicitly-typed variables are required.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Arial;font-size:100%;"  &gt;The "var" keyword tells the compiler to infer the type from what's on the right-side of the attribution. C# is a statically-typed language, and the “var” keyword doesn't change this.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Arial;font-size:100%;"  &gt;When you compile the code into IL, you'll see the type explicitly used there. So what's the harm of using "var" all over the place?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Arial;font-size:100%;"  &gt;Before jumping to the answer right away, I would like to refer you to &lt;a href="http://www.cc2e.com/"&gt;Steve McConnell's Code Complete&lt;/a&gt;, where he reminds us that one should strive to write code that's easy to read. it sure is nice when code is both easy to write and read (like the newly added "automatic properties" C# 3.0 feature). But readability always prevails.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Arial;font-size:100%;"  &gt;So, to answer my question about the harm of using "var" everywhere, I would say that it &lt;span style="font-style: italic; font-weight: bold;"&gt;can &lt;/span&gt;be really harmful to readability.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Arial;font-size:100%;"  &gt;Sure, if a variable declaration is like the following, there's no problem in using "var":&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Arial;font-size:100%;"  &gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;br /&gt;&lt;span style="font-family: courier new; color: rgb(255, 204, 102);font-family:courier new;" &gt;   var baby = new Person();&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Arial;font-size:100%;"  &gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;br /&gt;It is obvious that the variable baby is of type Person. But imagine some method, badly named GetNewOne, returning a new Person object.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Arial;font-size:100%;"  &gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;br /&gt;&lt;span style="font-family: courier new; color: rgb(255, 204, 102);"&gt; &lt;/span&gt;&lt;span style="font-family: courier new; color: rgb(255, 204, 102);font-family:courier new;" &gt;  var baby = GetNewOne();&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Arial;font-size:100%;"  &gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;br /&gt;How in the world would you know that baby is of type Person? I know if you're using Visual Studio, you can simple hover the mouse over it. But I think I shouldn't rely on a tool to provide me with code readability.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Arial;font-size:100%;"  &gt;In the example above I definitely want my code to be like this:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Arial;font-size:100%;"  &gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;br /&gt;&lt;span style=""&gt;   &lt;/span&gt;&lt;span style="font-family: courier new; color: rgb(255, 204, 102);font-family:courier new;" &gt;Person baby = GetNewOne()&lt;/span&gt;&lt;span style="font-weight: bold;font-family:courier new;" &gt;;&lt;/span&gt; &lt;span style="color: rgb(51, 204, 0);"&gt;//TODO: Refactor this method name please!!!&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Arial;font-size:100%;"  &gt;&lt;o:p&gt;&lt;/o:p&gt;I've been playing with &lt;a href="http://www.jetbrains.net/confluence/display/ReSharper/ReSharper+4.0+Nightly+Builds"&gt;ReSharper 4.0 nightly builds&lt;/a&gt; on Visual Studio 2008 targeting .Net 3.5, and interestingly enough, every time you use something like "&lt;span style="font-weight: bold;font-family:courier new;" &gt;Person baby = GetNewOne()&lt;/span&gt;", ReSharper 4.0 will put a &lt;strike&gt;squiggly line&lt;/strike&gt; small green line (hint) under Person, suggesting I should use the "var" keyword instead. See below.&lt;p&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_ppjnAc2b4wo/R9GBvO_1RaI/AAAAAAAAA3o/_NA5pL5HPgw/s1600-h/resharper4hint.PNG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://1.bp.blogspot.com/_ppjnAc2b4wo/R9GBvO_1RaI/AAAAAAAAA3o/_NA5pL5HPgw/s320/resharper4hint.PNG" alt="" id="BLOGGER_PHOTO_ID_5175060095305074082" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Arial;font-size:100%;"  &gt;ReSharper 4.0 is not out yet, and maybe (hopefully) this code suggestion will not be in the final version, but I thought it was interesting and wanted to share.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Arial;font-size:100%;"  &gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7984833534934011506-8204016438158919486?l=itranscendable.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://itranscendable.blogspot.com/feeds/8204016438158919486/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7984833534934011506&amp;postID=8204016438158919486&amp;isPopup=true' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7984833534934011506/posts/default/8204016438158919486'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7984833534934011506/posts/default/8204016438158919486'/><link rel='alternate' type='text/html' href='http://itranscendable.blogspot.com/2008/03/implicitly-typed-variables-in-resharper.html' title='Implicitly-typed variables in Resharper 4.0'/><author><name>Gustavo Cavalcanti</name><uri>http://www.blogger.com/profile/14733952116202634514</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://2.bp.blogspot.com/_ppjnAc2b4wo/SvpoFpyfnaI/AAAAAAAAFHY/75JV8M3HwhE/S220/Gus.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_ppjnAc2b4wo/R9GBvO_1RaI/AAAAAAAAA3o/_NA5pL5HPgw/s72-c/resharper4hint.PNG' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7984833534934011506.post-6656140922408357375</id><published>2008-02-28T23:19:00.000-08:00</published><updated>2008-02-28T23:22:18.999-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='User Group'/><title type='text'>MSDN Event here in Fresno!</title><content type='html'>Last night at the &lt;a href="http://www.centralcaldotnet.com/"&gt;user group&lt;/a&gt; meeting I mentioned the launch event of Windows Server 2008, Visual Studio 2008 and SQL Server 2008. I forgot to mention that all attendees will get a promotional pack containing all three new products. You can go ahead and register for it &lt;a href="http://www.microsoft.com/heroeshappenhere/events/Fresno/default.mspx#"&gt;here&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7984833534934011506-6656140922408357375?l=itranscendable.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://itranscendable.blogspot.com/feeds/6656140922408357375/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7984833534934011506&amp;postID=6656140922408357375&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7984833534934011506/posts/default/6656140922408357375'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7984833534934011506/posts/default/6656140922408357375'/><link rel='alternate' type='text/html' href='http://itranscendable.blogspot.com/2008/02/msdn-event-here-in-fresno.html' title='MSDN Event here in Fresno!'/><author><name>Gustavo Cavalcanti</name><uri>http://www.blogger.com/profile/14733952116202634514</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://2.bp.blogspot.com/_ppjnAc2b4wo/SvpoFpyfnaI/AAAAAAAAFHY/75JV8M3HwhE/S220/Gus.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7984833534934011506.post-8563584757712468605</id><published>2008-02-28T21:31:00.000-08:00</published><updated>2008-02-28T21:37:34.396-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Technical Review'/><title type='text'>C# 3.0 Cookbook 3rd Edition - I Recommend!</title><content type='html'>I had the pleasure to work as a &lt;a href="http://www.pnasoft.com/archive/2008/02/18/oreilly-csharp-3-0-cookbook-3rd-edition.aspx"&gt;technical reviewer&lt;/a&gt; on &lt;a href="http://www.oreilly.com/catalog/9780596516109/index.html"&gt;C# 3.0 Cookbook 3rd Edition, &lt;/a&gt;&lt;i&gt;&lt;a href="http://www.oreilly.com/catalog/9780596516109/index.html"&gt;by Jay Hilyard, Stephen Teilhet (O'Reilly).&lt;/a&gt;&lt;br /&gt;It is a wonderful book with a pragmatic approach to solve common interesting problems.&lt;br /&gt;Thank you O'Reilly for inviting me to work on this book.&lt;br /&gt;&lt;br /&gt;&lt;/i&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7984833534934011506-8563584757712468605?l=itranscendable.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://itranscendable.blogspot.com/feeds/8563584757712468605/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7984833534934011506&amp;postID=8563584757712468605&amp;isPopup=true' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7984833534934011506/posts/default/8563584757712468605'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7984833534934011506/posts/default/8563584757712468605'/><link rel='alternate' type='text/html' href='http://itranscendable.blogspot.com/2008/02/c-30-cookbook-3rd-edition-i-recommend.html' title='C# 3.0 Cookbook 3rd Edition - I Recommend!'/><author><name>Gustavo Cavalcanti</name><uri>http://www.blogger.com/profile/14733952116202634514</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://2.bp.blogspot.com/_ppjnAc2b4wo/SvpoFpyfnaI/AAAAAAAAFHY/75JV8M3HwhE/S220/Gus.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7984833534934011506.post-4010911270295022431</id><published>2008-02-28T15:39:00.000-08:00</published><updated>2008-02-28T15:42:24.287-08:00</updated><title type='text'>C# 3.0 Presentation source code</title><content type='html'>JD Conley was kind enough to post the source code on his &lt;a href="http://www.jdconley.com/blog/archive/2008/02/28/c-3.0-overview.aspx"&gt;blog&lt;/a&gt; of the presentation he did last night, at Fresno State, for our Central California .Net User Group.&lt;br /&gt;Thank you JD!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7984833534934011506-4010911270295022431?l=itranscendable.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://itranscendable.blogspot.com/feeds/4010911270295022431/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7984833534934011506&amp;postID=4010911270295022431&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7984833534934011506/posts/default/4010911270295022431'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7984833534934011506/posts/default/4010911270295022431'/><link rel='alternate' type='text/html' href='http://itranscendable.blogspot.com/2008/02/c-30-presentation-source-code.html' title='C# 3.0 Presentation source code'/><author><name>Gustavo Cavalcanti</name><uri>http://www.blogger.com/profile/14733952116202634514</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://2.bp.blogspot.com/_ppjnAc2b4wo/SvpoFpyfnaI/AAAAAAAAFHY/75JV8M3HwhE/S220/Gus.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7984833534934011506.post-5948090107967335742</id><published>2008-02-23T00:16:00.000-08:00</published><updated>2008-02-23T00:38:09.284-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='User Group'/><category scheme='http://www.blogger.com/atom/ns#' term='.net'/><title type='text'>Central California .Net User Grop meeting - Feb/27/2008</title><content type='html'>I am looking forward to next user group meeting, which will be presented by &lt;a href="http://www.jdconley.com/blog/"&gt;JD Conley&lt;/a&gt;, who will talk about C#3.0.&lt;br /&gt;For more information visit &lt;a href="http://www.centralcaldotnet.com/"&gt;www.centralcaldotnet.com&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7984833534934011506-5948090107967335742?l=itranscendable.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://itranscendable.blogspot.com/feeds/5948090107967335742/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7984833534934011506&amp;postID=5948090107967335742&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7984833534934011506/posts/default/5948090107967335742'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7984833534934011506/posts/default/5948090107967335742'/><link rel='alternate' type='text/html' href='http://itranscendable.blogspot.com/2008/02/central-california-net-user-grop.html' title='Central California .Net User Grop meeting - Feb/27/2008'/><author><name>Gustavo Cavalcanti</name><uri>http://www.blogger.com/profile/14733952116202634514</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://2.bp.blogspot.com/_ppjnAc2b4wo/SvpoFpyfnaI/AAAAAAAAFHY/75JV8M3HwhE/S220/Gus.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7984833534934011506.post-6263983116511794043</id><published>2008-02-22T23:51:00.000-08:00</published><updated>2008-02-23T00:08:44.885-08:00</updated><title type='text'>Problem with CD/DVD drive in Vista</title><content type='html'>I am not proud of having my inaugural blog post on how to fix a bug in Windows Vista.&lt;br /&gt;I have been using Vista 64 and have encountered a few problems.&lt;br /&gt;It started with my old logitech webcam, which I cannot find a vista driver for. I bought a Microsoft Lifecam to replace it, and, guess what, the thing didn't work right out of the box. I had to run a patch to fix something on the USB drivers of Vista 64 bits. It worked. It was funny to buy a brand new Microsoft peripheral incompatible with Vista 64.&lt;br /&gt;The next problem I had was with my CD/DVD drive. After some windows update it appeared with a warning sign in Device Manager, saying that the driver was missing. I spent several minutes trying to find a more up-to-date driver for my drive (TSSTcorp TS-L632H - came in a Inspiron 1520). Also, my U3 thumb drive didn't work.&lt;br /&gt;&lt;br /&gt;It turns out that the solution for this problem has nothing to do with driver, after all. All you have to do is&lt;br /&gt;a) Go to the registry and find [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E965-E325-11CE-BFC1-08002BE10318}&lt;br /&gt;b) Make sure the class = CDROM&lt;br /&gt;c) Delete both UpperFilter and LowerFilter keys.&lt;br /&gt;d) reboot.&lt;br /&gt;&lt;br /&gt;After I did this, both my CD/DVD drive and my U3 thumb drive (which works like a CD) work fine!&lt;br /&gt;&lt;br /&gt;Other than these, and not being able to run my McAfee Viruscan on Vista, I haven't had any problems with Vista 64.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7984833534934011506-6263983116511794043?l=itranscendable.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://itranscendable.blogspot.com/feeds/6263983116511794043/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7984833534934011506&amp;postID=6263983116511794043&amp;isPopup=true' title='8 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7984833534934011506/posts/default/6263983116511794043'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7984833534934011506/posts/default/6263983116511794043'/><link rel='alternate' type='text/html' href='http://itranscendable.blogspot.com/2008/02/problem-with-cddvd-drive-in-vista.html' title='Problem with CD/DVD drive in Vista'/><author><name>Gustavo Cavalcanti</name><uri>http://www.blogger.com/profile/14733952116202634514</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://2.bp.blogspot.com/_ppjnAc2b4wo/SvpoFpyfnaI/AAAAAAAAFHY/75JV8M3HwhE/S220/Gus.jpg'/></author><thr:total>8</thr:total></entry></feed>
