Paulo Morgado

.NET Development & Architecture

This Blog

Syndication

Search

Tags

News

Unit Test Today! Get Typemock Isolator!

Projects

Books

 

Visitors

Visitor Locations

Community

Email Notifications

Archives

Profile

Disclaimer

The opinions and viewpoints expressed in this site are mine and do not necessarily reflect those of Microsoft, my employer or any community that I belong to. Any code or opinions are offered as is. Products or services mentioned are purchased by me, made available to me by my employer or the manufacturer/vendor which doesn't influence my opinion in any way.

Browse by Tags

All Tags » .NET3.5 (RSS)
Extension Methods And Type Inference In Action
I make extensive use of extension methods , either to make classes small and focused or to improve readability. While porting a .NET 1.1 WinForms application to C# 3.0, I found lots of code like this: delegate int Int32DelegateStringBoolean ( string text...

Posted Mon, Apr 18 2011 2:16 by Paulo Morgado | with no comments

Hydrating Objects With Expression Trees - Part III
To finalize this series on object hydration, I’ll show some performance comparisons between the different methods of hydrating objects. For the purpose of this exercise, I’ll use this class: class SomeType { public int Id { get ; set ; } public string...

Posted Wed, Aug 18 2010 2:27 by Paulo Morgado | 2 comment(s)

Hydrating Objects With Expression Trees - Part II
In my previous post I showed how to hydrate objects by creating instances and setting properties in those instances. But, if the intent is to hydrate the objects from data, why not having an expression that does just that? That’s what the member initialization...

Posted Mon, Aug 16 2010 23:19 by Paulo Morgado | 2 comment(s)

Mastering Expression Trees With .NET Reflector
Following my last post , I received lots of enquiries about how got to master the creation of expression trees . The answer is: .NET Reflector On that post I needed to to generate an expression tree for this expression: Expression < Func < object...

Posted Fri, Aug 6 2010 1:40 by Paulo Morgado | 1 comment(s)

Dumping Objects Using Expression Trees
No. I’m not proposing to get rid of objects. A colleague of mine was asked if I knew a way to dump a list of objects of unknown type into a DataTable with better performance than the way he was using. The objects being dumped usually have over a...

Posted Tue, Aug 3 2010 1:36 by Paulo Morgado | 2 comment(s)

LINQ: Enhancing Distinct With The SelectorEqualityComparer
On my last post , I introduced the PredicateEqualityComparer and a Distinct extension method that receives a predicate to internally create a PredicateEqualityComparer to filter elements. Using the predicate, greatly improves readability, conciseness...

Posted Fri, Apr 9 2010 2:32 by Paulo Morgado | 7 comment(s)

Filed under: , , , , ,

LINQ: Enhancing Distinct With The PredicateEqualityComparer
Today I was writing a LINQ query and I needed to select distinct values based on a comparison criteria. Fortunately, LINQ’ s Distinct method allows an equality comparer to be supplied, but, unfortunately, sometimes, this means having to write custom equality...

Posted Thu, Apr 8 2010 2:18 by Paulo Morgado | 11 comment(s)

Filed under: , , , , ,

LINQ: Single vs. SingleOrDefault
Like other LINQ API methods that extract a scalar value from a sequence, Single has a companion SingleOrDefault . The documentation of SingleOrDefault states that it returns a single, specific element of a sequence of values, or a default value if no...

Posted Tue, Mar 30 2010 1:41 by Paulo Morgado | with no comments

Filed under: , , ,

LINQ: Single vs. First
I’ve witnessed and been involved in several discussions around the correctness or usefulness of the Single method in the LINQ API. The most common argument is that you are querying for the first element on the result set and an exception will be thrown...

Posted Sun, Mar 28 2010 23:48 by Paulo Morgado | 3 comment(s)

Filed under: , , ,

Web Site Globalization With ASP.NET Routing
For those who don’t know, I have this web site http://PauloMorgado.NET/ that I use both as a web presence besides my blogs and a playfield. Because I write both in English and Portuguese, I wanted the web site to have both English and Portuguese versions...

Posted Sun, Jan 31 2010 23:29 by Paulo Morgado | with no comments

Coupling ASP.NET Session State With Forms Authentication
Today I was talking with João about a way to couple the lifetime of the ASP.NET   session state with the lifetime of Forms Authentication ticket . My idea was to store the session ID in the UserData property of the forms authentication ticket upon...

Posted Thu, Jan 28 2010 1:18 by Paulo Morgado | with no comments

Playing With LINQ: Getting Interface Property Implementations
Today, my friend Nuno was writing some code to get the PropertyInfo s of a class implementation of an interface. Given this interface: public interface ISomeInterface { int IntProperty { get ; set ; } string StringProperty { get ; } void Method(); } and...

Posted Wed, Jan 27 2010 2:22 by Paulo Morgado | with no comments

How To Set Elements Of An Array Of A Private Type Using Visual Studio Shadows
Visual Studio uses Publicize to create accessors public for private members and types of a type. But when you try to set elements of a private array of elements of a private type, things get complicated. Imagine this hypothetic class to test: public static...

Posted Tue, Jan 19 2010 0:26 by Paulo Morgado | with no comments

Extended WebBrowser Control - Version 0.0.0.0 Uploaded
After a long time, I finally managed to upload a version of the Extended WebBrowser Control to CodePlex . It's still a work in progress, but it's usable. Feel free to download , comment and file issues . A nice tabbed browser demo is included...

Posted Wed, Dec 2 2009 2:03 by Paulo Morgado | 4 comment(s)