Tuesday, May 15, 2007

Interesting Reflection Problem

First of all, there is no problem with reflection!!!
I didn't get a nice title for this post. So sorry about that :-)

Actually, its a problem that I am trying to solve using reflection.
Here is the problem.

I've been trying to get the value out of a command expression inside an string, something like this:

Class1 ob1 = new Class1();

string strCommand = "ob1.Price"; // price being a property of the ob1 object

int iResult = Exec(strCommand);

In the iResult variable the actual price (a number) should be there. So what i want is that the command inside the strCommand string is executed, and their return value is taken.

I don't think it is possible to do it exactly in the way it has been asked. I tried to have a workaround using reflection. Here it is

class Program
{
static object Exec(object ob, string PropertyName)
{
System.Type objType = ob.GetType();
PropertyInfo property = objType.GetProperty(PropertyName);
return property.GetValue(ob, null);
}
static void Main(string[] args)
{
Console.WriteLine(Exec(System.DateTime.Now, "Day"));
}
}

I am not sure if this is the best way to do it. But thats the only way I can think of doing it :-)

Monday, May 14, 2007

This is not a post

This is not actually a blog post. But its an answer to another blog post made by someone.
You can read the referenced blog (unfortunately, comments are disabled on that blog) here

FireFox is compatible with almost all of the versions of windows unlike IE new release which works only on XP SP2 and above so that's means people using Windows XP SP1 or older have 3 choices and that is either to stick with the older IE which has so many security issues or to buy a new version of Windows which is not cheap or to migrate from IE to other web browser like FireFox and I must say that the third choice is the easy one to make without compromising on security and also without paying any money as Microsoft has abandoned its consumers who uses XP SP1 or older in terms of IE.
---If you are running Windows XP(with or without sp1), SP2 is a free download and requires you to pay ABSOLUTELY NO EXTRA CHARGE. So go ahead and upgrade yourself (oh yes... you can't do that if you are one of those who like to steal software rather than buy it... in simple terms i mean pirates)



The new release of IE seems to be solving most of the problems of the older version of IE but many of the problems still remains and many new exploits will emerge later on.
---Two things
1) Tell me one browser that has NO COMPROMISES
2) Can you tell me some of the security flaws in IE 7

Go write an exploit on IE7, publish it and then come back to me saying IE got a flaw... Don't throw stones in the dark

Most of the website are made to run best in IE because IE has support to many web components like VBScript, ActiveX etc which makes the website more useful but on the other side these components are at the core of most of the security issues in IE which is exploited by the hackers and some of the exploits
are very serious in nature
---I feel pity on you lad. VBScript, ActiveX are web components.... makes me laugh like hell :D
Well! I admit ActiveX has been a problem in the last few releases. But, now if you look at IE 7, it specifically warns you for every script and activeX, and by default it blocks everything. Its the user who is supposed to trust the website from where the content is coming and decide whether to run things or not. And BTW, FireFox also runs on plugins... and there are so many exploits on that too :)


Microsoft is very slow in releasing patches for the exploits in their softwares and in this case IE which makes IE even more vulnerable to attacks from hackers.
---I don't remember any such incidence (i guess i have been a Microsoft user since quite long). Can you please help me recollect at least one of those incidences when MS delayed (a lot) in releasing a patch


Most of the website are now being made to work in both IE and other web browsers like FireFox which is encouraging more and more user to migrate from IE to FireFox
---What a reason to leave the browser we all love :P


IE has less options as compare to FireFox which gives its users so many options like extensions etc to enhanced their web browsing experience
---I don't know what options the author refers to. As far as extensions are concerned, IE has them since last 13 years :)


In FireFox you can open multiple windows in a single window in order to browse multiple websites and this is a very plus points as this feature is not available in IE
---Have you ever seen something called IE 7. I am sure you have not. Go have a look at it. And BTW, "multiple windows in a single window" is called as tabbed browsing :P


FireFox has less security issues as compared to Microsoft's IE.
---Evidence please...


Options like extensions etc. are available on a large scale as compared to IE
---As I said... IE has them since last 13 years (the first release came in 1995)


FireFox has good download speed
---This one is the most hilarious... What makes you think so dude???


FireFox has one of the best pop up blocker available in the market today
z---Now I am damn sure you have not looked at IE 7


You can view news headlines whenever you want without even going to a news
website and if you want to read a particular news then just click the headline
you want to read in
---That's called feed reader and yet again... take a look at IE 7 bro. Its got it all


NOTE:The views expressed here are solely my personal views. My employer or any other community/organisation that I am associated with have nothing to do with the views expressed here by me