tags:

views:

499

answers:

4

I'm currently working on a UI development project and it was decided to implement it in Silvelight. I understand that Microsoft developers try to minimize size of the distribution and that's why some (lots) of the classes in regular .NET Framework are not included. Is it expected to see more classes included in Silverlight 3 library?

A: 

The .NET framework contains heaps of stuff that is of little or no use in a sandboxed environment like Silverlight.

I would not expect to see much more of the standard .NET framework included in the Core CLR, however there'll be a bunch of stuff coming into Silverlight3 from WPF.

geofftnz
+3  A: 

I hope not, and I doubt it.

Scott Guthrie who apparently runs the project for Microsoft is on the record as saying that he doesn't want to put "nice to haves" in, in case there's no room left for any future "must haves".

I think they've got the balance right - there's not much they've left out which you can't write yourself.

Phil Bachmann
+1  A: 

Silverlight 3 no doubt will grow in size. Silverlight 3 will target mobile devices, so there is no doubt that the package will remain small. However, people are asking for a lot of new features: printing, WCF additions, 3D, microphone support, hardware acceleration...no doubt its going to grow. Its just a matter if they integrate this into the core or will your XAP file have to get a lot bigger.

Bart Czernicki
+4  A: 

As an aside, you can always use Reflector over the core .NET Framework libraries to obtain some of the missing "nice to haves" in code form.

Here's redgate's reflector: http://www.red-gate.com/products/reflector/

And here is the code I extracted and modified version of HttpUtility.ParseQueryString:

public IDictionary<string, string> ParseParams(string paramsString)
{
    if (string.IsNullOrEmpty(paramsString))
        throw new ArgumentNullException("paramsString");

    // convert to dictionary
    var dict = new Dictionary<string, string>();

    // remove the leading ?
    if (paramsString.StartsWith("?"))
        paramsString = paramsString.Substring(1);

    var length = paramsString.Length;

    for (var i = 0; i < length; i++) {
        var startIndex = i;
        var pivotIndex = -1;

        while (i < length) {
            char ch = paramsString[i];
            if (ch == '=') {
                if (pivotIndex < 0) {
                    pivotIndex = i;
                }
            } else if (ch == '&') {
                break;
            }
            i++;
        }

        string name;
        string value;
        if (pivotIndex >= 0) {
            name = paramsString.Substring(startIndex, pivotIndex - startIndex);
            value = paramsString.Substring(pivotIndex + 1, (i - pivotIndex) - 1);
        } else {
            name = paramsString.Substring(startIndex, i - startIndex);
            value = null;
        }

        dict.Add(UrlDecode(name), UrlDecode(value));

        // if string ends with ampersand, add another empty token
        if ((i == (length - 1)) && (paramsString[i] == '&'))
            dict.Add(null, string.Empty);
    }

    return dict;
}

It's just an example, but as you can see, .. if what you really need is already inside the .NET BCL... then why re-implement it? Just decompile the thing and re-implement it in Silverlight.

IMO most of what you'll be decompiling will probably be basic vanilla stuff "nice to haves" thats missing in Silverlight anyway so I don't think this'll raise any legal concerns.

Of course, you could re-implement the querystring parsing logic yourself but as you can see there're all the little details in there that you could have missed not to mention performance concerns.

chakrit
I'm not familiar with Reflector. Can you please provide more information about this? Is there a project web site?
Alimzhan Zhanseitov
http://www.red-gate.com/products/reflector/
Robert Kozak
You may also be interested in Silverlight Spy. http://silverlightspy.com/silverlightspy/
Robert Kozak
@Robert Kozak intersting tool there :)
chakrit