Saturday, October 31, 2009

Can’t Debug inside some Classes ?

0 comments

Most probably it does not enter into auto generated classes(AltovaXML classes, …).

image

OR get rid of GeneratedCodeAttribute attribute.

Sunday, October 4, 2009

Implemeting IEnumerable<T>

0 comments

 

I always forget that there is something tricky when implementing templated IEnumerable.

IEnumerable<T>inherits from IEnumerable which has another method to cover.

So here is the example.

public class Sites : IEnumerable<Site>
{

    IEnumerator IEnumerable.GetEnumerator() { return theSites.GetEnumerator(); }
    public IEnumerator<Site> GetEnumerator() { return theSites.GetEnumerator(); }
}

Thursday, October 1, 2009

Danger: Events

1 comments

Before C# era, there were no such things as Events. But there were callbacks, ugly stuff to use. And now with C#, there are Events, comfortable, easy to use, subscribe, get notified from server, define event, fire it easy.

With C# there are 3 types of capabilities, class exposes:

Methods, Properties and Events.

 

Events=Methods with some extra subscription.

How do we decide, what Events are for and what Methods are for? More accurate question might be when to use Events and when Methods? The different between What and When might be the answer. Interested?

I think that the intention of Events is to let Client know WHEN something is done. This is a feedback, a follow up after Client was told WHAT to do.

And the intention of Methods is to let know Client WHAT to do.

So I try to consider these factors when defining Event and Method.