[Csmail-patches] CVS: csmail/src/CSMail.Utils ChangeLog,1.12,1.13 Properties.cs,1.6,1.7
Status: Pre-Alpha
Brought to you by:
mastergaurav
From: Gaurav V. <mas...@us...> - 2002-10-01 10:34:01
|
Update of /cvsroot/csmail/csmail/src/CSMail.Utils In directory usw-pr-cvs1:/tmp/cvs-serv13396 Modified Files: ChangeLog Properties.cs Log Message: 2002-10-01 * Properties.cs : GetBool(string, bool) - Implemented. : GetInt(string, int) - Implemented. Index: ChangeLog =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail.Utils/ChangeLog,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- ChangeLog 30 Sep 2002 12:28:01 -0000 1.12 +++ ChangeLog 1 Oct 2002 10:33:58 -0000 1.13 @@ -1,4 +1,9 @@ +2002-10-01 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> + + * Properties.cs : GetBool(string, bool) - Implemented. + : GetInt(string, int) - Implemented. + 2002-09-30 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> * StringUtils.cs : Escape(string), Index: Properties.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail.Utils/Properties.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- Properties.cs 9 Sep 2002 06:23:58 -0000 1.6 +++ Properties.cs 1 Oct 2002 10:33:58 -0000 1.7 @@ -125,6 +125,39 @@ } } + public bool GetBool(string key, bool defaultValue) + { + object val = this[key]; + if(val != null && val is string) + { + string value = ((string) val).Trim(); + if(value.Length > 0) + { + if(defaultValue) + return (String.Compare(value, "false", false) != 0); + else + return (String.Compare(value, "true", false) == 0); + } + } + return defaultValue; + } + + public int GetInt(string key, int defaultValue) + { + object val = this[key]; + if(val != null && val is string) + { + string value = ((string)val).Trim(); + try + { + return int.Parse(value); + } catch(Exception) + { + } + } + return defaultValue; + } + internal static void GetKeyValue(string line, out string key, out string value) { |