Skip to main content

Posts

Showing posts from May, 2010

4 .NET 4.0 Libraries You *Should* Know Better – MEF, Reactive, Tasks and Dynamic

In this post, I’ll consolidate few posts on four .NET libraries/frameworks, that’ll help you write better appsMEF or Managed Extensibility Framework - System.ComponentModel.CompositionMEF or Managed Extensibility Framework is cool. Firstly, it allows you to decouple your components pretty easily. Secondly, it supports various component discovery scenarios, and enables you to write better frameworks. An Introduction to MEF- Creating a Zoo And AnimalsMEF or Managed Extensibility Framework and Lazy<T> – Being Lazy with MEF, Export Attributes etcReactive Extensions and LINQ To Events – System.ReactiveReactive Extensions will soon become the de-facto for writing asynchronous code in a declarative manner .NET Rx gives greater freedom to compose new events – you can create specific events out of general eventsWhat is LINQ To EventsConcepts And First LookLinq To Events – A WPF Drawing DemoA Text Template for generating GetEventName wrapperParallel Extensions and TasksSystem.Threading…

An Extension Method to Dump Control Templates of WPF Controls

In Blend, you have the ability to create a copy of the control template of a control, and edit it (Right Click – Edit Template – > Edit A Copy). If you are interested, you can dump the Control template of any given WPF control pretty easily, from the source code as well.Here is a simple extension method to dump the control template of a WPF control. public static class ControlTemplateExtension { public static string DumpControlTemplate(this Control ctrl) { XmlWriterSettings settings = new XmlWriterSettings() { Indent = true, NewLineOnAttributes = true }; StringBuilder strbuild = new StringBuilder(); XmlWriter xmlwrite = XmlWriter.Create(strbuild, settings); XamlWriter.Save(ctrl.Template, xmlwrite); return strbuild.ToString(); } } And now you can go ahead and dump your control templates, like this. //use your control name instea…

C# 4.0 AccessPrivateWrapper – Instantiate and Access Private/Internal Classes and Members via dynamic + reflection

[+] Download Related Source codeFrankly, intrusion in to the private space of others is not so great. Mostly, you’ll get a kick in your ass, but at times, if you are lucky and if you are really smart, you’ll end up finding something really cool (Bond, James Bond). For me, at times, when doing some hacks/exploration of compiled or third party assemblies, I end up wanting to initialize a private class or a class with a private or internal constructor. Or, at times, when dealing with pre-compiled legacy libraries that I can’t change - I want to write a couple of tests against a private method to understand how it works.  I remember going through the source code of TFS power toys or so some time back - and I found that those guys are bringing up a lot of goodness by unearthing some private classes in the TFS library.Still, I should warn you.Warning (assume that this is in red): Private types, internals and private members are so because of some reason, and often you don’t want to mess wit…

Creating a Standalone, offline Installer for installing Silverlight runtime + your XAP application

Related DownloadsSilverlight Nerd Dinner Client Offline InstallerFiles Required To Create the Installer (NSIS Script, XAP File etc)NSIS Installer to compile the above ScriptWhat?Recently a friend asked me to help him create an ‘installer’ to pack and distribute the Silverlight game he recently developed. He wanted to distribute his game via software download websites (like download.cnet.com), and via medias like CD/DVD. In fact, that is pretty easy (technically) - and this post is about creating and deploying Silverlight Runtime + Your Silverlight application (Xap file) using your very own custom, standalone, offline installer with out getting a browser installed - instead of the user installing your Silverlight application Out Of Browser via the web browser. Alright. In this post, we’ll see how to build a standalone installer for Silverlight Nerd Dinner Client that I built some time earlier (It is a Silverlight client for Scott’s Nerddinner.com to enable nerds to ‘eat in packs’). The…

Suggested Red Polo T-Shirt Replacement for @Scottgu

I’m a @scottgu fan, so can’t stop thinking about this after watching Iron Man 2 ;).Happy Coding!! ;)Recent Tech Posts6 Visual Studio 2010 Tips You Should KnowA Nerd Dinner Client for Windows Phone 7Developing for Multi Core Machines in .NET 4.0C# Dynamic Features

Developing for Multicore machines. Tasks in .NET 4.0 - Why/What/How?

With those multi core processors everywhere, support for parallelism is an already implicit requirement for any new application. This post explores how easily you can implement parallel features in your application, with .NET 4.0. What is Parallel computing? From Wikipedia,Parallel computing is a form of computation in which many calculations are carried out simultaneously,[1] operating on the principle that large problems can often be divided into smaller ones, which are then solved concurrently ("in parallel"). Yes, like that photo indicates, parallel systems can do multiple things at the same time..NET 4.0 framework provides a wealth of easy to use primitives and abstractions to enable developers to quickly write parallel programs, targeting multi core machines. In this post, we’ll explore Tasks.The System.Threading.Tasks has all the classes and abstractions you need to develop applications targeting multi core machines. What is a Task?A Task in .NET 4.0 is a simple unit …