Sunday, May 22, 2005

Reflection...

For all those who still haven't got their hands dirty with reflection (i was surprised to see a LOT of .NET developers haven't!!) A very good source of learning the basics of reflection is a book called “Applied Microsoft .NET Framework Programming” by Jeffery Ritcher. Here’s a simple ‘Hello World’ of reflection:

To Get My Hands dirty with code I write a simple DLL (Class library project):

using System;
namespace ReflectionDLL
{
public class Sales
{
public Sales() { }
public string SayHello(){return "Hello";}
}
}

This DLL Contains A Module (namespace) named ReflectionDLL, a type(class) named Sales which in turn Contains A Member(function) named SayHello(). The objective is to get this information out of the DLL without looking at it’s source code.

For this I write a windows application which contains the following function:
public void MainFunction()
{
Assembly assem = Assembly.LoadFile("c:\\ReflectionDLL.dll");
foreach(Module m in assem.GetModules())
{
System.Windows.Forms.MessageBox.Show("Showing Modules involved in the DLL: " + m.ToString());
}

foreach(Type t in assem.GetTypes())
{
System.Windows.Forms.MessageBox.Show("Showing Types involved in DLL" + t.ToString());
foreach (MemberInfo m1 in t.GetMembers())
{
System.Windows.Forms.MessageBox.Show("Showing Memebers in current type: " + t.ToString() + " : Member Name is " + m1.ToString());
}
}
}

It’s interesting to note here that besides SayHello member all other framework related members e.g. ToString() (even though we have NOT implemented these) that are present in all objects are also shown.

Tuesday, May 10, 2005

The commonly asked customization question ... answered.

For the past month or so since i started customizing my desktop there has been quite a bit of interest shown by various people who have seen the desktop. The most commonly asked question was - "how can i do it on my machine!?" :). So here's a general guideline on how you can do it - feel free to post comments / send emails if you run into problems... :)

1. Download windows customization software. (i am using Windows blinds). Download a skin you like - i am using a classic blue skin designed by some individual that i downloaded from the net.

2. Download a Mac like status bar - there are many options out there - the Yz is just one of the popular options.

3. Download registry entries from msdn. There are .reg files in msdn you can download for a lot of customization like removing your recycle bin, changing system icons etc.

4. Use a little bit of googling and creativity - mainly for customized icons that you might need.

5. Show off your new desktop to other! :)

Wednesday, May 04, 2005

Underwater bridges and buildings upside down!

We just dont see them do we? Underwater bridges and buildings made upside down? Ironically however, i bet every developer writes code every day in his life which is synonymous to underwater bridges and upside down buildings. Reason? Requirements!(Which makes coding so VERY different and exciting to me, over other older deciplines and professions).

This is the Nth(50th??) wacky thing i've ended up doing with a DataGrid that was probably designed by Microsoft with the sole purpose of 'showing' data from a datasource! Well, i thought that after adding icons that do things to datagrid columns , adding calculated columns, adding calculated checkboxes, paging with n number of different styles, adding links buttons and sorting i had done all that can be done with a asp.net data grid.

turns out, i am WRONG - we now need RADIO BUTTONS in a datagrid column and user can selected just one of them throughout the data column and then hit a button (which is in no way connected with the datagrid) to select the record and pass it's value to another form! Phew!

If you are one of those like me you're probably saying "hmmm... what the big deal... have a column template and add a radio button!" - well, .NET renames each control in column template when the html is returned and so you end up with 1 radio button per record where all of them can be selected at the same time!

Here's is a good approach that did the trick. It's more the concept that is described in the article that makes you go "wow! didn't think of that!" - noone should need the sample code there - the idea in the article is by itself good enough to get you going and write your own code!

Monday, May 02, 2005

More Customizations!!!

It's hardly been a few days since my PC was 'skinned' to look like a MAC and that itch of customization has started again! Can my disks looks different? Folders? Individual File Types? After a bit of googling here's a screen shot of the latest desktop :)