Simple Reflection Based Assignment Using Extension Methods

Have you ever had two objects, of different types, and wished that C# could just be smart enough to realize that objA.FirstName should be assigned to objB.FirstName?  For me this comes up quite a bit when working with WCF services.  I don't want a service to directly expose my internal business object type, because that type might change on a different schedule than that of my data contract.  So I often end up with objects that have identical property names, usually the service being a subset of the internal class, but obviously of different types.  How can I handle assigning objDC from objInternal without writing a line of code (or generating a line of code) for every single property?  Enter AssignFrom ... with this code, you'll get something as simple as objDC.AssignFrom(objInternal);using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Reflection; using System.Diagnostics; namespace TestCSharp { public static class ObjectExtensions { public static T AssignFrom<T>(this T obj, object from) { Type toType = obj.GetType(); Type fromType = from.GetType(); var toInfo = toType.GetProperties(); var fromInfo = fromType.GetProperties(); foreach (var fromProp in fromInfo) { bool assigned = false; foreach (var toProp in toInfo) { if (toProp.CanWrite && fromProp.CanRead && toProp.PropertyType.Equals(fromProp.PropertyType) && toProp.Name.Equals(fromProp.Name) && toProp.GetIndexParameters().Count() == 0 && fromProp.GetIndexParameters().Count() == 0) { toProp.SetValue(obj, fromProp.GetValue(from, null), null); assigned = true; } } Debug.Assert(assigned, string.Format( "Property {0} was not populated to the To object.", fromProp.Name)); } return obj; } } }

BizTalk 2006 R2 Pre-requisites CAB Files

With many thanks to Sanket for posting this information originally, I wanted to post these links here so that the next time I can save my self the Google search and just hit this post.  These links are for the EN language, but there's a link at the bottom to the full list for all languages. Windows 2003 Server 32 bit http://go.microsoft.com/fwlink/?LinkId=81468 Windows 2003 Server 64 bit http://go.microsoft.com/fwlink/?LinkId=81459 Vista 64 bit http://go.microsoft.com/fwlink/?LinkId=81423 Vista 32 bit http://go.microsoft.com/fwlink/?LinkId=81432 Windows XP 32 bit http://go.microsoft.com/fwlink/?LinkId=81450 Windows XP 64 bit http://go.microsoft.com/fwlink/?LinkId=81441 For a complete list of all the downloads in all the languages, you can use this link - http://msdn.microsoft.com/en-us/library/aa578652.aspx

How To Create a Portable Office (Computing)

Laptop What makes a great laptop for a mobile office?  Well I can give some guidelines, and assume I'm talking to a group of developers, but in the end that is up to you.  Some things you need to remember: Extensibility - Does your laptop have an expansion bay which can be used to swap in new hard disks, optical disks and/or batteries? USB Ports - I've yet to meet a laptop with "too many" USB ports.  Mine has 4, and I run out quite regularly. Big screen - This is a desktop replacement machine, don't go for light, go for powerful and comfortable to type on and while you're at it, get a good resolution screen because you've got the real estate to do it with. Express Card - Express card slots are where are new plug-in peripherals that aren't USB are being developed for.  Make sure you've got one of these. PCMCIA - If you can still have a PCMCIA port, great because there are a ton of legacy laptop gizmos which can use this port. Firewire - While not as big in the Windows world, a lot of the video cameras in this world only talk Firewire.  Usually labeled IEEE 1394, you want to make sure you've got one of these. Multi-Core - Non negotiable it must be at least 2 cores, preferably 4 core once Intel gets their mobile quad core CPUs available. Memory - Max out your memory, there is just no reason not to. Video - If you're getting it yourself, max out the video card.  You likely will not win this argument with corporate IT though unless you happen to have a job that has intensive graphics like a designer. Now that is not the end all be all of laptop features.  Remember things that are important to your job, my father works with devices that require a parallel port to communicate with on a regular basis and that is becoming increasingly rare these days, so that is a feature he has to shop for specifically.  Get the pointing device that least drives you crazy, whatever that is.  Personally I love the "nib" style pointer, but I recognize that doesn't work for everyone.  The Dell Latitude D-820 which Sogeti provides me is an excellent device, and happens to have both nib and touch pad.  The only thing I'd change about my unit is that I'd prefer if it had a Bluetooth transceiver built into it. Mouse Everyone has opinions about pointing devices, but I love the Microsoft Wireless Presenter Mouse 8000.  This is a gorgeous Bluetooth mouse with built in presenter controls, media controls, laser pointer, etc.  None of this gets in the way of the operation of the four buttons or tilting scroll wheel (so you can scroll horizontally).  It runs on 2 AAA batteries, but will last months on those even with daily use.  I've had one for nearly 2 years, love the protective case it comes with, and have just bought my second one so I can have a backup in case the current one dies. (The media controls, and presenter controls, are on the bottom of the mouse, it flips over and disables the top buttons when in presenter mode). Sometimes though I'm an idiot, I grab my laptop and run to a meeting only to discover my presenter mouse is back on my desk.  Rather than suffer with even a nib, which is still inferior to a mouse, I now get to reach for my PCMCIA port and pull out the MoGo Mouse that was part of the MVP Award gift pack for 2009.  One photo won't do this ingenious little gizmo justice, so go check out MoGoMouse.com and check it out. Storage There is no such thing as enough storage. Period. Full Stop.  I carry over a terrabyte of storage in my backpack, and have occasionally still wanted for more (for short periods) when I've been bad and not rolled off temporary data that I should have.  My portable storage plan takes two parts, the first is a hard drive expansion slot for my Dell's MediaBay slot.  This is proprietary, but there are third party trays you can get which will slide in and let you put in your own hard disk.  I use this disk for all my virtual machines.  Worthy of note, you can also boot to this disk, so if you've got a Dell from work with lots of OS/Domain restrictions, you could install another OS on the other drive so you could re-purpose the hardware when you're not at work or if you need to run another Operating System for work reasons. For everything else I use Western Digital Passport drives.  These units can be acquired in large capacities, mine are 250gb, and I carry a pair of them.  They store my ISO library of software, my baseline VPC images (the Dell HD has the working copies), a home music library backup when I want more than I keep on my hard disk, etc. Cables & Hubs There are other things you'll need besides this, the first of which is cables.  Almost nothing I carry has its default cables with them unless those cables are proprietary (which is a mark against a device).  I carry a large number of ZipLinq cables though.  These wonderful self-retracting cables allow me to avoid the backpack becoming a jumble of cables, and yet connect to all sorts of things.  I carry multiple USB-to-USBmini cables, USBa-to-USBb, headphone extender, 1/8"-to-1/8", Firewire,  and generic USB extender cables.  All inside just one of my bags, with my hard drives and of course... a USB hub.