In one of my projects, i thought i'd love to use operators like ==, !=, > and < style="color: rgb(51, 51, 255);font-size:85%;" > public static bool operator ==(BaseEventVO evt1, BaseEventVO evt2)
{
return (((object)evt1 == (object)evt2) || ((object)evt1 != null) && ((object)evt2 != null) && evt1.IdSeq == evt2.IdSeq && evt1.Year == evt2.Year);
}
public static bool operator !=(BaseEventVO evt1, BaseEventVO evt2)
{
return !(evt1 == evt2);
}
public static bool operator >(BaseEventVO evt1, BaseEventVO evt2)
{
return (evt1.Year > evt2.Year || (evt1.Year == evt2.Year && evt1.Day > evt2.Day));
}
public static bool operator <(BaseEventVO evt1, BaseEventVO evt2)
{
return (evt1.Year < evt2.Year || (evt1.Year == evt2.Year && evt1.Day < evt2.Day));
}
Notice the cast to "(object)evt1 != null" - it is necessary in order to prevent loopback - you can't do "evt1 != null" as it'd use the "!=" overridden operator, hence ending in effective infinite loop (until call-stack blows).
You may also want to override GetHashCode() to produce unique ID of the object - speeds up things very significantly when you do hashtable lookups.
Thursday, October 04, 2007
Saturday, September 29, 2007
Number Formatting in C# using String.Format
Just so that i remember it next time. Number formatting examples (for US english):
double x = 12345.6789;
String.Format("{0:n0}") ... 12,345
String.Format("{0:n1}") ... 12,345.6
etc...
double x = 12345.6789;
String.Format("{0:n0}") ... 12,345
String.Format("{0:n1}") ... 12,345.6
etc...
Thursday, September 27, 2007
Vaccination for Peru
When travelling to Peru, you'll need following:
Oh well, better be safe than sorry i guess...
To check current situation about travel health issues, goto CDC - especially the malaria is quite important.
- Tetanus
- Typhoid
- Hep A (if you do 2nd shot within a year, you get 10yrs immunity)
- Yellow fever
Oh well, better be safe than sorry i guess...
To check current situation about travel health issues, goto CDC - especially the malaria is quite important.
Recording video (AVI/SFW)
I'm doing quite a bit of demos lately and it's starting to take way too much time. Same with writing "how-to's" for new releases. So I decided to record short sessions where I demo how to use the software and ship them along with the ClickOnce deploy. Pretty sweet I must say and users seem to like it as well.
I'm using CamStudio - excellent tool, supports regions, converions, annotation, audio recording, etc. simply great!
I'm using CamStudio - excellent tool, supports regions, converions, annotation, audio recording, etc. simply great!
Thursday, September 13, 2007
TFS Install
I've ran into some issues during the TFS install. First, we'd like to use the dual server configuration (having DB server separate). What I didn't expect is limitation of TFS to default instance! Well, here seems to be a workaround (can't confirm it yet though) in case you need to use named instance as we do.
The install process is quite complex task too - Cliff's blog post is quite a nice summary of the core things to do.
The install process is quite complex task too - Cliff's blog post is quite a nice summary of the core things to do.
Monday, September 10, 2007
ASP.net Permissions - protecting non-asp.net content
The allow/deny approach works very well for all asp.net content, but i needed to secure all the documents in protected folders - namely PDF, XLS and DOC files.
Here is excellent description how to do it - it uses wildcard mapping feature of IIS.
Here is excellent description how to do it - it uses wildcard mapping feature of IIS.
Tuesday, September 04, 2007
ASP.NET 2.0 CSS Friendly Control Adapters
One of my students showed me this about a year ago and since then I've been looking for the link again. Basically, these adapters replace the table-oriented rendering of most of the ASP.Net build-in controls with light-weight "div" versions, that support CSS styling.
Anyway, check it out yourself...
Anyway, check it out yourself...
Subscribe to:
Posts (Atom)