Visual Studio 2008 Beta 2 installed

Tuesday, 31 July 2007 14:07 by admin

Microsoft has just released VS2008 (code named Orcas) last week. And already there are many blogs around there discussing its new features. And I guess I'm such a sucker when it comes to Beta products.

I've just finished downloading the DVD image yesterday. I started downloading it on Friday (12hrs downloading time on 100kbps download rate). The package is quite huge (3.5 GB). It took me 1.5 hours to uninstall VS2008 Beta 1 and the MSDN that came with it. Installing the Beta 2 just consumed an hour of my time including the extraction of the DVD image.

Well, now that I have finished installing the software, it's time to test it. The IDE loaded much faster this time and believe it or not, the environment is much responsive compared to VS2005. I really haven't encountered much bugs in Beta 1 so there's nothing that I can check. What I did was started out my new project on my new IDE. My new project requires me to use ASP.Net Ajax 1.0. So I went ahead and installed the package. I tried creating a new project and viola! I noticed that there is no project template for ASP.Net Ajax! Though I've read in a blog that if you choose .Net Framework 3.5, the files needed for ASP.Net AJAX will automatically be included. But I don't want to have a dependency to a 3.5 Framework! All I want is to be able to create ASP.Net Ajax solution using my old and tested .net framework 2.0.

But alas! With the power of live.com I found a blog post by the Ajax team from Microsoft!

http://blogs.msdn.com/webdevtools/archive/2007/07/30/using-vs-2008-to-target-asp-net-ajax-1-0.aspx

I followed the instruction to be able to use ASP.Net Ajax 1.0 on .Net framework 2.0 projects in VS2008. Tried it once, twice and Grrrr.... it won't work!!! I've just read the comments and it seems that some other guys are experiencing the same problems as mine. Hmmm... Well I guess this is the price on using Beta softwares. If your planning to use VS2008, good luck to you!

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Categories:  
Actions:   E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed

Predicates, Converters and Actions

Friday, 27 July 2007 12:07 by admin

It's been a while that I blogged some serious (technical) stuff here. So I guess it's time again for another tips and tricks on C# that this blog supposedly offers.

What I'm going to share to you now is somewhat a shorthand of doing a basic looping routine using delegates and generics. Have you ever coded a routine that passes through all of your items in an array or a list and perform an operation per item? Are you getting tired of doing the same old stuff (for-each and for loops)? Well if you are, then this blog is for you.

Doing a loop within your array and doing an operation per item is a pretty much simple thing to do. You can call me lazy, but as you are doing this repetitively you often grow tired of seeing a single for loop statement. This prompted me to search the .net framework for some useful stuffs that might spice up my development. Hence I came across Predicates, Converters and Actions.

Predicates

A Predicate is a delegate located in the System Namespace which can be used as a determinant if the item within your array or list meets a specific condition or not.

Here's a simple example:

Suppose you have an array of integers and you want to get only the numbers that are greater that 5. Normally you will be doing this:

int[] arr = new int[] { 1,2,3,4,5,6,7,8,9,0 };
for (int i = 0; i < arr.Length; i++) {
    if (arr[i] > 5) {
       resArr[newIndex] = arr[i];
       newIndex++;
    }
}
/* I know the code is quite lame but I guess you know the idea */

You can convert it to this, by using a predicate:

bool Match(int item) {
    if (item > 5) {
        return true;
    } else {
        return false;
    }
}

// some code here...

Predicate<int> matchDelegate = new Predicate<int>(Match);
int[] resultArr = Array.FindAll<int>(_myIntArray, matchDelegate);

As you can see, we didn't even use a single for loop statement. This is done automatically upon calling the FindAll method of the Array class. This can also be applied to a List class as we can see in our next example.

 

Converters

A Converter is a delegate that is used to convert an item in an Array or List from one type to another.

Supposedly you have a List that contains integers and you want to convert all item to a string and store it in another List.

string converter(int item) {
    return item.ToString();
}

List<int> _listOfInt = new List<int>();
Converter<int, string> _converter = new Converter<int, string>(converter);

// Code to add each items goes here

List<string> _listOfString = _listOfInt.ConvertAll<string>(_converter);

The sample automatically converts all values in the List to string.

Actions

An Action is a delegate that specifies a routine that will be executed during the looping of the List.

Suppose you want to display all values of the List to the Debug Window. So instead of creating a loop, you can use Actions to do that.

void action(string item) {
    System.Diagnostics.Debug.Write(item);
}

List<string> _listOfString = new List<string>();
Action<string> _action = new Action<string>(action);

// Code to add the values

_listOfString.ForEach(_action);

This chunk of code will output all values of your List into the Debug Window in Visual Studio.

As you can see, the .Net Framework 2.0 is very rich and provides means to automate your programming. Note that this methods that I have showed you will not make your program run faster. The execution time of doing it manually and by using delegates are similar. This is just a shorthand of tasks that you quite do repetitively.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Categories:  
Actions:   E-mail | Permalink | Comments (6) | Comment RSSRSS comment feed

Open Source at Microsoft

Thursday, 26 July 2007 16:07 by admin

In his keynote at OSCON, Microsoft General Manager of Platform Strategy Bill Hilf announced that Microsoft is submitting its shared source licenses to the Open Source Initiative. This is a huge, long-awaited move. It will be earthshaking for both Microsoft and for the open source community if the licenses are in fact certified as open source licenses. Microsoft has been releasing a lot of software as shared source (nearly 650 projects, according to Bill). If this is suddenly certified as true open source software, it will be a lot harder to draw a bright line between Microsoft and the open source community.

This was the news that really blew my head off this day. By releasing 650 projects to the Open Source community, this will mean a whole lot of upcoming softwares on the Linux and Windows desktop. If some of you are not quite familiar with the Shared Source License, it's a Licensing scheme of Microsoft that permits its partners and developers to view the source of some of its products. An example of this is the ability for a Microsoft MVP to apply to view certain parts of Windows XP source code (though I really doubt that this will be included in the Open Source Initiative). Developers (MSDN members) has been the sole beneficiary of this initiative, until now. Here's a short list of developer softwares that "could" be included on the Open Source Initiative (most of it are already located on CodePlex).

http://www.microsoft.com/resources/sharedsource/Licensing/Developer.mspx

At the same time, Microsoft officially announced the availability of it's own Open Source web site (http://www.microsoft.com/opensource).

As they always say. If you can't beat them, join them!

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Categories:  
Actions:   E-mail | Permalink | Comments (2) | Comment RSSRSS comment feed