Standing on the shoulders of giants. RSS 2.0
# Tuesday, September 16, 2008

A nice method I discovered today:

System.Globalization.TextInfo.ToTitleCase(string)

This capitalizes the first letter of each word in the string, e.g. "hello world" becomes "Hello World".

Tuesday, September 16, 2008 4:30:19 PM (W. Europe Daylight Time, UTC+02:00)  #    Comments [1] - Trackback
Codesnippet
# Monday, September 15, 2008
public class Foo : IComparable<Foo>
{
    public Foo() { }

    public int Value { get; set; }

    public int CompareTo(Foo other)
    {
        if (other == null) { return 1; }

        return this.Value.CompareTo(other.Value);
    }
}

The trick is the line, which checks for the null comparison. Since null is always less than this, the method must return a value greater than zero (0).

Also see the remarks in the documentation:

Greater than zero: This object is greater than other.
...
By definition, any object compares greater than null (Nothing in Visual Basic), and two null references compare equal to each other.

Monday, September 15, 2008 5:55:47 PM (W. Europe Daylight Time, UTC+02:00)  #    Comments [0] - Trackback
Codesnippet
# Monday, September 08, 2008

55 more sessions have been added to an all ready full schedule making the current total 139 sessions and still more "secret" session will be announced at the PDC.

Highlights of the (new) sessions:

  • Parallel Symposium:
    • Addressing the Hard Problems with Concurrency
    • Application Opportunities and Architectures
    • Future of Parallel Computing
  • Services Symposium:
    • Enterprise Grade Cloud Applications
    • Expanding Applications to the Cloud
    • Projecting On Premises Applications to The Cloud
  • Service Bus Building Blocks: Connectivity, Messaging, Events, and Discovery
  • "Zermatt"
    • Deep Dive
    • Enabling Next Generation Identity
  • Windows CardSpace "2": Under the Hood

With the focus on "The Cloud", Parallel Computing and "Oslo" this looks like it will be a very interesting PDC. For more information about what "Oslo" is see both Don's and Doug's definitions.

[Current PDC08 Session List]

Monday, September 08, 2008 5:49:05 PM (W. Europe Daylight Time, UTC+02:00)  #    Comments [0] - Trackback
Conference | PDC2008
# Sunday, September 07, 2008

In the Managed Extensibility Framework source code on CodePlex is this 'preview' of the new Tuple class in the .NET Framework 4.0

// NOTE : this is a TEMPORARY and a very minimalistic implementation of Tuple'2,
// as defined in http://devdiv/sites/docs/NetFX4/CLR/Specs/Base Class Libraries/Tuple Spec.docx
// We will remove this after we move to v4 and Tuple is actually in there

[Via: Don Box's Spoutlet]

Sunday, September 07, 2008 7:55:08 PM (W. Europe Daylight Time, UTC+02:00)  #    Comments [0] - Trackback
BCL
# Saturday, September 06, 2008

A simple example to show how to use the SyndicationFeed class to load a feed and how to handle the items.

using System;
using System.Linq;
using System.ServiceModel.Syndication;
using System.Xml;

class Program
{
    static void Main(string[] args)
    {
        string feedUrl = "http://feeds.delicious.com/v2/rss/tags/paul.van.brenk";

        SyndicationFeed feed;

        using (XmlTextReader xReader = new XmlTextReader(feedUrl))
        {
            feed = SyndicationFeed.Load(xReader);
        }

        // max is more appropriate
        //var sum = feed.Items.Aggregate(0m, (x, y) => x += Decimal.Parse(y.Summary.Text));

        var max = feed.Items.Max(x => Decimal.Parse(x.Summary.Text));

        // select item title and relative weight for items with a relative weight > 0.1 
        var normItems = from i in feed.Items
                        where (Decimal.Parse(i.Summary.Text) / max) > 0.1m
                        select new { Title = i.Title.Text, Weight = Decimal.Parse(i.Summary.Text) / max };

        foreach (var item in normItems)
        {
            // 15 = highest possible value for consolecoler (Magic Number)
            Console.ForegroundColor = (ConsoleColor)(15 * item.Weight);
            Console.Write("{0} ", item.Title);
        }

        Console.ReadLine();
    }
}

Download code: ConsoleTagCloud.txt (1.22 KB)

Saturday, September 06, 2008 1:15:16 PM (W. Europe Daylight Time, UTC+02:00)  #    Comments [0] - Trackback
Codesnippet | Services
# Saturday, August 30, 2008

Joe Duffy is building a custom threadpool on his blog, exploring the different trade-offs:

The first threadpool he designs in part 1 is a very simple one, using a naive algorithme. The second one in part 2 is more interesting, since this allows threads to 'steal' work from each other and tries to take advantage of work still being in the memory cache by using a LIFO (Last In First Out) algorithm.

Update:

Part 3 was posted some time ago, which integrates the queue from part 2 in the pool from part 1.

Saturday, August 30, 2008 9:34:45 PM (W. Europe Daylight Time, UTC+02:00)  #    Comments [0] - Trackback
C#
# Friday, August 22, 2008

On Wednesday Lutz Roeder announced he has reached an agreement with Red Gate Software to continue the development of Reflector. It looks like this will prove to a good move for the product: Red Gate is able to make resources available for the future development of the product and has already opened a forum to get suggestions.

So thanks Lutz for this great tool and good luck to the team at Red Gate Software with the future development!

More info in this interview on Simple Talk.

Friday, August 22, 2008 10:10:12 AM (W. Europe Daylight Time, UTC+02:00)  #    Comments [0] - Trackback
Development
Ads
About
© Copyright 2010
Paul van Brenk
Sign In
newtelligence dasBlog 2.3.9074.18820
All Content © 2010, Paul van Brenk
DasBlog theme 'Business' created by Christoph De Baene (delarou)