csmail-patches Mailing List for CS Mail API (Page 5)
Status: Pre-Alpha
Brought to you by:
mastergaurav
You can subscribe to this list here.
2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(36) |
Aug
(25) |
Sep
(49) |
Oct
(28) |
Nov
(2) |
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2003 |
Jan
(2) |
Feb
(5) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2004 |
Jan
|
Feb
(3) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Gaurav V. <mas...@us...> - 2002-08-29 10:13:53
|
Update of /cvsroot/csmail/csmail/src/CSMail.Utils In directory usw-pr-cvs1:/tmp/cvs-serv1913 Modified Files: ChangeLog Log Message: 2002-08-29 * ChangeLog - Fixed typo error Index: ChangeLog =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail.Utils/ChangeLog,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- ChangeLog 29 Aug 2002 10:12:50 -0000 1.6 +++ ChangeLog 29 Aug 2002 10:13:50 -0000 1.7 @@ -1,7 +1,7 @@ 2002-08-29 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> - * StringUtils.cs : New class in lieu of StingUtils. + * StringUtils.cs : New class in lieu of Utils. 2002-08-29 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> |
From: Gaurav V. <mas...@us...> - 2002-08-29 10:12:53
|
Update of /cvsroot/csmail/csmail/src/CSMail.Utils In directory usw-pr-cvs1:/tmp/cvs-serv1508 Modified Files: ChangeLog Added Files: StringUtils.cs Log Message: 2002-08-29 * StringUtils.cs : New class in lieu of StingUtils. --- NEW FILE --- /** * Namespace: CSMail.Utils * Class: StringUtils * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ using System; using System.IO; using CSMail; namespace CSMail.Utils { public class StringUtils { public static string[] SeparatePath(string path) { return path.Split(new char[] { Path.PathSeparator }); } } } Index: ChangeLog =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail.Utils/ChangeLog,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- ChangeLog 29 Aug 2002 10:11:13 -0000 1.5 +++ ChangeLog 29 Aug 2002 10:12:50 -0000 1.6 @@ -1,6 +1,10 @@ 2002-08-29 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> + * StringUtils.cs : New class in lieu of StingUtils. + +2002-08-29 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> + * Utils.cs : Renamed to StringUtils 2002-08-29 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> |
From: Gaurav V. <mas...@us...> - 2002-08-29 10:11:15
|
Update of /cvsroot/csmail/csmail/src/CSMail.Utils In directory usw-pr-cvs1:/tmp/cvs-serv824 Modified Files: ChangeLog Removed Files: Utils.cs Log Message: 2002-08-29 * Utils.cs : Renamed to StringUtils Index: ChangeLog =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail.Utils/ChangeLog,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- ChangeLog 29 Aug 2002 10:02:02 -0000 1.4 +++ ChangeLog 29 Aug 2002 10:11:13 -0000 1.5 @@ -1,6 +1,10 @@ 2002-08-29 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> + * Utils.cs : Renamed to StringUtils + +2002-08-29 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> + * Properties.cs : GetDefaultProperties - Implemented : CopyFrom - Implemented : MergeWith - Implemented --- Utils.cs DELETED --- |
From: Gaurav V. <mas...@us...> - 2002-08-29 10:03:36
|
Update of /cvsroot/csmail/csmail/src/CSMail.Utils In directory usw-pr-cvs1:/tmp/cvs-serv29470 Modified Files: Utils.cs Log Message: 2002-08-29 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> * Utils.cs : fixed bug for SeparatePath(string) Index: Utils.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail.Utils/Utils.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- Utils.cs 29 Aug 2002 10:02:02 -0000 1.1 +++ Utils.cs 29 Aug 2002 10:03:33 -0000 1.2 @@ -16,7 +16,7 @@ public class Utils { [MailTODO] - public static SeparatePath(string path) + public static string SeparatePath(string path) { throw new NotImplementedException(); } |
From: Gaurav V. <mas...@us...> - 2002-08-29 10:02:06
|
Update of /cvsroot/csmail/csmail/src/CSMail.Utils In directory usw-pr-cvs1:/tmp/cvs-serv28949 Modified Files: ChangeLog Properties.cs Added Files: Utils.cs Log Message: 2002-08-29 * Properties.cs : GetDefaultProperties - Implemented : CopyFrom - Implemented : MergeWith - Implemented : ConvertIfPossible - Implemented * Utils.cs : Added new utility class. --- NEW FILE --- /** * Namespace: CSMail.Utils * Class: Utils * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ using System; using CSMail; namespace CSMail.Utils { public class Utils { [MailTODO] public static SeparatePath(string path) { throw new NotImplementedException(); } } } Index: ChangeLog =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail.Utils/ChangeLog,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- ChangeLog 29 Aug 2002 07:03:04 -0000 1.3 +++ ChangeLog 29 Aug 2002 10:02:02 -0000 1.4 @@ -1,9 +1,18 @@ -2002-08-28 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> +2002-08-29 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> + + * Properties.cs : GetDefaultProperties - Implemented + : CopyFrom - Implemented + : MergeWith - Implemented + : ConvertIfPossible - Implemented + * Utils.cs : Added new utility class. + +2002-08-29 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> * Properties.cs : Indexer - Implemented : LoadFrom(string) - Implemented : LoadFrom(TextReader) - Implemented + : GetKeyValue(...) - Marked internal 2002-08-28 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> Index: Properties.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail.Utils/Properties.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- Properties.cs 29 Aug 2002 07:03:04 -0000 1.3 +++ Properties.cs 29 Aug 2002 10:02:02 -0000 1.4 @@ -42,11 +42,48 @@ } } + public static Properties GetDefaultProperties() + { + Properties retVal = new Properties(); + + foreach(object current in Environment.GetEnvironmentVariables().Keys) + { + if(current is string) + { + string cenv = (string) current; + string penv = ConvertIfPossible(cenv); + retVal[penv] = Environment.GetEnvironmentVariable(cenv); + } + } + + return retVal; + } + + private static string ConvertIfPossible(string env) + { + string retVal = env.ToUpper(); + switch(retVal) + { + case "CSMAIL_HOME" : retVal = "CSMail.home"; + break; + case "CSMAIL_PATH" : retVal = "CSMail.path"; + break; + case "HOME" : retVal = "user.home"; + break; + case "PATH" : retVal = "path"; + break; + default : retVal = env; + break; + } + + return retVal; + } + public static Properties LoadFrom(string filename) { return LoadFrom(new StreamReader(filename)); } - + public static Properties LoadFrom(TextReader reader) { string currentLine; @@ -68,8 +105,25 @@ } return retVal; } - - private static void GetKeyValue(string line, out string key, + + public void CopyFrom(Properties from) + { + foreach(string key in from.Keys) + { + this[key] = from[key]; + } + } + + public void MergeWith(Properties with) + { + foreach(string key in with.Keys) + { + if(!this.ContainsKey(key)) + this[key] = with[key]; + } + } + + internal static void GetKeyValue(string line, out string key, out string value) { int colon = line.IndexOfAny(Separators); @@ -84,4 +138,4 @@ } } } -} \ No newline at end of file +} |
From: Gaurav V. <mas...@us...> - 2002-08-29 07:03:10
|
Update of /cvsroot/csmail/csmail/src/CSMail.Utils In directory usw-pr-cvs1:/tmp/cvs-serv4311/CSMail.Utils Modified Files: ChangeLog Properties.cs Log Message: 2002-08-29 * CSMail/ProviderCollection.cs : Renamed to ProviderList * CSMail/ProviderList.cs : Renamed version of ProviderCollection * CSMail/Session.cs : Stubbed LoadProviders, LoadAddressMap * CSMail.Utils/Properties.cs : Indexer - Implemented : LoadFrom(string) - Implemented : LoadFrom(TextReader) - Implemented Index: ChangeLog =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail.Utils/ChangeLog,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- ChangeLog 28 Aug 2002 11:46:38 -0000 1.2 +++ ChangeLog 29 Aug 2002 07:03:04 -0000 1.3 @@ -1,6 +1,12 @@ 2002-08-28 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> + * Properties.cs : Indexer - Implemented + : LoadFrom(string) - Implemented + : LoadFrom(TextReader) - Implemented + +2002-08-28 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> + * Properties.cs : Stubbed "this[string]" property. 2002-06-20 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> Index: Properties.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail.Utils/Properties.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- Properties.cs 28 Aug 2002 11:44:20 -0000 1.2 +++ Properties.cs 29 Aug 2002 07:03:04 -0000 1.3 @@ -9,27 +9,79 @@ */ using System; +using System.Collections; +using System.IO; using CSMail; namespace CSMail.Utils { - public class Properties + /// <summary> + /// key = value + /// key : value + /// </summary> + public class Properties : Hashtable { - public Properties() + public static readonly char[] Separators = new char[] { + ':', + '=' + }; + + public Properties() : base() { } - [MailTODO] public string this[string key] { get { - throw new NotImplementedException(); + return (string)base[key]; } set { - throw new NotImplementedException(); + base[key] = value; + } + } + + public static Properties LoadFrom(string filename) + { + return LoadFrom(new StreamReader(filename)); + } + + public static Properties LoadFrom(TextReader reader) + { + string currentLine; + string key; + string value; + Properties retVal = new Properties(); + + while((currentLine = reader.ReadLine()) != null) + { + currentLine = currentLine.Trim(); + if(currentLine[0] != '#') + { + GetKeyValue(currentLine, out key, out value); + if(key != null && value != null) + { + retVal[key] = value; + } + } + } + return retVal; + } + + private static void GetKeyValue(string line, out string key, + out string value) + { + int colon = line.IndexOfAny(Separators); + key = null; + value = null; + if(colon > 0) + { + key = line.Substring(0, colon); + key = key.Trim(); + value = line.Substring(colon + 1); + value = value.Trim(); } } } -} +} \ No newline at end of file |
From: Gaurav V. <mas...@us...> - 2002-08-29 07:03:09
|
Update of /cvsroot/csmail/csmail/src/CSMail In directory usw-pr-cvs1:/tmp/cvs-serv4311/CSMail Modified Files: ChangeLog Session.cs Added Files: ProviderList.cs Removed Files: ProviderCollection.cs Log Message: 2002-08-29 * CSMail/ProviderCollection.cs : Renamed to ProviderList * CSMail/ProviderList.cs : Renamed version of ProviderCollection * CSMail/Session.cs : Stubbed LoadProviders, LoadAddressMap * CSMail.Utils/Properties.cs : Indexer - Implemented : LoadFrom(string) - Implemented : LoadFrom(TextReader) - Implemented --- NEW FILE --- /** * Namespace: CSMail * Class: ProviderList * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ using System.Collections; namespace CSMail { public class ProviderList : IEnumerable { private ArrayList providers = new ArrayList(); public ProviderCollection() { } public IEnumerator GetEnumerator() { return providers.GetEnumerator(); } } } Index: ChangeLog =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/ChangeLog,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- ChangeLog 29 Aug 2002 04:10:11 -0000 1.10 +++ ChangeLog 29 Aug 2002 07:03:03 -0000 1.11 @@ -1,6 +1,12 @@ 2002-08-29 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> + * ProviderCollection.cs : Renamed to ProviderList + * ProviderList.cs : Renamed version of ProviderCollection + * Session.cs : Stubbed LoadProviders, LoadAddressMap + +2002-08-29 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> + * ProviderCollection.cs : Added class. * Session.cs : Added property Debug Index: Session.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/Session.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- Session.cs 29 Aug 2002 04:10:11 -0000 1.5 +++ Session.cs 29 Aug 2002 07:03:04 -0000 1.6 @@ -46,6 +46,9 @@ addrMap = new Properties(); debug = bool.Parse(this.properties["CSMail.debug"]); + + this.LoadProviders(); + this.LoadAddressMap(); } public bool Debug @@ -87,6 +90,36 @@ public static Session GetDefaultInstance(Properties properties) { return GetDefaultInstance(properties, null); + } + + /// <summary> + /// Loads from the following files: + /// 1. $CSMAIL_HOME/config/CSMail.properties + /// 2. each { $CSMAIL_PATH }/config/CSMail.properties + /// 3. $PWD/config/CSMail.properties + /// 4. $PWD/config/CSMail.properties.default + /// 5. Load default providers* + /// + /// * To be provided later by CSMail itself. + /// </summary> + private void LoadProviders() + { + // Load from the file. + } + + /// <summary> + /// Loads from the following files: + /// 1. $CSMAIL_HOME/config/CSMail.adress.map + /// 2. each { $CSMAIL_PATH }/config/CSMail.adress.map + /// 3. $PWD/config/CSMail.adress.map + /// 4. $PWD/config/CSMail.adress.map.default + /// 5. Load default map* + /// + /// * To be provided later by CSMail itself. + /// </summary> + private void LoadAddressMap() + { + // Load from the file. } } } --- ProviderCollection.cs DELETED --- |
From: Gaurav V. <mas...@us...> - 2002-08-29 04:10:14
|
Update of /cvsroot/csmail/csmail/src/CSMail In directory usw-pr-cvs1:/tmp/cvs-serv31294 Modified Files: ChangeLog Provider.cs Session.cs Added Files: ProviderCollection.cs Log Message: 2002-08-29 * ProviderCollection.cs : Added class. * Session.cs : Added property Debug --- NEW FILE --- /** * Namespace: CSMail * Class: ProviderCollection * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ using System.Collections; namespace CSMail { public class ProviderCollection : IEnumerable { private ArrayList providers = new ArrayList(); public ProviderCollection() { } } } Index: ChangeLog =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/ChangeLog,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- ChangeLog 28 Aug 2002 11:46:38 -0000 1.9 +++ ChangeLog 29 Aug 2002 04:10:11 -0000 1.10 @@ -1,7 +1,12 @@ +2002-08-29 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> + + * ProviderCollection.cs : Added class. + * Session.cs : Added property Debug + 2002-08-28 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> - * Providers.cs : Completed. + * Provider.cs : Completed. * Properties.cs : Made contructor public. * Session.cs : Working on it. Index: Provider.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/Provider.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- Provider.cs 28 Aug 2002 11:44:20 -0000 1.2 +++ Provider.cs 29 Aug 2002 04:10:11 -0000 1.3 @@ -69,7 +69,7 @@ return version; } } - + public override string ToString() { String retVal = "CSMail.Provider["; Index: Session.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/Session.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- Session.cs 28 Aug 2002 11:44:20 -0000 1.4 +++ Session.cs 29 Aug 2002 04:10:11 -0000 1.5 @@ -48,6 +48,18 @@ debug = bool.Parse(this.properties["CSMail.debug"]); } + public bool Debug + { + get + { + return debug; + } + set + { + debug = value; + } + } + public static Session GetInstance(Properties props, Authenticator auth) { return new Session(props, auth); |
From: Gaurav V. <mas...@us...> - 2002-08-28 11:46:42
|
Update of /cvsroot/csmail/csmail/src/CSMail.Utils In directory usw-pr-cvs1:/tmp/cvs-serv31805/CSMail.Utils Modified Files: ChangeLog Log Message: 2002-08-28 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> * CSMail/ChangeLog CSMail.Utils/ChangeLog -- Updated properly Index: ChangeLog =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail.Utils/ChangeLog,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- ChangeLog 20 Jun 2002 11:20:37 -0000 1.1 +++ ChangeLog 28 Aug 2002 11:46:38 -0000 1.2 @@ -1,4 +1,8 @@ +2002-08-28 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> + + * Properties.cs : Stubbed "this[string]" property. + 2002-06-20 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> * Properties.cs: Added file. Dummy class right now. |
From: Gaurav V. <mas...@us...> - 2002-08-28 11:46:42
|
Update of /cvsroot/csmail/csmail/src/CSMail In directory usw-pr-cvs1:/tmp/cvs-serv31805/CSMail Modified Files: ChangeLog Log Message: 2002-08-28 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> * CSMail/ChangeLog CSMail.Utils/ChangeLog -- Updated properly Index: ChangeLog =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/ChangeLog,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- ChangeLog 28 Aug 2002 11:44:20 -0000 1.8 +++ ChangeLog 28 Aug 2002 11:46:38 -0000 1.9 @@ -4,7 +4,6 @@ * Providers.cs : Completed. * Properties.cs : Made contructor public. * Session.cs : Working on it. - * Properties.cs : Stubbed "this[string]" property. 2002-08-28 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> |
From: Gaurav V. <mas...@us...> - 2002-08-28 11:44:23
|
Update of /cvsroot/csmail/csmail/src/CSMail In directory usw-pr-cvs1:/tmp/cvs-serv30170/CSMail Modified Files: ChangeLog Provider.cs Session.cs Log Message: 2002-08-28 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> * CSMail/Providers.cs : Completed. * CSMail/Properties.cs : Made contructor public. * CSMail/Session.cs : Working on it. * CSMail.Utils/Properties.cs : Stubbed "this[string]" property. Index: ChangeLog =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/ChangeLog,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- ChangeLog 28 Aug 2002 10:25:52 -0000 1.7 +++ ChangeLog 28 Aug 2002 11:44:20 -0000 1.8 @@ -1,6 +1,13 @@ 2002-08-28 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> + * Providers.cs : Completed. + * Properties.cs : Made contructor public. + * Session.cs : Working on it. + * Properties.cs : Stubbed "this[string]" property. + +2002-08-28 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> + * Folder.cs : Removed "MailTODO" from "ToString()" 2002-08-28 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> Index: Provider.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/Provider.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- Provider.cs 20 Jun 2002 10:34:55 -0000 1.1 +++ Provider.cs 28 Aug 2002 11:44:20 -0000 1.2 @@ -20,21 +20,14 @@ private string vendor; private string version; - internal Provider() + public Provider(ProviderType type, string protocol, string className, + string vendor, string version) { - //TODO: Initialize the values from the configuration file - Initialize(String.Empty); - } - - internal Provider(string configFile) - { - Initialize(configFile); - } - - [MailTODO] - internal void Initialize(string configFile) - { - throw new NotImplementedException(); + this.type = type; + this.protocol = protocol; + this.className = className; + this.vendor = vendor; + this.version = version; } public string ClassName @@ -75,6 +68,26 @@ { return version; } + } + + public override string ToString() + { + String retVal = "CSMail.Provider["; + switch(type) + { + case ProviderType.Store: retVal += "STORE,"; + break; + case ProviderType.Transport: retVal += "TRANSPORT,"; + break; + default : break; + } + retVal += (protocol + "," + className); + if(vendor != null) + retVal += ("," + vendor); + if(version != null) + retVal += ("," + version); + retVal += "]"; + return retVal; } } } Index: Session.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/Session.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- Session.cs 28 Aug 2002 10:17:12 -0000 1.3 +++ Session.cs 28 Aug 2002 11:44:20 -0000 1.4 @@ -8,15 +8,16 @@ * (C) Gaurav Vaish (2002) */ +using System; using System.Collections; using CSMail.Utils; namespace CSMail { - public class Session + public sealed class Session { - private Properties properties; - private Authenticator authenticator; + private readonly Properties properties; + private readonly Authenticator authenticator; private Hashtable authTable; private ArrayList providers; private Hashtable provByProto; @@ -26,6 +27,8 @@ private static Session defaultSession; + private const string CSMailVersion = "0.1"; + private Session() { } @@ -40,19 +43,38 @@ providers = new ArrayList(); provByProto = new Hashtable(); provByClass = new Hashtable(); - //addrMap = new Properties(); + addrMap = new Properties(); + + debug = bool.Parse(this.properties["CSMail.debug"]); + } - // debug = bool.Parse(this.properties["mail.debug"]) + public static Session GetInstance(Properties props, Authenticator auth) + { + return new Session(props, auth); } - public Session GetDefaultInstance(Properties properties, Authenticator authenticator) + public static Session GetInstance(Properties props) + { + return new Session(props, null); + } + + public static Session GetDefaultInstance(Properties properties, + Authenticator authenticator) { if(defaultSession == null) { - defaultSession = new Session(); - // Do some initialization??? + defaultSession = new Session(properties, authenticator); + } else + { + if(defaultSession.authenticator != authenticator) + throw new Exception("Access to default session denied"); } return defaultSession; + } + + public static Session GetDefaultInstance(Properties properties) + { + return GetDefaultInstance(properties, null); } } } |
From: Gaurav V. <mas...@us...> - 2002-08-28 11:44:23
|
Update of /cvsroot/csmail/csmail/src/CSMail.Utils In directory usw-pr-cvs1:/tmp/cvs-serv30170/CSMail.Utils Modified Files: Properties.cs Log Message: 2002-08-28 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> * CSMail/Providers.cs : Completed. * CSMail/Properties.cs : Made contructor public. * CSMail/Session.cs : Working on it. * CSMail.Utils/Properties.cs : Stubbed "this[string]" property. Index: Properties.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail.Utils/Properties.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- Properties.cs 20 Jun 2002 11:20:37 -0000 1.1 +++ Properties.cs 28 Aug 2002 11:44:20 -0000 1.2 @@ -8,12 +8,28 @@ * (C) Gaurav Vaish (2002) */ +using System; +using CSMail; + namespace CSMail.Utils { public class Properties { - private Properties() + public Properties() { + } + + [MailTODO] + public string this[string key] + { + get + { + throw new NotImplementedException(); + } + set + { + throw new NotImplementedException(); + } } } } |
From: Gaurav V. <mas...@us...> - 2002-08-28 10:25:54
|
Update of /cvsroot/csmail/csmail/src/CSMail In directory usw-pr-cvs1:/tmp/cvs-serv28092 Modified Files: Folder.cs ChangeLog Log Message: 2002-08-28 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> * Folder.cs : Removed "MailTODO" from "ToString()" Index: Folder.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/Folder.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- Folder.cs 28 Aug 2002 10:17:12 -0000 1.2 +++ Folder.cs 28 Aug 2002 10:25:52 -0000 1.3 @@ -165,7 +165,6 @@ return retVal; } - [MailTODO] public override string ToString() { String fn = FullName; Index: ChangeLog =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/ChangeLog,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- ChangeLog 28 Aug 2002 10:17:12 -0000 1.6 +++ ChangeLog 28 Aug 2002 10:25:52 -0000 1.7 @@ -1,6 +1,10 @@ 2002-08-28 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> + * Folder.cs : Removed "MailTODO" from "ToString()" + +2002-08-28 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> + * Authenticator.cs : Added class. * IllegalStateException.cs : Added exception class. * FolderOpenMode.cs : Added fields "Default", "NotSet" |
From: Gaurav V. <mas...@us...> - 2002-08-28 10:17:15
|
Update of /cvsroot/csmail/csmail/src/CSMail In directory usw-pr-cvs1:/tmp/cvs-serv23610 Modified Files: ChangeLog Folder.cs FolderOpenMode.cs InternetAddress.cs InternetAddressList.cs MessageFlags.cs Session.cs Added Files: Authenticator.cs IllegalStateException.cs MessageRemovedException.cs Log Message: 2002-08-28 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> * Authenticator.cs : Added class. * IllegalStateException.cs : Added exception class. * FolderOpenMode.cs : Added fields "Default", "NotSet" * MessageFlags.cs : Reformatting of flags. * Folder.cs : Constructor. Parameter is Store, not Session : Count { get; } - Made abstract : Exists { get; } - Made abstract : Messages { get; } - Made abstract : Mode { get; } - Implemented : Name { get; } - Made abstract : Store { get; } - Implemented : URL { get; } - Implemented : DeletedMessageCount { get; } - Added, implemented : NewMessageCount { get; } - Added, implemented : UnreadMessageCount { get; } - Implemented : Destructor - Removed : GetMessages(int, int) - Implemented : GetMessages(int[]) - Implemented * InternetAddressList.cs : Removed "public" from IAdress.Add(IAddress) : Implemented the "IAddressList" methods. * Session.cs : Typo bug fixed. * InternetAddress.cs : Fixed minor bugs. --- NEW FILE --- /** * Namespace: CSMail * Class: Authenticator * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ namespace CSMail { public class Authenticator { public Authenticator() { } } } --- NEW FILE --- /** * Namespace: CSMail * Class: IllegalStateException * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ using System; namespace CSMail { public class IllegalStateException : Exception { public IllegalStateException() : base() { } public IllegalStateException(string message) : base(message) { } } } --- NEW FILE --- /** * Namespace: CSMail * Class: MessageRemovedException * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ using System; namespace CSMail { public class MessageRemovedException : Exception { public MessageRemovedException() : base() { } public MessageRemovedException(string message) : base(message) { } } } Index: ChangeLog =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/ChangeLog,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- ChangeLog 26 Jul 2002 06:54:13 -0000 1.5 +++ ChangeLog 28 Aug 2002 10:17:12 -0000 1.6 @@ -1,4 +1,30 @@ +2002-08-28 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> + + * Authenticator.cs : Added class. + * IllegalStateException.cs : Added exception class. + * FolderOpenMode.cs : Added fields "Default", "NotSet" + * MessageFlags.cs : Reformatting of flags. + * Folder.cs : Constructor. Parameter is Store, not Session + : Count { get; } - Made abstract + : Exists { get; } - Made abstract + : Messages { get; } - Made abstract + : Mode { get; } - Implemented + : Name { get; } - Made abstract + : Store { get; } - Implemented + : URL { get; } - Implemented + : DeletedMessageCount { get; } - Added, + implemented + : NewMessageCount { get; } - Added, implemented + : UnreadMessageCount { get; } - Implemented + : Destructor - Removed + : GetMessages(int, int) - Implemented + : GetMessages(int[]) - Implemented + * InternetAddressList.cs : Removed "public" from IAdress.Add(IAddress) + : Implemented the "IAddressList" methods. + * Session.cs : Typo bug fixed. + * InternetAddress.cs : Fixed minor bugs. + 2002-07-26 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> * InternetAddressList.cs : Completed. Well almost. Index: Folder.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/Folder.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- Folder.cs 20 Jun 2002 02:43:24 -0000 1.1 +++ Folder.cs 28 Aug 2002 10:17:12 -0000 1.2 @@ -18,93 +18,97 @@ { public abstract class Folder //: IEnumerable { - private Session session; + protected Store store; + protected FolderOpenMode mode; - protected Folder(Session session) + private object lockObj; + + protected Folder(Store store) { - this.session = session; + this.store = store; + this.mode = FolderOpenMode.NotSet; + this.lockObj = new object(); } public abstract char Delimiter { get; } public abstract FolderType FolderType { get; } + public abstract bool Exists { get; } public abstract bool HasNewMessages { get; } public abstract bool IsOpen { get; } public abstract bool IsSubscribed { get; } + public abstract char Separator { get; } public abstract Folder Parent { get; } + public abstract int Count { get; } public abstract string FullName { get; } + public abstract string Name { get; } public abstract MessageFlags PermanentFlags { get; } public abstract Folder[] Children { get; } public abstract Folder[] SubscribedFolders { get; } + public abstract Message[] Messages { get; } - [MailTODO] - public int Count + public FolderOpenMode Mode { get { - throw new NotImplementedException(); + if(IsOpen) + { + return this.mode; + } + throw new IllegalStateException("[Mode] Folder closed"); } } - [MailTODO] - public bool Exists + public int NewMessageCount { get { - throw new NotImplementedException(); + return getMessageCount(MessageFlags.Recent); } } - - [MailTODO] - public Message[] Messages + + public int UnreadMessageCount { get { - throw new NotImplementedException(); + return getMessageCount(MessageFlags.Seen); } } - [MailTODO] - public FolderOpenMode Mode + public int DeletedMessageCount { get { - throw new NotImplementedException(); + return getMessageCount(MessageFlags.Deleted); } } - [MailTODO] - public string Name + private int getMessageCount(MessageFlags flag) { - get + if(!IsOpen) { - throw new NotImplementedException(); + return -1; } - } - [MailTODO] - public int NewMessageCount - { - get + int rv = 0; + int mc = Count; + for(int i = 0; i < mc; i++) { - throw new NotImplementedException(); + try + { + if(Messages[i].IsSet(flag)) + rv++; + } catch(MessageRemovedException) + { + } } + return rv; } - [MailTODO] public Store Store { get { - throw new NotImplementedException(); - } - } - - [MailTODO] - public int UnreadMessageCount - { - get - { - throw new NotImplementedException(); + return this.store; } } @@ -113,7 +117,11 @@ { get { - throw new NotImplementedException(); + URLName retVal = Store.URL; + String fn = (FullName == null ? String.Empty : FullName); + char c = Separator; + return new URLName(retVal.Protocol, retVal.Host, retVal.Port, + retVal.Username, retVal.Password, null); } } @@ -127,28 +135,43 @@ public abstract void Open(FolderOpenMode mode); public abstract bool RenameTo(Folder newFolder); +/* [MailTODO] ~Folder() { throw new NotImplementedException(); } - - [MailTODO] +*/ public Message[] GetMessages(int[] indices) { - throw new NotImplementedException(); + int len = indices.Length; + Message[] retVal = new Message[len]; + for(int i = 0; i < len; i++) + { + retVal[i] = Messages[indices[i]]; + } + return retVal; } - [MailTODO] public Message[] GetMessages(int start, int stop) { - throw new NotImplementedException(); + if(start > stop) + return null; + Message[] retVal = new Message[stop - start + 1]; + for(int i = 0; i < (stop - start + 1); i++) + { + retVal[i] = Messages[i + start]; + } + return retVal; } [MailTODO] public override string ToString() { - throw new NotImplementedException(); + String fn = FullName; + if(fn != null) + return fn.ToString(); + return base.ToString(); } } } Index: FolderOpenMode.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/FolderOpenMode.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- FolderOpenMode.cs 20 Jun 2002 02:43:24 -0000 1.1 +++ FolderOpenMode.cs 28 Aug 2002 10:17:12 -0000 1.2 @@ -12,6 +12,8 @@ { public enum FolderOpenMode { + Default, + NotSet, ReadOnly, ReadWrite } Index: InternetAddress.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/InternetAddress.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- InternetAddress.cs 26 Jul 2002 06:54:13 -0000 1.3 +++ InternetAddress.cs 28 Aug 2002 10:17:12 -0000 1.4 @@ -29,8 +29,8 @@ { hostname = hostname.Trim(); this.hostname = hostname; - this.protocol = procotol; - if(CheckIfIP(hostname)) + this.protocol = protocol; + if(CheckIfIP4(hostname)) { isIP = true; } @@ -43,11 +43,11 @@ /// </summary> public InternetAddress(int[] ip, string protocol) { - if(!ValidIP(ip)) + if(!ValidIP4(ip)) { throw new ArgumentException(); } - this.protocol = procotol; + this.protocol = protocol; this.ip = new int[4]; int i = 0; foreach(int current in ip) @@ -135,7 +135,7 @@ public override string ToString() { string retVal; - retVal = procotol + "://"; + retVal = protocol + "://"; retVal += hostname; return retVal; } Index: InternetAddressList.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/InternetAddressList.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- InternetAddressList.cs 26 Jul 2002 06:54:13 -0000 1.2 +++ InternetAddressList.cs 28 Aug 2002 10:17:12 -0000 1.3 @@ -61,7 +61,7 @@ { if(index < 0 || index > Count) return null; - return addresses[index]; + return (InternetAddress)addresses[index]; } } @@ -82,7 +82,17 @@ return addresses.Count; } - public int IAddress.Add(IAddress address) + public void AddAt(int index, InternetAddress address) + { + addresses.Insert(index, address); + } + + public InternetAddress GetAddress(int index) + { + return (InternetAddress)addresses[index]; + } + + int IAddressList.Add(IAddress address) { if(address is InternetAddress) { @@ -91,6 +101,28 @@ return addresses.Count; } + void IAddressList.AddAt(int index, IAddress address) + { + if(address is InternetAddress) + AddAt(index, (InternetAddress)address); + } + + IAddress IAddressList.GetAddress(int index) + { + return (IAddress)GetAddress(index); + } + + void IAddressList.Remove(IAddress address) + { + if(address is InternetAddress) + Remove((InternetAddress)address); + } + + public void Remove(InternetAddress address) + { + addresses.Remove(address); + } + public void Clear() { addresses.Clear(); @@ -109,7 +141,7 @@ i = 0; foreach(InternetAddress current in this) { - if(String.Compare(current.Hostname, current, ignoreCase) == 0) + if(String.Compare(current.Hostname, address, ignoreCase) == 0) { return i; } @@ -119,11 +151,6 @@ return -1; } - public void Remove(InternetAddress address) - { - addresses.Remove(address); - } - public void RemoveAt(int index) { if(index >= 0 && index < Count) @@ -148,7 +175,7 @@ index = FindByValue(current, ignoreCase); if(index >= 0 && index < Count) { - if(!delete.Contains(this[index]) + if(!delete.Contains(this[index])) { delete.Add(this[index]); } @@ -162,11 +189,16 @@ } } + public IEnumerator GetEnumerator() + { + return addresses.GetEnumerator(); + } + /// <summary> /// Returns a CRLF separated list of Addresses. /// Do I need to take care of anything??? /// </summray> - public string ToString() + public override string ToString() { string retVal = String.Empty; foreach(InternetAddress current in this) Index: MessageFlags.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/MessageFlags.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- MessageFlags.cs 20 Jun 2002 02:43:25 -0000 1.1 +++ MessageFlags.cs 28 Aug 2002 10:17:12 -0000 1.2 @@ -16,12 +16,12 @@ public enum MessageFlags { None = 0x0000, - Answered = 0x0001, - Deleted = 0x0002, - Draft = 0x0004, - Flagged = 0x0010, - Recent = 0x0020, - Seen = 0x0040, - UserDefined = 0x8000, + Answered = 0x0001 << 0, + Deleted = 0x0001 << 1, + Draft = 0x0001 << 2, + Flagged = 0x0001 << 3, + Recent = 0x0001 << 4, + Seen = 0x0001 << 5, + UserDefined = 0x0001 << 15, } } Index: Session.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/Session.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- Session.cs 20 Jun 2002 11:16:13 -0000 1.2 +++ Session.cs 28 Aug 2002 10:17:12 -0000 1.3 @@ -16,7 +16,7 @@ public class Session { private Properties properties; - private Authentiactor authenticator; + private Authenticator authenticator; private Hashtable authTable; private ArrayList providers; private Hashtable provByProto; @@ -40,7 +40,7 @@ providers = new ArrayList(); provByProto = new Hashtable(); provByClass = new Hashtable(); - addrMap = new Properties(); + //addrMap = new Properties(); // debug = bool.Parse(this.properties["mail.debug"]) } |
From: Gaurav V. <mas...@us...> - 2002-07-26 06:54:16
|
Update of /cvsroot/csmail/csmail/src/CSMail In directory usw-pr-cvs1:/tmp/cvs-serv30511/src/CSMail Modified Files: ChangeLog InternetAddress.cs InternetAddressList.cs Log Message: 2002-07-26 Gaurav Vaish <mastergaurav> * CSMailAPI.xml : Removed InternetAddressList::Set(int, InternetAddress) Added parameter (bool) to InternetAddressList::FindByValue(string) Added parameter (bool) to InternetAddressList::RemoveFirst(string) Added parameter (bool) to InternetAddressList::Remove(string[]) Removed parameter (int) from InternetAddressList::ToString(int) * InternetAddressList.cs : Completed. Well almost. Index: ChangeLog =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/ChangeLog,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- ChangeLog 25 Jul 2002 11:24:14 -0000 1.4 +++ ChangeLog 26 Jul 2002 06:54:13 -0000 1.5 @@ -1,4 +1,8 @@ +2002-07-26 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> + + * InternetAddressList.cs : Completed. Well almost. + 2002-07-25 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> * Header.cs : Added comment for ToString() method. Index: InternetAddress.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/InternetAddress.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- InternetAddress.cs 25 Jul 2002 11:24:14 -0000 1.2 +++ InternetAddress.cs 26 Jul 2002 06:54:13 -0000 1.3 @@ -10,18 +10,26 @@ using System; +/** + * The class currently does not support the a full URL of the type + * prot://user:pass@hostname:port/filepath#ref + * As of now, it understands only prot://hostname + */ + namespace CSMail { public class InternetAddress { private string hostname; + private string protocol; private int[] ip; private bool isIP; - public InternetAddress(string hostname) + public InternetAddress(string hostname, string protocol) { hostname = hostname.Trim(); this.hostname = hostname; + this.protocol = procotol; if(CheckIfIP(hostname)) { isIP = true; @@ -33,12 +41,13 @@ /// the IP_V6 format IPs, I have to first go through the /// documentations. /// </summary> - public InternetAddress(int[] ip) + public InternetAddress(int[] ip, string protocol) { if(!ValidIP(ip)) { throw new ArgumentException(); } + this.protocol = procotol; this.ip = new int[4]; int i = 0; foreach(int current in ip) @@ -64,6 +73,14 @@ return isIP; } } + + public string Protocol + { + get + { + return protocol; + } + } public int[] getIP { @@ -113,6 +130,14 @@ return false; } return true; + } + + public override string ToString() + { + string retVal; + retVal = procotol + "://"; + retVal += hostname; + return retVal; } } } Index: InternetAddressList.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/InternetAddressList.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- InternetAddressList.cs 25 Jul 2002 11:24:14 -0000 1.1 +++ InternetAddressList.cs 26 Jul 2002 06:54:13 -0000 1.2 @@ -46,7 +46,134 @@ } } } - - + + public int Count + { + get + { + return addresses.Count; + } + } + + public InternetAddress this[int index] + { + get + { + if(index < 0 || index > Count) + return null; + return addresses[index]; + } + } + + public int Add(InternetAddress address) + { + return addresses.Add(address); + } + + public int Add(InternetAddressList address) + { + foreach(InternetAddress current in address) + { + if(current != null) + { + addresses.Add(current); + } + } + return addresses.Count; + } + + public int IAddress.Add(IAddress address) + { + if(address is InternetAddress) + { + addresses.Add((InternetAddress)address); + } + return addresses.Count; + } + + public void Clear() + { + addresses.Clear(); + } + + public int IndexOf(InternetAddress address) + { + return addresses.IndexOf(address); + } + + public int FindByValue(string address, bool ignoreCase) + { + int i; + if(address != null && address.Length > 0) + { + i = 0; + foreach(InternetAddress current in this) + { + if(String.Compare(current.Hostname, current, ignoreCase) == 0) + { + return i; + } + i++; + } + } + return -1; + } + + public void Remove(InternetAddress address) + { + addresses.Remove(address); + } + + public void RemoveAt(int index) + { + if(index >= 0 && index < Count) + { + addresses.RemoveAt(index); + } + } + + public void RemoveFirst(string address, bool ignoreCase) + { + RemoveAt(FindByValue(address, ignoreCase)); + } + + public void Remove(string[] addresses, bool ignoreCase) + { + ArrayList delete = new ArrayList(); + int index; + foreach(string current in addresses) + { + if(current != null) + { + index = FindByValue(current, ignoreCase); + if(index >= 0 && index < Count) + { + if(!delete.Contains(this[index]) + { + delete.Add(this[index]); + } + } + } + } + + foreach(InternetAddress current in delete) + { + this.addresses.Remove(current); + } + } + + /// <summary> + /// Returns a CRLF separated list of Addresses. + /// Do I need to take care of anything??? + /// </summray> + public string ToString() + { + string retVal = String.Empty; + foreach(InternetAddress current in this) + { + retVal += (current.ToString() + "\r\n"); + } + return retVal; + } } } |
From: Gaurav V. <mas...@us...> - 2002-07-26 06:54:16
|
Update of /cvsroot/csmail/csmail/docs In directory usw-pr-cvs1:/tmp/cvs-serv30511/docs Modified Files: ChangeLog csMailAPI.xml Log Message: 2002-07-26 Gaurav Vaish <mastergaurav> * CSMailAPI.xml : Removed InternetAddressList::Set(int, InternetAddress) Added parameter (bool) to InternetAddressList::FindByValue(string) Added parameter (bool) to InternetAddressList::RemoveFirst(string) Added parameter (bool) to InternetAddressList::Remove(string[]) Removed parameter (int) from InternetAddressList::ToString(int) * InternetAddressList.cs : Completed. Well almost. Index: ChangeLog =================================================================== RCS file: /cvsroot/csmail/csmail/docs/ChangeLog,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- ChangeLog 25 Jul 2002 11:24:14 -0000 1.2 +++ ChangeLog 26 Jul 2002 06:54:13 -0000 1.3 @@ -1,8 +1,21 @@ +2002-07-26 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> + + * CSMailAPI.xml : Removed + InternetAddressList::Set(int, InternetAddress) + Added parameter (bool) to + InternetAddressList::FindByValue(string) + Added parameter (bool) to + InternetAddressList::RemoveFirst(string) + Added parameter (bool) to + InternetAddressList::Remove(string[]) + Removed parameter (int) from + InternetAddressList::ToString(int) + 2002-07-25 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> - * CSMailAPI.xml : Removed property "Empty" from - class InternetAddressList. No Need. + * CSMailAPI.xml : Removed property "Empty" from + class InternetAddressList. No Need. 2002-06-19 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> Index: csMailAPI.xml =================================================================== RCS file: /cvsroot/csmail/csmail/docs/csMailAPI.xml,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- csMailAPI.xml 25 Jul 2002 11:24:14 -0000 1.5 +++ csMailAPI.xml 26 Jul 2002 06:54:13 -0000 1.6 @@ -414,15 +414,12 @@ <param name="addresses" type="InternetAddressList"/> </method> <method name="Clear" return="void"/> - <method name="Set" return="void"> - <param name="index" type="int"/> - <param name="address" type="InternetAddress"/> - </method> <method name="IndexOf" return="int"> <param name="address" type="InternetAddress"/> </method> <method name="FindByValue" return="int"> <param name="address" type="string"/> + <param name="ignoreCase" type="bool"/> </method> <method name="Item" return="InternetAddress"> <param name="index" type="int"/> @@ -435,13 +432,13 @@ </method> <method name="RemoveFirst" return="InternetAddress"> <param name="address" type="string"/> + <param name="ignoreCase" type="bool"/> </method> <method name="Remove" return="InternetAddress[]"> <param name="addresses" type="string[]"/> + <param name="ignoreCase" type="bool"/> </method> - <method name="ToString" return="string"> - <param name="index" type="int"/> - </method> + <method name="ToString" return="string"/> <implements> <interface name="IAddressList"/> <interface name="IEnumerable"/> |
From: Gaurav V. <mas...@us...> - 2002-07-25 11:24:17
|
Update of /cvsroot/csmail/csmail/docs In directory usw-pr-cvs1:/tmp/cvs-serv29772/docs Modified Files: ChangeLog csMailAPI.xml Log Message: 2002-07-25 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> * *.*/*: See ChangeLog Index: ChangeLog =================================================================== RCS file: /cvsroot/csmail/csmail/docs/ChangeLog,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- ChangeLog 20 Jun 2002 02:46:17 -0000 1.1 +++ ChangeLog 25 Jul 2002 11:24:14 -0000 1.2 @@ -1,4 +1,9 @@ +2002-07-25 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> + + * CSMailAPI.xml : Removed property "Empty" from + class InternetAddressList. No Need. + 2002-06-19 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> * by_object.cs, by_object.xsl: Added new files. Index: csMailAPI.xml =================================================================== RCS file: /cvsroot/csmail/csmail/docs/csMailAPI.xml,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- csMailAPI.xml 23 Jun 2002 02:03:42 -0000 1.4 +++ csMailAPI.xml 25 Jul 2002 11:24:14 -0000 1.5 @@ -397,7 +397,6 @@ </implements> </class> <class name="InternetAddressList"> - <property name="Empty" type="InternetAddressList" allow="get;"/> <method name="ctor"/> <method name="ctor"> <param name="addresses" type="InternetAddress[]"/> |
From: Gaurav V. <mas...@us...> - 2002-07-25 11:24:17
|
Update of /cvsroot/csmail/csmail/src/CSMail In directory usw-pr-cvs1:/tmp/cvs-serv29772/src/CSMail Modified Files: ChangeLog Header.cs HeaderList.cs InternetAddress.cs Added Files: InternetAddressList.cs Log Message: 2002-07-25 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> * *.*/*: See ChangeLog --- NEW FILE --- /** * Namespace: CSMail * Class: InternetAddressList * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ using System; using System.Collections; using System.Collections.Specialized; namespace CSMail { public class InternetAddressList : IAddressList, IEnumerable { private ArrayList addresses = new ArrayList(); public InternetAddressList() { } public InternetAddressList(InternetAddress[] addresses) { if(addresses != null) { foreach(InternetAddress current in addresses) { if(current != null) { this.addresses.Add(current); } } } } public InternetAddressList(InternetAddressList addresses) { if(addresses != null) { foreach(InternetAddress current in addresses) { this.addresses.Add(current); } } } } } Index: ChangeLog =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/ChangeLog,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- ChangeLog 20 Jun 2002 11:18:50 -0000 1.3 +++ ChangeLog 25 Jul 2002 11:24:14 -0000 1.4 @@ -1,4 +1,16 @@ +2002-07-25 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> + + * Header.cs : Added comment for ToString() method. + * HeaderList.cs : Fixed bug in IndexOf(string, bool), was + missing i++. + * InternetAddress.cs : Renamed + * ValidIP(int[]) to ValidIP4(int[]) + * CheckIfIP(string host) to + CheckIfIP4(string) + * Supporting only IP_V4 notice (added) + * InternetAddressList.cs : Added new file. Initial implementation. + 2002-06-20 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> * Session.cs: Added constructors and GetDefaultInstance(...) method @@ -16,11 +28,12 @@ * InternetAddress.cs, * URLName.cs : Initial implementation. * FolderEventArgs.cs : Added property NewFolder. Debugged - the constructors + the constructors * Header.cs : Added ToString() method. * HeaderList.cs : Now implements IEnumerable. Added methods - GetEnumerator(), this[int], Add(...), IndexOf(...), - Remove*(...), Exists and ToString() + GetEnumerator(), this[int], Add(...), + IndexOf(...), Remove*(...), Exists and + ToString() 2002-06-18 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> Index: Header.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/Header.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- Header.cs 20 Jun 2002 02:43:24 -0000 1.1 +++ Header.cs 25 Jul 2002 11:24:14 -0000 1.2 @@ -59,6 +59,15 @@ } } + /// <summary> + /// Returns all the values in the form of: + /// <c> + /// Name: Value_1\r\n + /// Name: Value_2\r\n + /// </c> + /// This can be very useful while creation of headers like "Received" + /// in SMTP protocol. + /// </summary> public override string ToString() { string retVal = ""; Index: HeaderList.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/HeaderList.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- HeaderList.cs 20 Jun 2002 02:43:25 -0000 1.1 +++ HeaderList.cs 25 Jul 2002 11:24:14 -0000 1.2 @@ -18,6 +18,10 @@ { private ArrayList headers = new ArrayList(); + public HeaderList() + { + } + public HeaderList(Header header) { headers.Add(header); @@ -97,6 +101,7 @@ { return i; } + i++; } return -1; } Index: InternetAddress.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/InternetAddress.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- InternetAddress.cs 20 Jun 2002 02:43:25 -0000 1.1 +++ InternetAddress.cs 25 Jul 2002 11:24:14 -0000 1.2 @@ -28,6 +28,11 @@ } } + /// <summary> + /// Currently only IP_V4 formats are supported. To support + /// the IP_V6 format IPs, I have to first go through the + /// documentations. + /// </summary> public InternetAddress(int[] ip) { if(!ValidIP(ip)) @@ -83,7 +88,7 @@ return retVal; } - private bool ValidIP(int[] ip) + private bool ValidIP4(int[] ip) { if(ip.Length != 4) return false; @@ -95,7 +100,7 @@ return true; } - private bool CheckIfIP(string host) + private bool CheckIfIP4(string host) { string[] seps = host.Split(new char[] {'.'}); if(seps.Length != 4) |
From: Gaurav V. <mas...@us...> - 2002-07-25 09:32:09
|
Update of /cvsroot/csmail/csmail In directory usw-pr-cvs1:/tmp/cvs-serv2782 Modified Files: COPYING ChangeLog Log Message: 2002-07-25 Gaurav Vaish <mas...@us...> * COPYING: License changed to MIT License. * ChangeLog: Notification Index: COPYING =================================================================== RCS file: /cvsroot/csmail/csmail/COPYING,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- COPYING 20 Jun 2002 02:28:43 -0000 1.1 +++ COPYING 25 Jul 2002 09:32:06 -0000 1.2 @@ -1,5 +1,5 @@ - The CSMail is released under the GNU-GPL License (version 2). All the copying + The CSMail is released under the The MIT License. All the copying business and using of the library, henceforth, shall be under the norms as mentioned in the License. A copy of the same has been included below for convenience. @@ -11,283 +11,26 @@ ----------------------------------------------------------------------------- - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 + The MIT License - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. +Copyright (c) 2002, Gaurav Vaish - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. + Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. ----------------------------------------------------------------------------- Index: ChangeLog =================================================================== RCS file: /cvsroot/csmail/csmail/ChangeLog,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- ChangeLog 20 Jun 2002 11:21:18 -0000 1.2 +++ ChangeLog 25 Jul 2002 09:32:06 -0000 1.3 @@ -1,4 +1,9 @@ +2002-07-25 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> + + * IMPORTANT UPDATE (file COPYING): + The License has been changed from GNU-GPL to the MIT License + 2002-06-20 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> * Created a local CVS repository on my computer. Will directly put |
From: Gaurav V. <mas...@us...> - 2002-07-24 10:57:57
|
Update of /cvsroot/csmail/csmail/nant/src In directory usw-pr-cvs1:/tmp/cvs-serv1717/nant/src Added Files: AssemblyInfo.cs BuildException.cs DirectoryScanner.cs FileSet.cs Location.cs NAnt.cs NAnt.exe Project.cs PropertyDictionary.cs Target.cs TargetCollection.cs Task.cs TaskBuilder.cs TaskBuilderCollection.cs TaskCollection.cs TaskFactory.cs Log Message: 2002-02-24 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> * **.**/** -- Final single commit for all the files. --- NEW FILE --- // NAnt - A .NET build tool // Copyright (C) 2001 Gerry Shaw // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // Gerry Shaw (ger...@ya...) using System.Reflection; using System.Runtime.CompilerServices; [assembly: AssemblyTitle("NAnt")] [assembly: AssemblyDescription("A .NET Build Tool")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("http://nant.sourceforge.net/")] [assembly: AssemblyProduct("NAnt")] [assembly: AssemblyCopyright("Copyright (C) 2001 Gerry Shaw")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] [assembly: AssemblyVersion("0.6.0.*")] // This will not compile with Visual Studio. If you want to build a signed // executable use the NAnt build file. To build under Visual Studio just // exclude this file from the build. [assembly: AssemblyDelaySign(false)] [assembly: AssemblyKeyName("")] --- NEW FILE --- // NAnt - A .NET build tool // Copyright (C) 2001 Gerry Shaw // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // Gerry Shaw (ger...@ya...) // Ian MacLean (ian...@an...) namespace SourceForge.NAnt { using System; /// <summary> /// Thrown whenever an error occurs during the build. /// </summary> public class BuildException : ApplicationException { private Location _location = Location.UnknownLocation; /// <summary> /// Constructs a build exception with no descriptive information. /// </summary> public BuildException() : base() { } /// <summary> /// Constructs an exception with a descriptive message. /// </summary> public BuildException(String message) : base(message) { } /// <summary> /// Constructs an exception with a descriptive message and an /// instance of the Exception that is the cause of the current Exception. /// </summary> public BuildException(String message, Exception e) : base(message, e) { } /// <summary> /// Constructs an exception with a descriptive message and location /// in the build file that caused the exception. /// </summary> /// <param name="location">Location in the build file where the exception occured.</param> public BuildException(String message, Location location) : base(message) { _location = location; } /// <summary> /// Constructs an exception with the given descriptive message, the /// location in the build file and an instance of the Exception that /// is the cause of the current Exception. /// </summary> /// <param name="message">The error message that explains the reason for the exception.</param> /// <param name="location">Location in the build file where the exception occured.</param> /// <param name="e">An instance of Exception that is the cause of the current Exception.</param> public BuildException(String message, Location location, Exception e) : base(message, e) { _location = location; } public override string Message { get { string message = base.Message; // only include location string if not empty string locationString = _location.ToString(); if (locationString != String.Empty) { message = locationString + " " + message; } return message; } } } } --- NEW FILE --- // NAnt - A .NET build tool // Copyright (C) 2001 Gerry Shaw // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // Gerry Shaw (ger...@ya...) /* Examples: "**\*.class" matches all .class files/dirs in a directory tree. "test\a??.java" matches all files/dirs which start with an 'a', then two more characters and then ".java", in a directory called test. "**" matches everything in a directory tree. "**\test\**\XYZ*" matches all files/dirs that start with "XYZ" and where there is a parent directory called test (e.g. "abc\test\def\ghi\XYZ123"). Example of usage: DirectoryScanner scanner = DirectoryScanner(); scanner.Includes.Add("**\\*.class"); scanner.Exlucdes.Add("modules\\*\\**"); scanner.BaseDirectory = "test"; scanner.Scan(); foreach (string filename in GetIncludedFiles()) { Console.WriteLine(filename); } */ namespace SourceForge.NAnt { using System; using System.Collections.Specialized; using System.IO; using System.Text; using System.Text.RegularExpressions; public class DirectoryScanner { string _baseDirectory = Environment.CurrentDirectory; // holds the nant patterns StringCollection _includes = new StringCollection(); StringCollection _excludes = new StringCollection(); // holds the nant patterns converted to regular expression patterns StringCollection _includePatterns = null; StringCollection _excludePatterns = null; // holds the result from a scan StringCollection _fileNames = null; StringCollection _directoryNames = null; public StringCollection Includes { get { return _includes; } } public StringCollection Excludes { get { return _excludes; } } public string BaseDirectory { get { return _baseDirectory; } set { _baseDirectory = value; } } public StringCollection FileNames { get { if (_fileNames == null) { Scan(); } return _fileNames; } } public StringCollection DirectoryNames { get { if (_directoryNames == null) { Scan(); } return _directoryNames; } } public void Scan() { _includePatterns = new StringCollection(); foreach (string pattern in Includes) { _includePatterns.Add(ToRegexPattern(pattern)); } _excludePatterns = new StringCollection(); foreach (string pattern in Excludes) { _excludePatterns.Add(ToRegexPattern(pattern)); } _fileNames = new StringCollection(); _directoryNames = new StringCollection(); ScanDirectory(Path.GetFullPath(BaseDirectory)); } void ScanDirectory(string path) { // get info for the current directory DirectoryInfo currentDirectoryInfo = new DirectoryInfo(path); // scan subfolders foreach (DirectoryInfo directoryInfo in currentDirectoryInfo.GetDirectories()) { ScanDirectory(directoryInfo.FullName); } // scan files foreach (FileInfo fileInfo in currentDirectoryInfo.GetFiles()) { string filename = Path.Combine(path, fileInfo.Name); if (IsPathIncluded(filename)) { _fileNames.Add(filename); } } // Check current path last so that delete task will correctly // delete empty directories. This may *seem* like a special case // but it is more like formalizing something in a way that makes // writing the delete task easier :) if (IsPathIncluded(path)) { _directoryNames.Add(path); } } bool IsPathIncluded(string path) { bool included = false; // check path against includes foreach (string pattern in _includePatterns) { Match m = Regex.Match(path, pattern); if (m.Success) { included = true; break; } } // check path against excludes if (included) { foreach (string pattern in _excludePatterns) { Match m = Regex.Match(path, pattern); if (m.Success) { included = false; break; } } } return included; } string ToRegexPattern(string nantPattern) { StringBuilder pattern = new StringBuilder(nantPattern); // NAnt patterns can use either / \ as a directory seperator. // We must replace both of these characters with Path.DirectorySeperatorChar pattern.Replace('/', Path.DirectorySeparatorChar); pattern.Replace('\\', Path.DirectorySeparatorChar); // Patterns MUST be full paths. if (!Path.IsPathRooted(pattern.ToString())) { pattern = new StringBuilder(Path.Combine(BaseDirectory, pattern.ToString())); } // The '\' character is a special character in regular expressions // and must be escaped before doing anything else. pattern.Replace(@"\", @"\\"); // Escape the rest of the regular expression special characters. // NOTE: Characters other than . $ ^ { [ ( | ) * + ? \ match themselves. // TODO: Decide if ] and } are missing from this list, the above // list of characters was taking from the .NET SDK docs. pattern.Replace(".", @"\."); pattern.Replace("$", @"\$"); pattern.Replace("^", @"\^"); pattern.Replace("{", @"\{"); pattern.Replace("[", @"\["); pattern.Replace("(", @"\("); pattern.Replace(")", @"\)"); pattern.Replace("+", @"\+"); // Special case directory seperator string under Windows. string seperator = Path.DirectorySeparatorChar.ToString(); if (seperator == @"\") { seperator = @"\\"; } // Convert NAnt pattern characters to regular expression patterns. // SPECIAL CASE: to match subdirectory OR current directory. If // we don't do this then we can write something like 'src/**/*.cs' // to match all the files ending in .cs in the src directory OR // subdirectories of src. pattern.Replace(seperator + "**", "(" + seperator + ".|)|"); // | is a place holder for * to prevent it from being replaced in next line pattern.Replace("**", ".|"); pattern.Replace("*", "[^" + seperator + "]*"); pattern.Replace("?", "[^" + seperator + "]?"); pattern.Replace('|', '*'); // replace place holder string // Help speed up the search pattern.Insert(0, '^'); // start of line pattern.Append('$'); // end of line return pattern.ToString(); } } } --- NEW FILE --- // NAnt - A .NET build tool // Copyright (C) 2001 Gerry Shaw // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // Gerry Shaw (ger...@ya...) namespace SourceForge.NAnt { using System; using System.Collections.Specialized; using System.IO; public class FileSet { /// <summary> /// Used to determine if a file has a more recent last write time then the specified write time. /// </summary> /// <param name="fileNames">A collection of filenames to check last write times against.</param> /// <param name="targetLastWriteTime">The datetime to compare against.</param> /// <returns><c>True</c> if at least one file in <c>fileNames</c> has a last write time greater than <c>targetLastWriteTime</c>.</returns> public static bool MoreRecentLastWriteTime(StringCollection fileNames, DateTime targetLastWriteTime) { foreach (string fileName in fileNames) { FileInfo fileInfo = new FileInfo(fileName); if (!fileInfo.Exists) { return true; } if (fileInfo.LastWriteTime > targetLastWriteTime) { return true; } } return false; } // We can't just use the DirectoryScanner's includes/excludes collections // because when we do a Scan() we need to first expand any macros. StringCollection _includes = new StringCollection(); StringCollection _excludes = new StringCollection(); DirectoryScanner _scanner = null; string _baseDirectory; bool _includeAllByDefault; Task _task = null; public FileSet(bool includeAllByDefault) { IncludeAllByDefault = includeAllByDefault; Excludes.Add("**/CVS/*"); Excludes.Add("**/.cvsignore"); } /// <remarks> /// Will be automagically set in Task.AutoInitializeAttributes() if /// file set has TaskFileSetAttribute set on it. /// </remarks> // TODO: change this to IMacroExpander public Task Task { get { return _task; } set { _task = value; } } public string BaseDirectory { get { return _baseDirectory; } set { _baseDirectory = value; } } /// <summary>Determines if scan should produce everything or nothing /// if there are no Includes set. Default false.</summary> public bool IncludeAllByDefault { get { return _includeAllByDefault; } set { _includeAllByDefault = value; } } public StringCollection Includes { get { return _includes; } } public StringCollection Excludes { get { return _excludes; } } public void Scan() { // get project (only for expanding macros) Project expander = Task.Project; _scanner = new DirectoryScanner(); _scanner.BaseDirectory = expander.GetFullPath(BaseDirectory);; foreach (string path in Includes) { _scanner.Includes.Add(expander.ExpandText(path)); } if (Includes.Count <= 0 && IncludeAllByDefault) { _scanner.Includes.Add("**"); } foreach (string path in Excludes) { _scanner.Excludes.Add(expander.ExpandText(path)); } _scanner.Scan(); } public StringCollection DirectoryNames { get { if (_scanner == null) { Scan(); } return _scanner.DirectoryNames; } } public StringCollection FileNames { get { if (_scanner == null) { Scan(); } return _scanner.FileNames; } } } } --- NEW FILE --- // NAnt - A .NET build tool // Copyright (C) 2001 Gerry Shaw // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // Ian MacLean (ian...@an...) // Gerry Shaw (ger...@ya...) namespace SourceForge.NAnt { using System; using System.IO; /// <summary> /// Stores the file name and line number in a file. /// </summary> public class Location { string _fileName; int _lineNumber; int _columnNumber; public static readonly Location UnknownLocation = new Location(); /// <summary> /// Creates a location consisting of a file name and line number. ///</summary> public Location(string fileName, int lineNumber, int columnNumber) { Uri uri = new Uri(fileName); string strfileName = uri.LocalPath; // convert from URI syntax to local path Init(strfileName, lineNumber, columnNumber); } /// <summary> /// Creates a location consisting of a file name but no line number. ///</summary> public Location(string fileName) { Init(fileName, 0, 0); } /// <summary> /// Creates an "unknown" location. ///</summary> private Location() { Init(null, 0, 0); } /// <summary> /// Private Init function. ///</summary> private void Init(string fileName, int lineNumber, int columnNumber) { _fileName = fileName; _lineNumber = lineNumber; _columnNumber = columnNumber; } /// <summary> /// Returns the file name, line number and a trailing space. An error /// message can be appended easily. For unknown locations, returns /// an empty string. ///</summary> public override string ToString() { string message = ""; if (_fileName != null) { message += _fileName; if (_lineNumber != 0) { message += ":"; message += _lineNumber.ToString(); } message += ":"; } return message; } } } --- NEW FILE --- // NAnt - A .NET build tool // Copyright (C) 2001 Gerry Shaw // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // Gerry Shaw (ger...@ya...) namespace SourceForge.NAnt { using System; using System.Diagnostics; using System.IO; using System.Text.RegularExpressions; public class NAnt { public static int Main(string[] args) { int returnCode = 0; Log.IndentSize = 12; Project project = new Project(); const string buildfileOption = "-buildfile:"; const string basedirOption = "-basedir:"; const string setOption = "-set:"; const string helpOption = "-h"; // allow -h and -help const string verboseOption = "-verbose"; bool showHelp = false; foreach (string arg in args) { if (arg.StartsWith(buildfileOption)) { project.BuildFileName = arg.Substring(buildfileOption.Length); } else if (arg.StartsWith(basedirOption)) { project.BaseDirectory = arg.Substring(basedirOption.Length); } else if (arg.StartsWith(basedirOption)) { project.BaseDirectory = arg.Substring(basedirOption.Length); } else if (arg.StartsWith(setOption)) { // TODO: implement user defined properties // user defined properties from command line or file should be // marked so that they cannot be overwritten by the build file // ie, once set they are set for the rest of the build. Match match = Regex.Match(arg, @"-set:(\w+)=(\w*)"); if (match.Success) { string name = match.Groups[1].Value; string value = match.Groups[2].Value; project.Properties.AddReadOnly(name, value); } } else if (arg.StartsWith(helpOption)) { showHelp = true; } else if (arg.StartsWith(verboseOption)) { project.Verbose = true; } else if (arg.Length > 0) { // must be a target (or mistake ;) project.BuildTargets.Add(arg); } } // Get version information directly from assembly. This takes more // work but prevents the version numbers from getting out of sync. ProcessModule module = Process.GetCurrentProcess().MainModule; FileVersionInfo info = FileVersionInfo.GetVersionInfo(module.FileName); string programName = Path.GetFileNameWithoutExtension(info.FileName); // in case the user has renamed the program if (showHelp) { const int optionPadding = 23; Console.WriteLine("NAnt Version {0} Copyright (C) 2001 Gerry Shaw", info.FileMajorPart + "." + info.FileMinorPart + "." + info.FileBuildPart); Console.WriteLine("http://nant.sourceforge.net/"); Console.WriteLine(); Console.WriteLine("NAnt comes with ABSOLUTELY NO WARRANTY."); Console.WriteLine("This is free software, and you are welcome to redistribute it under certain"); Console.WriteLine("conditions set out by the GNU General Public License. A copy of the license"); Console.WriteLine("is available in the distribution package and from the NAnt web site."); Console.WriteLine(); Console.WriteLine("usage: {0} [options] [target]", programName); Console.WriteLine(); Console.WriteLine("options:"); Console.WriteLine(" {0} use given buildfile", (buildfileOption + "<file>").PadRight(optionPadding)); Console.WriteLine(" {0} set project base directory", (basedirOption + "<dir>").PadRight(optionPadding)); Console.WriteLine(" {0} use value for given property", (setOption + "<property>=<value>").PadRight(optionPadding)); Console.WriteLine(" {0} print this message", helpOption.PadRight(optionPadding)); Console.WriteLine(); Console.WriteLine("If no buildfile is specified the first file ending in .build will be used."); } else { if (!project.Run()) { Console.WriteLine("Try `{0} -help' for more information.", programName); returnCode = 1; // set return code to indicate an error occurred } } Log.Close(); return returnCode; } } } --- NEW FILE --- MZ $ * ( &Þ&r ( Þ + + ( ( ( Þ&rÇ ( Þ ( + + + ( + } + + ( Ð ( t + ~ + + + 8Ø 8² ( t o -$ o ( o ( o Ð ( t t# 9æ ,o oÆ o" +0o# t o oÉ o$ &o% -ÇÞu* Ür o" +,o# t o o$ &o% -ËÞu* Ü X i?Cþÿÿo' Ð @þÿÿ* 8é 8à ( t t! Ð (( t +E o o ( i2³ X i?2ÿÿÿo' Ð @ÿÿÿ* *0 + + + + + + + o" +o o# t r ,{ oë &r ,({ oë & o% -Þ u* Ü* { + o- o. o/ o0 -ào1 + o3 o- o3 (4 o3 o6 o3 o7 o3 o/ (2 o9 ¢o3 o: ¢o3 o; ¢(¨ &o= o> o? 1( &o1 ,rA ( } } + + + + + + + + + + + (F + oH -+X(? (Á (Á (Á } (< " rÛ ró (9 r (: (; (< +o- rq o0 -ã(> +o- r o0 -ã(= +o- r o0 -ã(? +o- oM o0 -æoO (2 (¦ o> (¦ (5 { } } + + + + + + + + + + + + oT > oU 8è t! t! ,#(P (¦ (Y -3 (Z &(P Þ r¿ ( :ÿÿÿÞu* Ü* ( (H < (_ +( (G ,;oH ,oI oI (` +(M +$( 8 ob sG sG oH ,=oH ,oI oI (` + (M ,(Q +$( :dÿÿÿoR } } } } }! }" }# {$ * + + + + + + + + ( Þ rÇ ( ( + o- (` -æ([ +0 o- sd oe i-of i-(_ -Ç* ,T(] 1 (g +( (h +si zÞ% (Z ( ,1(] +sk zÞ% (Z ( }' }( }) (¦ + + + + + o- ¢(4 }/ }0 -rX s± + ~5 +o# t! , +o% -á+ s¬ o" +7o# t &o% -ÀÞu* Ü{4 +o# t -âÞu* Ürª o" +7o# t &o% -ÀÞu* Ü* ~5 su ov (o ( &Ü* 5 + (Y -G( -r< ( ( >' oU 8í t! (Q t! ,( (¦ ,2( +Ksd oH -(X (Z &( Þ# r ( ( :ÿÿÿÞu* Ü* {7 &oä }; + + + + + + * ( }= }> }? }@ +rb ,1rb -$r^ -r^ +( +,rb -+rb s s Þ&Þ (F (X ,rb ,(Y -(Z &s Þ&Þ ? , rb ,^{C ..rd +{C 3{E +{E ( {A sG sG oH -rh -r¨ ,*oI oI (` -oI oI (` + 9+ {A ( (¦ 9Í s ( ( (¦ Þ"oB s² s² ¢rN ¢( (¦ ÞoB s² ( ( ( ( (¦ oñ oñ oñ + * * Ü* + + + or &~K + +o# t ( .oO o% -ÞÞu* Ü* +o# t o o% -æÞu* Ü* z( r¢ &o1 QL +o# t o o% -åÞu* Ü( +o# t o% -æÞu* Ü* (¦ +o# t oM o% -åÞu* Ü( +o# t o% -æÞu* ÜL (¤ (¦ }P rZ rb s {P 8î Q r¦ 9Ï Q r¼ 9° Q rÒ 9 Q rþ 9r rb /a< rb X X2ß Xo XYo + o 1 o +" & X X2äo y" +o y" rZ ,+ rZ ¢ r: {P o¤ sª o o¥ :þÿÿ*0 (® ,{P y +~M + rb o© & oª & o« ,+X o« , o¬ -æo© &o T r> --Xr rb ,+rZ o T r> :@ÿÿÿrZ + * * *0 }Q }Q {Q ( , r¢ + + + + + + }U +o- {U &o0 -ÞsD }V +o- {V &o0 -ÞsD }W }X (½ of +o² (½ +/o^ (E (¾ &Xi2É(¾ &* {U +o- (³ o´ , + o0 -Û,6{V +o- (³ o´ , + o0 -Ù+ /~] oµ &\~] oµ &o1 (¶ -(¸ (E s+ r^ &rd &rT &r^ &rh &r &rx &r &r &~] (¸ r^ ,rH rx o· &r &r¬ o· &r¼ o· &|*oµ &^o¹ &$o. &o1 + }R }S }T *0 +, o- sG oH -ÞoI (` ,Þ o0 -Ì+ }Y }Z (È &(Ê &*0 + + + + + sÀ + o- {[ & o0 -Ù(É 0(Ç &(Ê + o- {[ & o0 -Ù{[ + + s» o¼ (Ñ (Ñ (Ñ {_ {` |` ( rô + ( , rø o¾ oÝ , r o¾ oÛ , r o¾ oÛ ,O r0 o´ ,7o¿ oÀ oÁ o¿ oÀ oÁ oâ ,+, rX , oß 1 oà &Xi?Øþÿÿ( oà oÄ (Å oÆ (Ç 9 " " " (h rÈ (Ì r rR rë r (Ì r (Ì rM r_ (h r· (h r (h r (h (Ì r¿ +oä ( + *0 * sd ~c i1o^ (E + }i s + + + + + + + + ( (Ú (Û (Û (W ,4(Ú s± (Ü Þ r2 s² (Ï (¥ i" ÞX(¥ (¦ ,oÑ oB (¦ (¦ +(Ô oÕ +HÐ oÖ ,*o× -"{m s o (Ù o (Û o }e oÚ oU +1o# t! t! oï -ÆÞu* Üoq s¬ o" +9o# t &o% -¾Þu* Ü(á +o# t -âÞu* Ürª o" +-o# t oü or &o% -ÊÞu* Ü*4 -(à &(à +o- (è -ê*0 -rÚ s± + ,-{l {N 9 oÝ +Vo# tU 1@oß o¿ oÀ oà oá oÁ (â ob o% -¡Þu* Ü+ ,(¶ - (E +(F + -{o &(ä oå * - (ä oå *0 oÛ t! + - (ä oæ *0 *0 }o * }t (ø + + + + + -r2 (ö ,Xo < +, oé o? 1(û & X i2Ìr¬ o" +0o# t &o% -ÇÞu* Ü* +9 o- (÷ s± -¿(¥ +o# t -äÞu* ÜÞ}r +o# t( oõ ,Þo% -ÚÞu* Ü+ * }u ( Ð ( t + + + +( + t o Þ o (r & + +o# t* o ,Þo% -ÚÞu* Ü+ * * ( + + ( s± 4 4 ¨ × ) ) ) ) ) ) ) ) « Û à ôc r ³$¹ 9 ÌI8 LEX¦ÉsÛ Ô Q Ì ±`8 xÛ á¸4 ¹ÁÓ/ É Ñ4 i^£ Ùø4 áø4 é û y y Öy÷Ñn ùA î = e n y ~ ° Ó ß å ë 3Hip¯Ëßõü &, A % % % % t_Captures ¨ ¨¬ ± references ==é± ¡| ¡ ¥© 1= %¥© %%¥© ͱ ±a ¨ --- NEW FILE --- // NAnt - A .NET build tool // Copyright (C) 2001 Gerry Shaw // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // Gerry Shaw (ger...@ya...) // Ian MacLean (ian...@an...) namespace SourceForge.NAnt { using System; using System.IO; using System.Reflection; using System.Text.RegularExpressions; using System.Xml; using System.Xml.XPath; using System.Collections; using System.Collections.Specialized; /// <summary> /// Central representation of an NAnt project. /// </summary> public class Project { public static readonly string BuildFilePattern = "*.build"; /// <summary> /// Finds the file name for the build file in the specified directory. /// </summary> /// <param name="directory">The directory to look for a build file. When in doubt use Environment.CurrentDirectory for directory.</param> /// <returns>The path to the build file or <c>null</c> if no build file could be found.</returns> public static string FindBuildFileName(string directory) { string buildFileName = null; // find first file ending in .build DirectoryInfo directoryInfo = new DirectoryInfo(directory); FileInfo[] files = directoryInfo.GetFiles(BuildFilePattern); if (files.Length > 0) { buildFileName = Path.Combine(directory, files[0].Name); } return buildFileName; } string _name; string _defaultTargetName; string _baseDirectory; string _buildFileName; bool _verbose = false; StringCollection _buildTargets = new StringCollection(); TaskCollection _tasks = new TaskCollection(); TargetCollection _targets = new TargetCollection(); XPathTextPositionMap _positionMap; // created when Xml document is loaded TaskFactory _taskFactory; // created in constructor PropertyDictionary _properties = new PropertyDictionary(); public Project() { _taskFactory = new TaskFactory(this); } /// <summary> /// The name of the project. /// </summary> public string Name { get { return _name; } set { _name = value; } } public string BaseDirectory { get { return _baseDirectory; } set { _baseDirectory = value; } } public string BuildFileName { get { return _buildFileName; } set { _buildFileName = value; } } /// <summary> /// When true tasks should output more output. /// </summary> public bool Verbose { get { return _verbose; } set { _verbose = value; } } /// <summary> /// The list of targets to built. /// </summary> /// <remarks> /// Targets are built in the order they appear in the collection. If /// the collection is empty the default target will be built. /// </remarks> public StringCollection BuildTargets { get { return _buildTargets; } } /// <summary> /// The list of tasks to perform before any targets executed. /// </summary> /// <remarks> /// Tasks are executed in the order they appear in the collection. /// </remarks> public TaskCollection Tasks { get { return _tasks; } } public PropertyDictionary Properties { get { return _properties; } } public TargetCollection Targets { get { return _targets; } } public bool Run() { bool buildResult = false; try { DateTime startTime = DateTime.Now; if (BaseDirectory == null) { BaseDirectory = Environment.CurrentDirectory; } BaseDirectory = Path.GetFullPath(BaseDirectory); if (BuildFileName == null || BuildFileName == String.Empty) { BuildFileName = FindBuildFileName(BaseDirectory); if (BuildFileName == null) { throw new BuildException(String.Format("Could not find a '{0}' file in '{1}'", BuildFilePattern, BaseDirectory)); } } Log.WriteLine("Buildfile: {0}", BuildFileName); if (Verbose) { Log.WriteLine("Base Directory: {0}", BaseDirectory); } XmlDocument doc = new XmlDocument(); try { doc.Load(BuildFileName); // TODO: validate against xsd schema } catch (XmlException e) { throw new BuildException(String.Format("Could not load '{0}'", BuildFileName), e); } Initialize(doc); Properties.Add("nant.buildfile", BuildFileName); Execute(); Log.WriteLine(); Log.WriteLine("BUILD SUCCEEDED"); TimeSpan buildTime = DateTime.Now - startTime; Log.WriteLine(); Log.WriteLine("Total time: {0} seconds", (int) buildTime.TotalSeconds); buildResult = true; } catch (BuildException e) { Log.WriteLine(); Log.WriteLine("BUILD FAILED"); Log.WriteLine(e.Message); if (e.InnerException != null) { Log.WriteLine(e.InnerException.Message); } } catch (Exception e) { // all other exceptions should have been caught Log.WriteLine(); Log.WriteLine("INTERNAL ERROR"); Log.WriteLine(e.ToString()); } return buildResult; } public int AddTasks(string assemblyPath) { Assembly assembly; if (assemblyPath == null) { assembly = Assembly.GetExecutingAssembly(); } else { assembly = Assembly.LoadFrom(assemblyPath); } int taskCount = 0; foreach(Type type in assembly.GetTypes()) { if (type.IsSubclassOf(typeof(Task)) && !type.IsAbstract) { if (_taskFactory.Builders.Add(new TaskBuilder(type.FullName, assemblyPath))) { taskCount++; } } } return taskCount; } public void Initialize(XmlDocument doc) { Name = doc.SelectSingleNode("project/@name").Value; // make it possible for user to override this value if (BaseDirectory == null) { BaseDirectory = doc.SelectSingleNode("project/@basedir").Value; } // used only if BuildTargets collection is empty _defaultTargetName = doc.SelectSingleNode("project/@default").Value; // initialize builtin tasks AddTasks(null); // init static built in properties Properties.Add("nant.project.name", Name); Properties.Add("nant.base.dir", BaseDirectory); Properties.Add("nant.default.name", _defaultTargetName); // add all environment variables IDictionary variables = Environment.GetEnvironmentVariables(); foreach (string name in variables.Keys) { string value = (string) variables[name]; Properties.Add("nant.env." + name, value); } // Load line Xpath to linenumber array _positionMap = new XPathTextPositionMap(doc.BaseURI); // process all the non-target nodes (these are global tasks for the project) XmlNodeList taskList = doc.SelectNodes("project/*[name() != 'target']"); foreach (XmlNode taskNode in taskList) { // TODO: do somethiing like Project.CreateTask(taskNode) and have the project set the location TextPosition textPosition = _positionMap.GetTextPosition(taskNode); Task task = CreateTask(taskNode); if (task != null) { Tasks.Add(task); } } // execute global tasks now - before anything else // this lets us include tasks that do things like add more tasks foreach (Task task in Tasks) { task.Execute(); } // process all the targets XmlNodeList targetList = doc.SelectNodes("project/target"); foreach (XmlNode targetNode in targetList) { Target target = new Target(this); target.Initialize(targetNode); Targets.Add(target); } } public void Execute() { if (BuildTargets.Count == 0) { BuildTargets.Add(_defaultTargetName); } foreach(string targetName in BuildTargets) { Execute(targetName); } } public void Execute(string targetName) { Target target = Targets.Find(targetName); if (target == null) { throw new BuildException(String.Format("unknown target '{0}'", targetName)); } target.Execute(); } public Task CreateTask(XmlNode taskNode) { return CreateTask(taskNode, null); } public Task CreateTask(XmlNode taskNode, Target target) { Task task = _taskFactory.CreateTask(taskNode, target); if (task != null) { // save task location in case of error TextPosition pos = _positionMap.GetTextPosition(taskNode); // initialize the task task.Initialize(taskNode, new Location(taskNode.BaseURI, pos.Line, pos.Column)); } return task; } public string ExpandText(string input) { string output = input; if (input != null) { const string pattern = @"\$\{([^\}]*)\}"; foreach (Match m in Regex.Matches(input, pattern)) { if (m.Length > 0) { string token = m.ToString(); string propertyName = m.Groups[1].Captures[0].Value; string propertyValue = Properties[propertyName]; if (propertyValue != null) { output = output.Replace(token, propertyValue); } } } } return output; } public string GetFullPath(string path) { string baseDir = ExpandText(BaseDirectory); if (path != null) { if (!Path.IsPathRooted(path)) { path = Path.Combine(baseDir, path); } } else { path = baseDir; } return Path.GetFullPath(path); } } } --- NEW FILE --- // NAnt - A .NET build tool // Copyright (C) 2001 Gerry Shaw // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // Gerry Shaw (ger...@ya...) namespace SourceForge.NAnt { using System.Collections; using System.Collections.Specialized; public class PropertyDictionary : DictionaryBase { /// <summary> /// Maintains a list of the property names that are readonly. /// </summary> StringCollection _readOnlyProperties = new StringCollection(); /// <summary> /// Adds a property that cannot be changed. /// </summary> /// <remarks> /// Properties added with this method can never be changed. Note that /// they are removed if the <c>Clear</c> method is called. /// </remarks> /// <param name="name">Name of property</param> /// <param name="value">Value of property</param> public void AddReadOnly(string name, string value) { if (!_readOnlyProperties.Contains(name)) { _readOnlyProperties.Add(name); Dictionary.Add(name, value); } } /// <summary> /// Adds a property to the collection. /// </summary> /// <param name="name">Name of property</param> /// <param name="value">Value of property</param> public void Add(string name, string value) { if (!_readOnlyProperties.Contains(name)) { Dictionary.Add(name, value); } } public string this[string name] { get { return (string) Dictionary[(object) name]; } set { if (!_readOnlyProperties.Contains(name)) { Dictionary[name] = value; } } } protected override void OnClear() { _readOnlyProperties.Clear(); } } } --- NEW FILE --- // NAnt - A .NET build tool // Copyright (C) 2001 Gerry Shaw // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // Gerry Shaw (ger...@ya...) // Ian MacLean (ian...@an...) namespace SourceForge.NAnt { using System; using System.Collections.Specialized; using System.Xml; public class Target { string _name; Project _project; bool _hasExecuted = false; TaskCollection _tasks = new TaskCollection(); StringCollection _dependencies = new StringCollection(); public Target(Project project) { Project = project; } public string Name { get { return _name; } set { _name = value; } } public Project Project { get { return _project; } set { _project = value; } } public bool HasExecuted { get { return _hasExecuted; } } public TaskCollection Tasks { get { return _tasks; } } public StringCollection Dependencies { get { return _dependencies; } } public void Initialize(XmlNode targetNode) { // get target name XmlNode nameNode = targetNode.SelectSingleNode("@name"); if (nameNode == null) { // TODO: add Location to exception throw new BuildException("target must have a name attribute"); } Name = nameNode.Value; // add dependicies XmlNode dependsNode = targetNode.SelectSingleNode("@depends"); if (dependsNode != null) { string depends = dependsNode.Value; foreach (string str in depends.Split(new char[]{','})) { string dependency = str.Trim(); if (dependency.Length > 0) { Dependencies.Add(dependency); } } } // select all the non-target nodes (these are global tasks for the project) XmlNodeList taskList = targetNode.SelectNodes("*"); foreach (XmlNode taskNode in taskList) { Task task = Project.CreateTask(taskNode, this); if (task != null) { Tasks.Add(task); } } } public void Execute() { if (!HasExecuted) { try { foreach (string targetName in Dependencies) { Target target = Project.Targets.Find(targetName); if (target == null) { // TODO: add Location to exception throw new BuildException(String.Format("unknown dependent target '{0}' of target '{1}'", targetName, Name)); } target.Execute(); } Log.WriteLine(); Log.WriteLine("{0}:", Name); foreach (Task task in Tasks) { task.Execute(); } } finally { _hasExecuted = true; } } } } } --- NEW FILE --- // NAnt - A .NET build tool // Copyright (C) 2001 Gerry Shaw // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // Gerry Shaw (ger...@ya...) namespace SourceForge.NAnt { using System; using System.Collections; public class TargetCollection : ArrayList { public Target Find(string targetName) { foreach(Target target in this) { if (target.Name == targetName) return target; } return null; } } } --- NEW FILE --- // NAnt - A .NET build tool // Copyright (C) 2001 Gerry Shaw // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // Gerry Shaw (ger...@ya...) // Mike Krueger (mi...@ic...) // Ian MacLean (ian...@an...) namespace SourceForge.NAnt { using System; using System.Reflection; using System.Xml; public abstract class Task { /// <summary>Gets and sets how much spacing log prefix names will be padded.</summary> /// <remarks> /// Includes characters for a space after the name and the [ ] brackets. Default is 12. /// </remarks> public static int LogPrefixPadding = Log.IndentSize; Location _location = Location.UnknownLocation; Target _target = null; Project _project = null; /// <summary> /// Location in build file where task is defined. /// </summary> protected Location Location { get { return _location; } set { _location = value; } } public string Name { get { string name = null; TaskNameAttribute taskName = (TaskNameAttribute) Attribute.GetCustomAttribute(GetType(), typeof(TaskNameAttribute)); if (taskName != null) { name = taskName.Name; } return name; } } public string LogPrefix { get { string prefix = "[" + Name + "] "; return prefix.PadLeft(LogPrefixPadding); } } public Target Target { get { return _target; } set { _target = value; } } public Project Project { get { return _project; } set { _project = value; } } protected void AutoInitializeAttributes(XmlNode taskNode) { // TODO: BooleanValidatorAttribute and Int32ValidatorAttribute implementation in Task // Go down the inheritance tree to find the private fields in the object. // We are looking for task attributes to initialize. Type currentType = GetType(); while (currentType != typeof(object)) { FieldInfo[] fieldInfoArray = currentType.GetFields(BindingFlags.NonPublic|BindingFlags.Instance); foreach (FieldInfo fieldInfo in fieldInfoArray) { // process TaskAttribute attributes TaskAttributeAttribute taskAttribute = (TaskAttributeAttribute) Attribute.GetCustomAttribute(fieldInfo, typeof(TaskAttributeAttribute)); if (taskAttribute != null) { // get value from xml file XmlNode node = taskNode.SelectSingleNode("@" + taskAttribute.Name); // check if its required if (node == null && taskAttribute.Required) { // TODO: add Location to exception throw new BuildException(String.Format("{0} is a required attribute.", taskAttribute.Name), Location); } if (node != null) { fieldInfo.SetValue(this, Convert.ChangeType(node.Value, fieldInfo.FieldType)); } } // process TaskFileSet attributes TaskFileSetAttribute fileSetAttribute = (TaskFileSetAttribute) Attribute.GetCustomAttribute(fieldInfo, typeof(TaskFileSetAttribute)); if (fileSetAttribute != null) { // have file set initialize itself FileSet fileSet = (FileSet) fieldInfo.GetValue(this); // set task fileset belongs to fileSet.Task = this; // load values from build file XmlNode fileSetNode = taskNode.SelectSingleNode(fileSetAttribute.Name); if (fileSetNode != null) { XmlNode baseDirectoryNode = fileSetNode.SelectSingleNode("@basedir"); if (baseDirectoryNode != null) { fileSet.BaseDirectory = baseDirectoryNode.Value; } foreach (XmlNode node in fileSetNode.SelectNodes("includes")) { string pathname = node.SelectSingleNode("@name").Value; fileSet.Includes.Add(pathname); } foreach (XmlNode node in fileSetNode.SelectNodes("excludes")) { fileSet.Excludes.Add(node.SelectSingleNode("@name").Value); } } } } currentType = currentType.BaseType; } } protected void AutoExpandAttributes() { // Go down the inheritance tree to find the private fields in the object. // We are looking for task attributes to initialize. Type currentType = GetType(); while (currentType != typeof(object)) { FieldInfo[] fieldInfoArray = currentType.GetFields(BindingFlags.NonPublic|BindingFlags.Instance); foreach (FieldInfo fieldInfo in fieldInfoArray) { // proces string parameters TaskAttributeAttribute taskAttribute = (TaskAttributeAttribute) Attribute.GetCustomAttribute(fieldInfo, typeof(TaskAttributeAttribute)); if (taskAttribute != null) { if (taskAttribute.ExpandText) { string value = (string) fieldInfo.GetValue(this); value = Project.ExpandText(value); fieldInfo.SetValue(this, value); } // if a field also has a validator attribute then ensure that value is correct ValidatorAttribute[] validators = (ValidatorAttribute[]) Attribute.GetCustomAttributes(fieldInfo, typeof(ValidatorAttribute)); foreach (ValidatorAttribute validator in validators) { string errorMessage = validator.Validate(fieldInfo.GetValue(this)); if (errorMessage != null) { throw new BuildException(String.Format("Error processing '{0}' attribute in <{1}> task: {2}", taskAttribute.Name, Name, errorMessage), Location); } } } } currentType = currentType.BaseType; } } public void Initialize(XmlNode taskNode) { Initialize(taskNode, null); } public void Initialize(XmlNode taskNode, Location location) { if (location != null) { _location = location; } AutoInitializeAttributes(taskNode); InitializeTask(taskNode); } public void Execute() { AutoExpandAttributes(); ExecuteTask(); } protected virtual void InitializeTask(XmlNode taskNode) { } protected abstract void ExecuteTask(); } } --- NEW FILE --- // NAnt - A .NET buil... [truncated message content] |
Update of /cvsroot/csmail/csmail/src/CSMail In directory usw-pr-cvs1:/tmp/cvs-serv1717/src/CSMail Added Files: .cvsignore AddressType.cs AssemblyInfo.cs BodyPart.cs BodyPartList.cs ChangeLog ConnectionEventArgs.cs ConnectionEventHandler.cs ConnectionEventType.cs ContentDisposition.cs ContentType.cs EMailAddress.cs EMailAddressList.cs Folder.cs FolderAddress.cs FolderEventArgs.cs FolderEventHandler.cs FolderEventType.cs FolderOpenMode.cs FolderSortStyle.cs FolderType.cs Header.cs HeaderList.cs IAddress.cs IAddressList.cs IEncode.cs IMimePart.cs IPart.cs InternetAddress.cs Message.cs MessageFlags.cs MessageSortStyle.cs Multipart.cs NewsAddress.cs NewsAddressList.cs Parameter.cs ParameterList.cs Provider.cs ProviderType.cs RecipientType.cs Service.cs Session.cs Store.cs TODOAttribute.cs TransferEncoding.cs URLName.cs Log Message: 2002-02-24 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> * **.**/** -- Final single commit for all the files. --- NEW FILE --- *.bat --- NEW FILE --- /** * Namespace: CSMail * Enumeration: AddressType * Comment: Enumeration AddressType for various types of addresses. * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ namespace CSMail { public enum AddressType { EmailAddress, InternetAddress, NewsAddress } } --- NEW FILE --- using System.Reflection; using System.Runtime.CompilerServices; [assembly: AssemblyTitle("CSMail")] [assembly: AssemblyDescription("CS Mail API")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("http://csmail.sourceforge.net/")] [assembly: AssemblyProduct("CSMail")] [assembly: AssemblyCopyright("Copyright (C) 2002, Gaurav Vaish")] [assembly: AssemblyTrademark("CS-Mail")] [assembly: AssemblyCulture("")] [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyDelaySign(false)] [assembly: AssemblyKeyName("")] --- NEW FILE --- /** * Namespace: CSMail * Class: BodyPart * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ using System.IO; namespace CSMail { public abstract class BodyPart: IPart { private Multipart parent; public BodyPart() { } public Multipart Parent { get { return parent; } } protected Multipart ParentProperty { get { return parent; } set { parent = value; } } public abstract Multipart Content { get; set; } public abstract ContentType ContentType { get; set; } public abstract string Description { get; set; } public abstract ContentDisposition Disposition { get; set; } public abstract string Filename { get; set; } public abstract HeaderList Headers { get; set; } public abstract int Size { get; set; } public abstract int AddHeader(Header header); public abstract int AddHeaders(HeaderList headers); public abstract void Write(TextWriter writer); } } --- NEW FILE --- /** * Namespace: CSMail * Class: BodyPartList * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ using System.Collections; namespace CSMail { public class BodyPartList { public BodyPartList(BodyPart part) { //TODO } public BodyPartList(BodyPart[] parts) { //TODO } public BodyPartList(BodyPartList parts) { //TODO } } } --- NEW FILE --- 2002-06-20 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> * Session.cs: Added constructors and GetDefaultInstance(...) method 2002-06-19 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> * Added attribute class - MailTODOAttribute in the file TODOAttribute.cs * Folder.cs, * Message.cs, * Session.cs, * Store.cs, * Service.cs, * InternetAddress.cs, * URLName.cs : Initial implementation. * FolderEventArgs.cs : Added property NewFolder. Debugged the constructors * Header.cs : Added ToString() method. * HeaderList.cs : Now implements IEnumerable. Added methods GetEnumerator(), this[int], Add(...), IndexOf(...), Remove*(...), Exists and ToString() 2002-06-18 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> * Added the following objects: - BodyPart - BodyPartList - ConnectionEventArgs - ConnectionEventHandler - ContentType - EMailAddress - EMailAddressList - Folder - FolderAddress - FolderEventArgs - FolderEventHandler - Header - HeaderList - Multipart - Parameter - ParameterList - Session - IAddress - IAddressList - IEncode - IMimePart - IPart - MessageFlags 2002-06-13 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> * Added the enumerations: - AddressType - ConnectionEventType - ContentDisposition - Flags - FolderEventType - FolderSortStyle - MessageSortStyle - ProviderType - RecipientType - TransferEncoding --- NEW FILE --- /** * Namespace: CSMail * Class: ConnectionEventArgs * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ namespace CSMail { public class ConnectionEventArgs { private ConnectionEventType eventType; public ConnectionEventArgs(ConnectionEventType eventType) { this.eventType = eventType; } public ConnectionEventType EventType { get { return eventType; } } } } --- NEW FILE --- /** * Namespace: CSMail * Delegate: ConnectionEventHandler * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ namespace CSMail { public delegate void ConnectionEventHandler(object sender, ConnectionEventArgs e); } --- NEW FILE --- /** * Namespace: CSMail * Enumeration: ConnectionEventType * Comment: Enumeration ConnectionEventType contains various possible\ * events associated with a Connection. * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ namespace CSMail { public enum ConnectionEventType { Opened, Closed, Disconnected } } --- NEW FILE --- /** * Namespace: CSMail * Enumeration: ContentDisposition * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ namespace CSMail { public enum ContentDisposition { Attachment, Inline } } --- NEW FILE --- /** * Namespace: CSMail * Class: ContentType * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ using System; namespace CSMail { public class ContentType { private string primaryType; private string subType; private ParameterList parameters; public ContentType(string primary, string sub) { primaryType = primary; subType = sub; } public ContentType(string primary, string sub, ParameterList parameters) { primaryType = primary; subType = sub; this.parameters = parameters; } public string PrimaryType { get { if(primaryType != null) return primaryType; return String.Empty; } } public string SubType { get { if(subType != null) return subType; return String.Empty; } } public ParameterList Parameters { get { return parameters; } } public override bool Equals(object obj) { if(obj is ContentType) { return Equals((ContentType)obj); } if(obj is string) { return Equals((string)obj); } return false; } public bool Equals(ContentType cType) { if(cType != null) { return Equals(cType.ToString()); } return false; } public bool Equals(string cType) { return (cType.Equals(this.ToString())); } public override string ToString() { string retVal; retVal = primaryType; if(primaryType != "") retVal += "/"; retVal += SubType; if(retVal != "" && parameters!=null) { retVal += ";"; retVal += parameters.ToString(); } return retVal; } public override int GetHashCode() { return (primaryType.GetHashCode() + subType.GetHashCode()); } } } --- NEW FILE --- /** * Namespace: CSMail * Class: EMailAddress * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ using System; namespace CSMail { public class EMailAddress: IAddress { private string user; private string host; private string name; public EMailAddress(string user, string host) { this.user = user; this.host = host; } public EMailAddress(string name, string user, string host): this(user, host) { this.name = name; } public string User { get { return user; } } public string Host { get { return host; } } public string Name { get { return name; } } public AddressType AddressType { get { return AddressType.EmailAddress; } } public bool Equals(IAddress address) { if(address is EMailAddress) { EMailAddress that = (EMailAddress)address; if(this.User == that.User && this.Host == that.Host && this.Name == that.Name) return true; } return false; } public override string ToString() { string retVal = String.Empty; if(name != null && name != String.Empty) { retVal = (name + " <"); } retVal += (user + "@" + host); if(name != null && name != String.Empty) { retVal += ">"; } return retVal; } } } --- NEW FILE --- /** * Namespace: CSMail * Class: EMailAddressList * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ using System.Collections; namespace CSMail { public class EMailAddressList: IAddressList, IEnumerable { private ArrayList emails; public EMailAddressList() { emails = new ArrayList(); } public EMailAddressList(EMailAddress[] addresses) { emails = new ArrayList(); foreach(EMailAddress current in addresses) { emails.Add(current); } } public EMailAddressList(EMailAddressList addresses) { emails = new ArrayList(); foreach(EMailAddress current in addresses) { emails.Add(current); } } public EMailAddress this[int index] { get { return (EMailAddress)emails[index]; } set { emails[index] = value; } } int IAddressList.Add(IAddress address) { if(address is EMailAddress) return Add((EMailAddress)address); return -1; } void IAddressList.AddAt(int index, IAddress address) { if(address is EMailAddress) AddAt(index, (EMailAddress)address); } public int Count { get { return emails.Count; } } public void Clear() { emails.Clear(); } IAddress IAddressList.GetAddress(int index) { return GetAddress(index); } void IAddressList.Remove(IAddress address) { if(address is EMailAddress) Remove((EMailAddress)address); } public int Add(EMailAddress address) { return emails.Add(address); } public int Add(EMailAddress[] addresses) { foreach(EMailAddress current in addresses) { emails.Add(current); } return emails.Count; } public int IndexOf(EMailAddress address) { return emails.IndexOf(address); } public void AddAt(int index, EMailAddress address) { emails.Insert(index, address); } public EMailAddress GetAddress(int index) { return (EMailAddress)emails[index]; } public void Remove(EMailAddress address) { emails.Remove(address); } public void RemoveAt(int index) { emails.RemoveAt(index); } public IEnumerator GetEnumerator() { return emails.GetEnumerator(); } /// <summary> /// Returns a string of comma separataed addresses. /// </summary> public override string ToString() { string retVal = ""; foreach(EMailAddress current in this) { retVal += (current.ToString() + ","); } retVal = retVal.Substring(0, retVal.Length - 1); return retVal; } } } --- NEW FILE --- /** * Namespace: CSMail * Class: Folder * Comment: An abstract class representing a folder for mail messages.\ * A folder can contain a message, a folder or both. The only\ * method to get a Folder is by using the Folder { get; }\ * property of Store or Folder. * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ using System; namespace CSMail { public abstract class Folder //: IEnumerable { private Session session; protected Folder(Session session) { this.session = session; } public abstract char Delimiter { get; } public abstract FolderType FolderType { get; } public abstract bool HasNewMessages { get; } public abstract bool IsOpen { get; } public abstract bool IsSubscribed { get; } public abstract Folder Parent { get; } public abstract string FullName { get; } public abstract MessageFlags PermanentFlags { get; } public abstract Folder[] Children { get; } public abstract Folder[] SubscribedFolders { get; } [MailTODO] public int Count { get { throw new NotImplementedException(); } } [MailTODO] public bool Exists { get { throw new NotImplementedException(); } } [MailTODO] public Message[] Messages { get { throw new NotImplementedException(); } } [MailTODO] public FolderOpenMode Mode { get { throw new NotImplementedException(); } } [MailTODO] public string Name { get { throw new NotImplementedException(); } } [MailTODO] public int NewMessageCount { get { throw new NotImplementedException(); } } [MailTODO] public Store Store { get { throw new NotImplementedException(); } } [MailTODO] public int UnreadMessageCount { get { throw new NotImplementedException(); } } [MailTODO] public URLName URL { get { throw new NotImplementedException(); } } public abstract void AppendMessages(Message[] messages); public abstract void Close(); public abstract bool Create(FolderType type); public abstract bool Delete(bool recurse); public abstract Message[] Expunge(); public abstract Folder GetFolder(string name); public abstract Message GetMessage(int index); public abstract void Open(FolderOpenMode mode); public abstract bool RenameTo(Folder newFolder); [MailTODO] ~Folder() { throw new NotImplementedException(); } [MailTODO] public Message[] GetMessages(int[] indices) { throw new NotImplementedException(); } [MailTODO] public Message[] GetMessages(int start, int stop) { throw new NotImplementedException(); } [MailTODO] public override string ToString() { throw new NotImplementedException(); } } } --- NEW FILE --- /** * Namespace: CSMail * Class: FolderAddress * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ namespace CSMail { public class FolderAddress { private string protocol; private string username; private string password; private string foldername; private string hostname = null; public FolderAddress(): this("smtp", null, null) { } public FolderAddress(string protocol, string username, string password): this(protocol, username, password, "localhost", null) { } public FolderAddress(string protocol, string username, string password, string hostname, string foldername) { this.protocol = protocol; this.username = username; this.password = password; this.hostname = hostname; this.foldername = foldername; } public string Protocol { get { return protocol; } } public string Username { get { return username; } } public string Password { get { return password; } } public string Foldername { get { return foldername; } } public string Hostname { get { return hostname; } } } } --- NEW FILE --- /** * Namespace: CSMail * Class: FolderEventArgs * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ using System; namespace CSMail { public class FolderEventArgs { private FolderEventType eventType; private Folder folder; private Folder newFolder; public FolderEventArgs(Folder folder, FolderEventType eventType) { if(eventType == FolderEventType.Renamed || !Enum.IsDefined(typeof(FolderEventType), eventType)) { throw new ArgumentException(); } this.eventType = eventType; this.folder = folder; } public FolderEventArgs(Folder folder, Folder newFolder) { this.folder = folder; this.newFolder = newFolder; eventType = FolderEventType.Renamed; } public FolderEventType EventType { get { return eventType; } } public Folder Folder { get { return folder; } } public Folder NewFolder { get { if(eventType == FolderEventType.Renamed) return newFolder; return null; } } } } --- NEW FILE --- /** * Namespace: CSMail * Delegate: FolderEventHandler * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ namespace CSMail { public delegate void FolderEventHandler(object sender, FolderEventArgs e); } --- NEW FILE --- /** * Namespace: CSMail * Enumeration: FolderEventType * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ namespace CSMail { public enum FolderEventType { Created, Deleted, Renamed } } --- NEW FILE --- /** * Namespace: CSMail * Enumration: FolderOpenMode * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ namespace CSMail { public enum FolderOpenMode { ReadOnly, ReadWrite } } --- NEW FILE --- /** * Namespace: CSMail * Enumeration: FolderSortStyle * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ namespace CSMail { public enum FolderSortStyle { Default, Name, Size } } --- NEW FILE --- /** * Namespace: CSMail * Enumeration: FolderType * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ namespace CSMail { public enum FolderType { Folders, Messages, Both } } --- NEW FILE --- /** * Namespace: CSMail * Class: Header * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ namespace CSMail { public class Header { private string name; private string[] values; public Header(string name, string value) { this.name = name; values = new string[1]; values[0] = value; } public Header(string name, string[] values) { this.name = name; this.values = new string[values.Length]; int i = 0; foreach(string current in values) { this.values[i++] = current; } } public string Name { get { return name; } } public string Value { get { if(values != null) return values[0]; return null; } } public string[] Values { get { return values; } } public override string ToString() { string retVal = ""; foreach(string current in Values) { retVal += (name + ": " + current + "\r\n"); } return retVal; } } } --- NEW FILE --- /** * Namespace: CSMail * Class: HeaderList * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ using System; using System.Collections; using System.Collections.Specialized; namespace CSMail { public class HeaderList: IEnumerable { private ArrayList headers = new ArrayList(); public HeaderList(Header header) { headers.Add(header); } public HeaderList(Header[] headers) { foreach(Header current in headers) { this.headers.Add(current); } } public HeaderList(HeaderList headers) { foreach(Header current in headers) { this.headers.Add(current); } } public int Count { get { return headers.Count; } } public Header this[int index] { get { return (Header)(headers[index]); } set { headers[index] = value; } } public IEnumerator GetEnumerator() { return headers.GetEnumerator(); } public int Add(Header header) { return headers.Add(header); } public int Add(Header[] headers) { foreach(Header current in headers) { this.headers.Add(current); } return this.headers.Count; } public int IndexOf(Header header) { return headers.IndexOf(header); } public int IndexOf(string fullHeader, bool ignoreCase) { if(fullHeader == null || fullHeader == "") { return -1; } int i=0; foreach(Header current in this) { if(String.Compare(fullHeader, current.ToString(), ignoreCase) == 0) { return i; } } return -1; } public void Remove(Header header) { headers.Remove(header); } public void RemoveAt(int index) { if(index < 0 || index > headers.Count) { return; } headers.RemoveAt(index); } public bool Exists(string fullHeader, bool ignoreCase) { if(fullHeader == null || fullHeader == "") { return false; } foreach(Header current in this) { if(String.Compare(current.ToString(), fullHeader, ignoreCase) == 0) { return true; } } return false; } public bool Exists(Header header) { return headers.Contains(header); } public void RemoveAll(string name, bool ignoreCase) { ArrayList delete = new ArrayList(); foreach(Header current in this) { if(String.Compare(name, current.Name, ignoreCase) == 0) { delete.Add(current); } } foreach(Header current in delete) { headers.Remove(current); } } public void Remove(string fullHeader, bool ignoreCase) { RemoveAt(IndexOf(fullHeader, ignoreCase)); } public override string ToString() { string retVal = ""; foreach(Header current in this) { retVal += current.ToString(); } return retVal; } } } --- NEW FILE --- /** * Namespace: CSMail * Interface: IAddress * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ namespace CSMail { public interface IAddress { AddressType AddressType { get; } bool Equals(IAddress address); } } --- NEW FILE --- /** * Namespace: CSMail * Interface: IAddressList * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ namespace CSMail { public interface IAddressList { int Count { get; } int Add(IAddress address); void AddAt(int index, IAddress address); void Clear(); IAddress GetAddress(int index); void Remove(IAddress iaddress); void RemoveAt(int index); } } --- NEW FILE --- /** * Namespace: CSMail * Interface: IEncode * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ namespace CSMail { public interface IEncode { string ContentType { get; } /** * I think, I should replace them with a stream (reader) */ string DecodedData { get; } string EncodedData { get; } TransferEncoding TransferEncoding { get; set; } ContentDisposition ContentDisposition { get; set; } } } --- NEW FILE --- /** * Namespace: CSMail * Interface: IMimePart * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ namespace CSMail { public interface IMimePart: IPart { string ContentID { get; set; } string ContentLanguage { get; set; } string ContentMD5 { get; set; } //HeaderList Headers { get; set; } string Text { get; set; } TransferEncoding TransferEncoding { get; set; } } } --- NEW FILE --- /** * Namespace: CSMail * Interface: IPart * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ using System; using System.IO; namespace CSMail { public interface IPart { Multipart Content { get; set; } ContentType ContentType { get; set; } string Description { get; set; } ContentDisposition Disposition { get; set; } string Filename { get; set; } HeaderList Headers { get; set; } int Size { get; set; } int AddHeader(Header header); int AddHeaders(HeaderList headers); void Write(TextWriter writer); } } --- NEW FILE --- /** * Namespace: CSMail * Class: InternetAddress * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ using System; namespace CSMail { public class InternetAddress { private string hostname; private int[] ip; private bool isIP; public InternetAddress(string hostname) { hostname = hostname.Trim(); this.hostname = hostname; if(CheckIfIP(hostname)) { isIP = true; } } public InternetAddress(int[] ip) { if(!ValidIP(ip)) { throw new ArgumentException(); } this.ip = new int[4]; int i = 0; foreach(int current in ip) { this.ip[i++] = current; } hostname = ConvertToAddress(ip); this.isIP = true; } public string Hostname { get { return hostname; } } public bool IsIP { get { return isIP; } } public int[] getIP { get { if(IsIP) { return ip; } return null; } } private string ConvertToAddress(int[] ip) { string retVal = ""; foreach(int current in ip) { retVal += current.ToString() + "."; } retVal = retVal.Substring(0, retVal.Length - 1); return retVal; } private bool ValidIP(int[] ip) { if(ip.Length != 4) return false; foreach(int current in ip) { if(current < 0 || current > 255) return false; } return true; } private bool CheckIfIP(string host) { string[] seps = host.Split(new char[] {'.'}); if(seps.Length != 4) return false; int val; foreach(string current in seps) { val = Int32.Parse(current); if(val < 0 || val > 255) return false; } return true; } } } --- NEW FILE --- /** * Namespace: CSMail * Class: Message * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ using System; using System.IO; namespace CSMail { public abstract class Message: IPart { protected Folder folder; protected int index; protected Session session; protected Message() { } protected Message(Folder folder, int index) { this.folder = folder; this.index = index; } protected Message(Session session) { this.session = session; } public abstract MessageFlags Flags { get; set; } public abstract EMailAddressList From { get; set; } public abstract DateTime ReceivedDate { get; set; } public abstract IAddressList Recipients { get; } public abstract DateTime SentDate { get; set; } public abstract string Subject { get; set; } public abstract void AddFrom(EMailAddress address); public abstract void AddFrom(EMailAddressList address); public abstract void AddRecipient(RecipientType type, EMailAddress email); public abstract void AddRecipients(RecipientType type, EMailAddressList emails); public abstract void AddRecipient(NewsAddress email); public abstract void AddRecipients(NewsAddressList email); public abstract Message GetReplyMessage(bool toAll); public abstract IAddressList GetRecipients(RecipientType type); public abstract void SaveChanges(); public abstract Multipart Content { get; set; } public abstract ContentType ContentType { get; set; } public abstract string Description { get; set; } public abstract ContentDisposition Disposition { get; set; } public abstract string Filename { get; set; } public abstract HeaderList Headers { get; set; } public abstract int Size { get; set; } public abstract int AddHeader(Header header); public abstract int AddHeaders(HeaderList headers); public abstract void Write(TextWriter writer); [MailTODO] public virtual Folder Folder { get { throw new NotImplementedException(); } } [MailTODO] public bool IsExpunged { get { throw new NotImplementedException(); } set { throw new NotImplementedException(); } } [MailTODO] public IAddressList ReplyTo { get { throw new NotImplementedException(); } set { throw new NotImplementedException(); } } [MailTODO] public bool IsSet(MessageFlags flag) { throw new NotImplementedException(); } } } --- NEW FILE --- /** * Namespace: CSMail * Enumeration: MessageFlags * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ using System; namespace CSMail { [Flags] public enum MessageFlags { None = 0x0000, Answered = 0x0001, Deleted = 0x0002, Draft = 0x0004, Flagged = 0x0010, Recent = 0x0020, Seen = 0x0040, UserDefined = 0x8000, } } --- NEW FILE --- /** * Namespace: CSMail * Enumeration: MessageSortStyle * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ namespace CSMail { public enum MessageSortStyle { Default, From, Size, Date, Subject } } --- NEW FILE --- /** * Namespace: CSMail * Class: Multipart * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ namespace CSMail { public abstract class Multipart { private IPart part; public IPart Part { get { return part; } set { part = value; } } } } --- NEW FILE --- /** * Namespace: CSMail * Class: NewsAddress * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ using System; using System.Collections; namespace CSMail { public class NewsAddress: IAddress { private string hostname; private ArrayList groups = new ArrayList(); public NewsAddress(string host, string group) { hostname = host; groups.Add(group); } public NewsAddress(string host, string[] groups) { if(groups == null || groups.Length == 0) { throw new ArgumentException(); } hostname = host; foreach(string current in groups) { this.groups.Add(current); } } public AddressType AddressType { get { return AddressType.NewsAddress; } } public string Hostname { get { return hostname; } } public string Group { get { if(groups.Count > 0) { return (string)groups[0]; } return null; } } public string[] Groups { get { if(groups.Count > 0) { string[] retVal = new string[groups.Count]; for(int i=0; i < groups.Count; i++) { retVal[i] = (string)groups[i]; } return retVal; } return null; } } public int Add(string group) { return groups.Add(group); } public void Remove(string group) { groups.Remove(group); } public bool Contains(string group) { return groups.Contains(group); } public override int GetHashCode() { return hostname.GetHashCode() + (Group == null ? 0xFFFF : Group.GetHashCode()); } public override bool Equals(object obj) { if(obj is NewsAddress) { return Equals((NewsAddress)obj); } return false; } public bool Equals(IAddress address) { if(address is NewsAddress) { return Equals((NewsAddress)address); } return false; } public bool Equals(NewsAddress address) { if(address.hostname == hostname && Groups != null && address.Groups != null && Groups.Length == address.Groups.Length) { for(int i=0; i < groups.Count; i++) { if(String.Compare(Groups[i], address.Groups[i], false) != 0) { return false; } } return true; } return false; } } } --- NEW FILE --- /** * Namespace: CSMail * Class: NewsAddressList * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ using System.Collections; namespace CSMail { public class NewsAddressList: IAddressList, IEnumerable { private ArrayList news = new ArrayList(); public NewsAddressList() { } public NewsAddressList(NewsAddressList[] addresses) { foreach(NewsAddressList current in addresses) { news.Add(current); } } public NewsAddressList(NewsAddressList addresses) { foreach(NewsAddressList current in addresses) { news.Add(current); } } public NewsAddressList this[int index] { get { return (NewsAddressList)news[index]; } set { news[index] = value; } } int IAddressList.Add(IAddress address) { if(address is NewsAddressList) return Add((NewsAddressList)address); return -1; } void IAddressList.AddAt(int index, IAddress address) { if(address is NewsAddressList) AddAt(index, (NewsAddressList)address); } public int Count { get { return news.Count; } } public void Clear() { news.Clear(); } IAddress IAddressList.GetAddress(int index) { return GetAddress(index); } void IAddressList.Remove(IAddress address) { if(address is NewsAddressList) Remove((NewsAddressList)address); } public int Add(NewsAddressList address) { return news.Add(address); } public int Add(NewsAddressList[] addresses) { foreach(NewsAddressList current in addresses) { news.Add(current); } return news.Count; } public int IndexOf(NewsAddressList address) { return news.IndexOf(address); } public void AddAt(int index, NewsAddressList address) { news.Insert(index, address); } public NewsAddress GetAddress(int index) { return (NewsAddress)news[index]; } public void Remove(NewsAddressList address) { news.Remove(address); } public void RemoveAt(int index) { news.RemoveAt(index); } public IEnumerator GetEnumerator() { return news.GetEnumerator(); } } } --- NEW FILE --- /** * Namespace: CSMail * Class: Parameter * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ namespace CSMail { public class Parameter { private string name; private string value; public Parameter(string name, string value) { this.name = name; this.value = value; } public string Name { get { return name; } } public string Value { get { return value; } } } } --- NEW FILE --- /** * Namespace: CSMail * Class: ParameterList * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ using System.Collections; namespace CSMail { public class ParameterList: IEnumerable { private Hashtable parameters; public ParameterList(Parameter parameter) { parameters = new Hashtable(); parameters.Add(parameter.Name, parameter.Value); } public ParameterList(Parameter[] parameters) { this.parameters = new Hashtable(); foreach(Parameter current in parameters) { this.parameters.Add(current.Name, current.Value); } } public ParameterList(ParameterList parameters) { this.parameters = new Hashtable(); foreach(string name in parameters) { this.parameters.Add(name, parameters[name]); } } public string this[string name] { get { return (string)(parameters[name]); } set { parameters[name] = value; } } public int Count { get { return parameters.Count; } } public void Add(Parameter parameter) { parameters.Add(parameter.Name, parameter.Value); } public void Remove(Parameter parameter) { Remove(parameter.Name); } public void Remove(string name) { if(parameters.ContainsKey(name)) parameters.Remove(name); } /// <summary> /// Returns an Enumerator on the Name(s) of the Parameter(s) /// </summary> public IEnumerator GetEnumerator() { return (IEnumerator)(parameters.Keys); } public override string ToString() { string retVal = ""; foreach(string key in this) { retVal += (key + "=\"" + this[key] + "\";"); } retVal = retVal.Substring(0, retVal.Length - 1); return retVal; } } } --- NEW FILE --- /** * Namespace: CSMail * Class: Provider * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ using System; namespace CSMail { public class Provider { private string className; private string protocol; private ProviderType type; private string vendor; private string version; internal Provider() { //TODO: Initialize the values from the configuration file Initialize(String.Empty); } internal Provider(string configFile) { Initialize(configFile); } [MailTODO] internal void Initialize(string configFile) { throw new NotImplementedException(); } public string ClassName { get { return className; } } public string Protocol { get { return protocol; } } public ProviderType ProviderType { get { return type; } } public string Vendor { get { return vendor; } } public string Version { get { return version; } } } } --- NEW FILE --- /** * Namespace: CSMail * Enumeration: ProviderType * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ namespace CSMail { public enum ProviderType { Store, Transport } } --- NEW FILE --- /** * Namespace: CSMail * Enumeration: RecipientType * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ using System; namespace CSMail { [Flags] public enum RecipientType: short { To = 0x0001, Cc = 0x0002, Bcc = 0x0004, NewsGroup = 0x0010, All = To | Cc | Bcc | NewsGroup } } --- NEW FILE --- /** * Namespace: CSMail * Class: Service * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ using System; namespace CSMail { public abstract class Service { protected bool connected; protected bool debug; protected Session session; protected URLName url; protected Service(Session session, URLName url) { this.session = session; this.url = url; } public URLName URL { get { return url; } } public bool Connected { get { return connected; } } [MailTODO] public void Close() { throw new NotImplementedException(); } [MailTODO] public void Connect() { throw new NotImplementedException(); } [MailTODO] public void Connect(InternetAddress hostname, string username, string password) { throw new NotImplementedException(); } [MailTODO] public void Connect(InternetAddress hostname, int port, string username, string password) { throw new NotImplementedException(); } [MailTODO] ~Service() { throw new NotImplementedException(); } } } --- NEW FILE --- /** * Namespace: CSMail * Class: Session * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ using System.Collections; using CSMail.Utils; namespace CSMail { public class Session { private Properties properties; private Authentiactor authenticator; private Hashtable authTable; private ArrayList providers; private Hashtable provByProto; private Hashtable provByClass; private Properties addrMap; private bool debug; private static Session defaultSession; private Session() { } private Session(Properties properties, Authenticator authenticator) { this.properties = properties; this.authenticator = authenticator; this.debug = false; authTable = new Hashtable(); providers = new ArrayList(); provByProto = new Hashtable(); provByClass = new Hashtable(); addrMap = new Properties(); // debug = bool.Parse(this.properties["mail.debug"]) } public Session GetDefaultInstance(Properties properties, Authenticator authenticator) { if(defaultSession == null) { defaultSession = new Session(); // Do some initialization??? } return defaultSession; } } } --- NEW FILE --- /** * Namespace: CSMail * Class: Store * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ namespace CSMail { public abstract class Store: Service { public Store(Session session, URLName url): base(session, url) { } public abstract Folder DefaultFolder { get; } public abstract Folder this[string folderName] { get; } public abstract Folder this[URLName url] { get; } } } --- NEW FILE --- /** * Namespace: CSMail * Class: MailTODOAttribute * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ using System; namespace CSMail { [AttributeUsage(AttributeTargets.All)] internal class MailTODOAttribute: Attribute { string comment; public MailTODOAttribute() { comment = ""; } public MailTODOAttribute(string comment) { this.comment = comment; } } } --- NEW FILE --- /** * Namespace: CSMail * Enumeration: TransferEncoding * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ namespace CSMail { public enum TransferEncoding { Default, Bit7, Bit8, QuotedPrintable, Base64, Binary, UUEncode, UserDefined } } --- NEW FILE --- /** * Namespace: CSMail * Class: URLName * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ using System; using System.Net; namespace CSMail { public class URLName { private string protocol = "smtp"; private string host = "localhost"; private int port = 25; private string username; private string password; private string file; private string fullUrl; public URLName(string url) { ParseURL(url); fullUrl = url; } public URLName(string protocol, string host, int port, string user, string pass, string file) { this.protocol = protocol; this.host = host; this.port = port; this.username = user; this.password = pass; this.file = file; fullUrl = protocol + "://" + host; if(user != null && user.Length > 0) { fullUrl += user; if(pass != null && pass.Length > 0) { fullUrl += ":" + pass; } fullUrl += "@"; } fullUrl += host; if(port > 0) { fullUrl += ":" + port.ToString(); } if(!file.StartsWith("/")) { fullUrl += "/"; } fullUrl += file; } public string Protocol { get { return protocol; } } public string Host { get { return host; } } public int Port { get { return port; } } public string Username { get { return username; } } public string Password { get { return password; } } public string File { get { return file; } } [MailTODO] /// <summary> /// The URL is to be of the form: /// protocol://[user[:pass@]]host[:port]/file /// </summary> private void ParseURL(string url) { throw new NotImplementedException(); } public override bool Equals(object obj) { if(obj is URLName) { return Equals((URLName)obj); } return false; } public bool Equals(URLName url) { if(url.Protocol == protocol && url.Host == host && url.Port == port && url.Username == username && url.Password == password) { return true; } return false; } public override int GetHashCode() { return fullUrl.GetHashCode(); } } } |
From: Gaurav V. <mas...@us...> - 2002-07-24 10:57:57
|
Update of /cvsroot/csmail/csmail/src/CSMail.Utils In directory usw-pr-cvs1:/tmp/cvs-serv1717/src/CSMail.Utils Added Files: ChangeLog Properties.cs Log Message: 2002-02-24 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> * **.**/** -- Final single commit for all the files. --- NEW FILE --- 2002-06-20 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> * Properties.cs: Added file. Dummy class right now. --- NEW FILE --- /** * Namespace: CSMail.Utils * Class: Properties * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ namespace CSMail.Utils { public class Properties { private Properties() { } } } |
From: Gaurav V. <mas...@us...> - 2002-07-24 10:57:57
|
Update of /cvsroot/csmail/csmail/src In directory usw-pr-cvs1:/tmp/cvs-serv1717/src Added Files: .cvsignore CSMail.build ChangeLog makefile Log Message: 2002-02-24 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> * **.**/** -- Final single commit for all the files. --- NEW FILE --- *~ .*.swp license --- NEW FILE --- <?xml version="1.0" encoding="iso-8859-1"?> <!-- NAnt build file for CSMail.dll --> <project name="CSMail" default="build"> <property name="debug" value="false"/> <target name="build"> <echo message="Building the CSMail library..."/> <mkdir dir="../lib"/> <csc target="library" output="../lib/CSMail.dll" debug="${debug}"> <sources> <includes name="CSMail/*.cs"/> <includes name="CSMail.Utils/*.cs"/> </sources> </csc> </target> <target name="clean"> <echo message="Cleaning the CSMail library..."/> <delete file="../lib/CSMail.dll" failonerror="false"/> <delete dir="../lib" failonerror="false"/> </target> </project> --- NEW FILE --- 2002-06-20 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> * Added directory CSMail.Utils 2002-06-13 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> * Added directory CSMail --- NEW FILE --- NANT = ../nant/NAnt.exe BUILD_FILE = CSMail.build all: lib linux: lib windows: lib lib: @$(NANT) -buildfile:$(BUILD_FILE) build clean: @rm -f *~ .*~ @rm -f CSMail/*~ CSMail/.*~ @$(NANT) -buildfile:$(BUILD_FILE) clean |
From: Gaurav V. <mas...@us...> - 2002-07-24 10:57:56
|
Update of /cvsroot/csmail/csmail/nant In directory usw-pr-cvs1:/tmp/cvs-serv1717/nant Added Files: NAnt.exe Log Message: 2002-02-24 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> * **.**/** -- Final single commit for all the files. --- NEW FILE --- MZ $ * * Ü* + + + o &~ + +o t ( .o o -ÞÞu Ü* +o t o o -æÞu Ü* z( r &o Q +o t o o -åÞu Ü( +o t o -æÞu Ü* ( +o t o o -åÞu Ü( +o t o -æÞu Ü ( ( } r r s { 8î ( r 9Ï ( r¡ 9° ( r· 9 ( rã 9r r /a* r X X2ß Xo+ XYo, + o( 1 o+ ++ & X X2äo- y+ +o- y+ r ,+ r ¢ r { o3 s o( o4 :þÿÿ*0 ( ,{ y +~ + r o9 & o: & o; ,+X o; , o< -æo9 &o= - r# --Xr r ,+r o= - r# :@ÿÿÿr + + (@ Ð! (B t! + ~ + + + 8Ø 8² (B t oE -$ o« ( oH (I oJ Ð (B t t$ 9æ ,oG oË oM +0o t oG oÎ oN &o -ÇÞu Ür¥ oM +,o t oG oN &o -ËÞu Ü X i?CþÿÿoO Ð @þÿÿ* 8é 8à (B t t# Ð (P t +E oK o ( i2³ X i?2ÿÿÿoO Ð @ÿÿÿ* *0 + + + + + + + + + + + + + oT > oU 8è t# t# ,#(9 ( (W -3 (X &(9 Þ rû ( :ÿÿÿÞu Ü* (" (1 * (> +(" (0 ,;o^ ,o_ o_ (` +(6 +$( 8 oc s[ s[ o^ ,=o^ ,o_ o_ (` + (6 ,(: +$( :dÿÿÿo; } } } } } } } + + + + + + + (" Þ rÛ ( ( + ob (F -æ(A +0 ob sf og i-oh i-(E -Ç* ,T(C 1 (j +( (k +sl zÞ% (@ ( ,1(C +so zÞ% (@ ( } } } ( + + + + + + oM +o o t rd ,{" oð &rr ,({" oð & o -Þ u Ü* {" + ob oq or od -ào + ot oJ ot (Q ot ow ot ox ot oL (O oz ¢ot o{ ¢ot o| ¢( &o~ o oi 1( &oN ,r ( }! }" + + + + + oJ ¢(Q }& }' -rú s¶ + ~, +o t# , +o -á+ s oM +7o t &o -ÀÞu Ü{+ +o t -âÞu ÜrL oM +7o t &o -ÀÞu Ü* ~, s o (_ ( &Ü* , + + + + + + + + + + + * * ( + o^ -+X(l (Æ (Æ (Æ }- (i + +ob rl -â(k +ob r -â(j +ob r -â(l +ob o od -æo (O ( o ( (R {- }- }0 + (W -G( -rî ( ( >' oU 8í t# (: t# ,( ( ,2( +Ksf o^ -(V (X &( Þ# rÌ (Q ( :ÿÿÿÞu Ü* {8 &oé }< + + + + + + * ( }> }? }@ }A +r ,1r -$r -r +(0 +,r -+r s s Þ&Þ ( (V ,r ,(W -(X &s Þ&Þ ? , r ,^{D ..r +{D 3{F +{F (0 {B s[ s[ o^ -r -rT ,*o_ o_ (` -o_ o_ (` + 9+ {B (* ( 9Í s£ ( (* ( Þ"o s· s· ¢rú ¢(¥ ( Þo s· ( (0 ( oö oö oö (" ( + + ,+rê *0 ,rö +(rl ,r + r *0 * ( &Þ&r& (F Þ + + (¯ (£ (£ Þ&rì (F Þ (ª + + + (± + }P + * * *0 }Q }Q {Q (' , r + + + + + + }U +ob {U &od -Þs }V +ob {V &od -Þs }W }X ( oh +o´ ( +/o] ( (à &Xi2É(à &* {U +ob (µ o¶ , + od -Û,6{V +ob (µ o¶ , + od -Ù+ /~\ o· &\~\ o· &o (¸ -(½ ( s r &r &rF &rP &rZ &r- &rj &rt &r~ &~\ (º r ,r: rj o¹ &r &r o¹ &r® o¹ &|*o· &^o» &$oq &o + }R }S }T *0 +, ob s[ o^ -Þo_ (` ,Þ od -Ì+ }Y }Z (Í &(Ï &*0 + + + + + sÅ + ob {[ & od -Ù(Î 0(Ì &(Ï + ob {[ & od -Ù{[ + + s½ o¾ (Ö (Ö (Ö {_ {` |` (0 ræ + ( , rê oÀ oâ , r oÀ oà , r oÀ oà ,O r" o¶ ,7oÁ o oà oÁ o oà oç ,+, rJ , oä 1 oå &Xi?Øþÿÿ(Ä oÅ oÆ (Ç oÈ (É 9 + + + (k rº (Î rô rD rÝ rx (Î r (Î r? rQ (k r© (k r (k r (k (Î r± +oé ( + *0 * sf ~c i1o] ( + }i s + + + + + + + + (§ (ß (à (à (? ,4(ß s¶ (á Þ r$ s· (Ñ ( i+ ÞX( ( ,oÓ o ( ( +(Ö o× +HÐ oØ ,*oÙ -"{m s oG (Þ oG (à oG }e oÜ oU +1o t# t# oô -ÆÞu Üo s oM +9o t &o -¾Þu Ü(æ +o t -âÞu ÜrL oM +-o t o o &o -ÊÞu Ü*4 -(å &(å +ob (í -ê*0 -rÌ s¶ + ,-{l { 9 oß +Vo tU 1@oá oÁ o oâ oã oà (ç oc o -¡Þu Ü+ ,(¸ - ( +( + -{o &(æ oç * - (æ oç *0 oÝ t# + - (æ oè *0 *0 }o * }t (ý + + + + + -r$ (û ,XoG * +, oë oi 1( & X i2Ìr oM +0o t &o -ÇÞu Ü* +9 ob (ü s¶ -¿( +o t -äÞu ÜÞ}r +o t) oú ,Þo -ÚÞu Ü+ * }u ( Ð! (B t! + + + +( + t o# Þ o ( & + +o t+ o ,Þo -ÚÞu Ü+ * * ( + + ( s¶ B × × × × × × × × × × ã ã ã ã ! ' ." ß !% ß !. ß !/ ß '0 .2 ±{ß ¹þm QÌ ¹¬.ÁÒ` É"® Ñ y» Ù: á: BD#µ!B^ÁB£áBöB»ú!BÆABÒazázñ¡z * / 7 U } ¡ È ë ÷ ý K`¥Åàó&+9? Ç Ç î Ç Ç ò ò ò ò tion 4&ÒaO((;ì8i ¤ ¬ ¬° ==åù ù Ñ!Ñ!¤} -= references ñù ùa ¬ |
Update of /cvsroot/csmail/csmail/nunit/src/NUnitCore In directory usw-pr-cvs1:/tmp/cvs-serv27574/nunit/src/NUnitCore Added Files: ActiveTestSuite.cs AssemblyInfo.cs AssemblyTestCollector.cs Assertion.cs AssertionFailedError.cs BaseTestRunner.cs ClassPathTestCollector.cs ExceptionTestCase.cs ExpectExceptionAttribute.cs IFailureDetailView.cs IProtectable.cs ITest.cs ITestCollector.cs ITestListener.cs ITestLoader.cs ITestSuiteLoader.cs LoadingTestCollector.cs NUnitCore.csproj NUnitException.cs ReflectionUtils.cs ReloadingTestSuiteLoader.cs RepeatedTest.cs SimpleTestCollector.cs StandardLoader.cs StandardTestSuiteLoader.cs TestCase.cs TestCaseClassLoader.cs TestDecorator.cs TestFailure.cs TestResult.cs TestSetup.cs TestSuite.cs Version.cs Log Message: 2002-02-24 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> * NUnit -- Added the sourcecode. I hope there's no problem with license. --- NEW FILE --- namespace NUnit.Extensions { using System; using System.Threading; using NUnit.Framework; /// <summary> /// A TestSuite for active Tests. It runs each test in a /// separate thread and until all threads have terminated. /// -- Aarhus Radisson Scandinavian Center 11th floor /// </summary> public class ActiveTestSuite: TestSuite { private int fActiveTestDeathCount; /// <summary> /// /// </summary> /// <param name="result"></param> public override void Run(TestResult result) { fActiveTestDeathCount= 0; base.Run(result); WaitUntilFinished(); } /// <summary> /// /// </summary> /// <param name="test"></param> /// <param name="result"></param> public void BaseRunTest(ITest test, TestResult result) { base.RunTest(test, result); } /// <summary> /// /// </summary> /// <param name="test"></param> /// <param name="result"></param> public override void RunTest(ITest test, TestResult result) { ThreadLittleHelper tlh = new ThreadLittleHelper(test, result, this); Thread t = new Thread(new ThreadStart(tlh.Run)); t.Start(); } /// <summary> /// /// </summary> /// <param name="test"></param> public void RunFinished(ITest test) { lock(this) { fActiveTestDeathCount++; Monitor.PulseAll(this); } } private void WaitUntilFinished() { lock(this) { while (fActiveTestDeathCount < TestCount) { try { Monitor.Wait(this); } catch (ThreadInterruptedException) { return; // TBD } } } } #region Nested Classes /// <summary> /// /// </summary> public class ThreadLittleHelper { private ITest fTest; private TestResult fResult; private ActiveTestSuite fSuite; /// <summary> /// /// </summary> /// <param name="test"></param> /// <param name="result"></param> /// <param name="suite"></param> public ThreadLittleHelper(ITest test, TestResult result, ActiveTestSuite suite) { fSuite = suite; fTest = test; fResult = result; } /// <summary> /// /// </summary> public void Run() { try { fSuite.BaseRunTest(fTest, fResult); } finally { fSuite.RunFinished(fTest); } } } #endregion } } --- NEW FILE --- using System; using System.Reflection; using System.Runtime.CompilerServices; // Mark the framework assembly as CLS compliant [assembly:CLSCompliant(true)] // // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. // [assembly:AssemblyTitle("NUnit Testing Framework")] [assembly:AssemblyDescription("A unit testing framework for the .Net platform, ported from junit by Kent Beck and Erich Gamma.")] [assembly:AssemblyConfiguration("")] [assembly:AssemblyCompany("")] [assembly:AssemblyProduct("NUnit")] [assembly:AssemblyCopyright("")] [assembly:AssemblyTrademark("")] [assembly:AssemblyCulture("")] // // Version information for an assembly consists of the following four values: // // Major Version // Minor Version // Revision // Build Number // // You can specify all the value or you can default the Revision and Build Numbers // by using the '*' as shown below: [assembly:AssemblyVersion("1.11.*")] // // In order to sign your assembly you must specify a key to use. Refer to the // Microsoft .NET Framework documentation for more information on assembly signing. // // Use the attributes below to control which key is used for signing. // // Notes: // (*) If no key is specified - the assembly cannot be signed. // (*) KeyName refers to a key that has been installed in the Crypto Service // Provider (CSP) on your machine. // (*) If the key file and a key name attributes are both specified, the // following processing occurs: // (1) If the KeyName can be found in the CSP - that key is used. // (2) If the KeyName does not exist and the KeyFile does exist, the key // in the file is installed into the CSP and used. // (*) Delay Signing is an advanced option - see the Microsoft .NET Framework // documentation for more information on this. // //[assembly: AssemblyDelaySign(false)] //[assembly: AssemblyKeyFile(@"..\..\..\..\NUnit.key")] //[assembly: AssemblyKeyName("")] --- NEW FILE --- using System; using NUnit.Framework; namespace NUnit.Runner { /// <summary> /// Collects the names of all classes in an assembly that are tests. /// </summary> public sealed class AssemblyTestCollector : MarshalByRefObject, ITestCollector { #region Instance Variables private string fAssemblyName; private StandardLoader fLoader; #endregion #region Constructors /// <summary> /// Create a new AssemblyTestCollector for the specified /// assembly, and uses the supplied loader to load the tests /// from the assembly. /// </summary> /// <param name="assemblyName">The file name of the assembly /// from which to load classes</param> /// <param name="loader">An instance if the standard loader to /// use for loading tests from the assembly.</param> public AssemblyTestCollector(string assemblyName, StandardLoader loader) { if(loader!=null) fLoader = loader; else throw new ArgumentNullException("loader"); if(assemblyName != null) { fAssemblyName = assemblyName; } else throw new ArgumentNullException("assemblyName"); } /// <summary> /// Create a new AssemblyTestCollector for the specified /// assembly. /// </summary> /// <param name="assemblyName">The file name of the assembly /// from which to load classes.</param> public AssemblyTestCollector(string assemblyName) : this(assemblyName,new StandardLoader()){} /// <summary> /// returns a System.String[] of FullNames for all test classes /// contained within the assembly. /// Implements ITestCollector.CollectTestsClassNames() /// </summary> #endregion #region ITestCollector Methods public string[] CollectTestsClassNames() { Type[] tests = fLoader.GetTestTypes(fAssemblyName); string[] ret = new string[tests.Length]; int i=0; foreach (Type testType in tests) { ret[i] = testType.FullName; i++; } return ret; } #endregion } } --- NEW FILE --- namespace NUnit.Framework { using System; /// <summary>A set of Assert methods.</summary> public class Assertion : MarshalByRefObject { /// <summary> /// Protect constructor since it is a static only class /// </summary> protected Assertion():base(){} /// <summary> /// Asserts that a condition is true. If it isn't it throws /// an <see cref="AssertionFailedError"/>. /// </summary> /// <param name="message">The message to display is the condition /// is false</param> /// <param name="condition">The evaluated condition</param> static public void Assert(string message, bool condition) { if (!condition) Assertion.Fail(message); } /// <summary> /// Asserts that a condition is true. If it isn't it throws /// an <see cref="AssertionFailedError"/>. /// </summary> /// <param name="condition">The evaluated condition</param> static public void Assert(bool condition) { Assertion.Assert(string.Empty, condition); } /// <summary> /// /// Asserts that two doubles are equal concerning a delta. If the /// expected value is infinity then the delta value is ignored. /// </summary> /// <param name="expected">The expected value</param> /// <param name="actual">The actual value</param> /// <param name="delta">The maximum acceptable difference between the /// the expected and the actual</param> static public void AssertEquals(double expected, double actual, double delta) { Assertion.AssertEquals(string.Empty, expected, actual, delta); } /// <summary> /// /// Asserts that two singles are equal concerning a delta. If the /// expected value is infinity then the delta value is ignored. /// </summary> /// <param name="expected">The expected value</param> /// <param name="actual">The actual value</param> /// <param name="delta">The maximum acceptable difference between the /// the expected and the actual</param> static public void AssertEquals(float expected, float actual, float delta) { Assertion.AssertEquals(string.Empty, expected, actual, delta); } /// <summary>Asserts that two objects are equal. If they are not /// an <see cref="AssertionFailedError"/> is thrown.</summary> static public void AssertEquals(Object expected, Object actual) { Assertion.AssertEquals(string.Empty, expected, actual); } /// <summary>Asserts that two doubles are equal concerning a delta. /// If the expected value is infinity then the delta value is ignored. /// </summary> static public void AssertEquals(string message, double expected, double actual, double delta) { // handle infinity specially since subtracting two infinite values gives // NaN and the following test fails if (double.IsInfinity(expected)) { if (!(expected == actual)) Assertion.FailNotEquals(message, expected, actual); } else if (!(Math.Abs(expected-actual) <= delta)) Assertion.FailNotEquals(message, expected, actual); } /// <summary>Asserts that two floats are equal concerning a delta. /// If the expected value is infinity then the delta value is ignored. /// </summary> static public void AssertEquals(string message, float expected, float actual, float delta) { // handle infinity specially since subtracting two infinite values gives // NaN and the following test fails if (float.IsInfinity(expected)) { if (!(expected == actual)) Assertion.FailNotEquals(message, expected, actual); } else if (!(Math.Abs(expected-actual) <= delta)) Assertion.FailNotEquals(message, expected, actual); } /// <summary>Asserts that two objects are equal. If they are not /// an <see cref="AssertionFailedError"/> is thrown.</summary> static public void AssertEquals(string message, Object expected, Object actual) { if (expected == null && actual == null) return; if (expected != null && expected.Equals(actual)) return; Assertion.FailNotEquals(message, expected, actual); } /// <summary>Asserts that an object isn't null.</summary> static public void AssertNotNull(Object anObject) { Assertion.AssertNotNull(string.Empty, anObject); } /// <summary>Asserts that an object isn't null.</summary> static public void AssertNotNull(string message, Object anObject) { Assertion.Assert(string.Empty, anObject != null); } /// <summary>Asserts that an object is null.</summary> static public void AssertNull(Object anObject) { Assertion.AssertNull(string.Empty, anObject); } /// <summary>Asserts that an object is null.</summary> static public void AssertNull(string message, Object anObject) { Assertion.Assert(message, anObject == null); } /// <summary>Asserts that two objects refer to the same object. If they /// are not the same an <see cref="AssertionFailedError"/> is thrown. /// </summary> static public void AssertSame(Object expected, Object actual) { Assertion.AssertSame(string.Empty, expected, actual); } /// <summary>Asserts that two objects refer to the same object. /// If they are not an <see cref="AssertionFailedError"/> is thrown. /// </summary> static public void AssertSame(string message, Object expected, Object actual) { if (expected == actual) return; Assertion.FailNotSame(message, expected, actual); } /// <summary>Fails a test with no message.</summary> static public void Fail() { Assertion.Fail(string.Empty); } /// <summary>Fails a test with the given message.</summary> static public void Fail(string message) { if (message == null) message = string.Empty; throw new AssertionFailedError(message); } static private void FailNotEquals(string message, Object expected, Object actual) { string formatted=string.Empty; if (message != null) formatted= message+" "; Assertion.Fail(formatted+"expected:<"+expected+"> but was:<"+actual+">"); } static private void FailNotSame(string message, Object expected, Object actual) { string formatted=string.Empty; if (message != null) formatted= message+" "; Assertion.Fail(formatted+"expected same"); } } } --- NEW FILE --- namespace NUnit.Framework { using System; using System.Runtime.Serialization; /// <summary> /// Thrown when an assertion failed. /// </summary> [Serializable] public class AssertionFailedError : ApplicationException//NUnitException { /// <summary> /// Serialization Constructor /// </summary> protected AssertionFailedError(SerializationInfo info, StreamingContext context) : base(info,context){} /// <summary> /// /// </summary> /// <param name="message"></param> public AssertionFailedError (string message) : base(message) {} // public override bool IsAssertionFailure // { // get{return true;} // } } } --- NEW FILE --- namespace NUnit.Runner { using System; using System.Collections; using System.Collections.Specialized; using System.IO; using System.IO.IsolatedStorage; using System.Reflection; using NUnit.Framework; /// <summary> /// Base class for all test runners. /// </summary> /// <remarks> /// /// </remarks> public abstract class BaseTestRunner: MarshalByRefObject, ITestListener { /// <summary> /// /// </summary> [Obsolete("Shoud be handled by a loader")] public static string SUITE_PROPERTYNAME="Suite"; private static NameValueCollection fPreferences = new NameValueCollection(); private static int fgMaxMessageLength = 500; private static bool fgFilterStack = true; private bool fLoading = true; /// <summary> /// /// </summary> public BaseTestRunner() { fPreferences = new NameValueCollection(); fPreferences.Add("loading", "true"); fPreferences.Add("filterstack", "true"); ReadPreferences(); fgMaxMessageLength = GetPreference("maxmessage", fgMaxMessageLength); } #region ITestListener Methods /// <summary> /// /// </summary> /// <param name="test"></param> /// <param name="t"></param> public abstract void AddError(ITest test, Exception t); /// <summary> /// /// </summary> /// <param name="test"></param> /// <param name="t"></param> public abstract void AddFailure(ITest test, AssertionFailedError t); /// <summary> /// /// </summary> /// <param name="test"></param> public abstract void EndTest(ITest test); #endregion #if false /// <summary> /// Clears the status message. /// </summary> protected virtual void ClearStatus() { // Belongs in the GUI TestRunner class. } #endif /// <summary> /// Returns the formatted string of the elapsed time. /// </summary> public static string ElapsedTimeAsString(long runTime) { return ((double)runTime/1000).ToString(); } /// <summary> /// Extract the class name from a string in VA/Java style /// </summary> public static string ExtractClassName(string className) { if(className.StartsWith("Default package for")) return className.Substring(className.LastIndexOf(".")+1); return className; } static bool FilterLine(string line) { string[] patterns = new string[] { "NUnit.Framework.TestCase", "NUnit.Framework.TestResult", "NUnit.Framework.TestSuite", "NUnit.Framework.Assertion." // don't filter AssertionFailure }; for (int i = 0; i < patterns.Length; i++) { if (line.IndexOf(patterns[i]) > 0) return true; } return false; } /// <summary> /// Filters stack frames from internal NUnit classes /// </summary> public static string FilterStack(string stack) { string pref = GetPreference("filterstack"); if (((pref != null) && !GetPreference("filterstack").Equals("true")) || fgFilterStack == false) return stack; StringWriter sw = new StringWriter(); StringReader sr = new StringReader(stack); try { string line; while ((line = sr.ReadLine()) != null) { if (!FilterLine(line)) sw.WriteLine(line); } } catch (Exception) { return stack; // return the stack unfiltered } return sw.ToString(); } /// <summary> /// /// </summary> /// <param name="t"></param> /// <returns></returns> public static string GetFilteredTrace(Exception t) { return BaseTestRunner.FilterStack(t.StackTrace); } /// <summary> /// /// </summary> /// <param name="key"></param> /// <returns></returns> public static string GetPreference(string key) { return fPreferences.Get(key); } private static int GetPreference(String key, int dflt) { String value= GetPreference(key); int intValue= dflt; if (value != null) { try { intValue= int.Parse(value); } catch (FormatException) {} } return intValue; } private static FileStream GetPreferencesFile() { return new IsolatedStorageFileStream("NUnit.Prefs", FileMode.OpenOrCreate); } /// <summary> /// /// </summary> /// <returns></returns> public virtual ITestLoader GetLoader() { if (UseReloadingTestSuiteLoader()) return new UnloadingLoader(); return new StandardLoader(); } /// <summary> /// Returns the ITest corresponding to the given suite. This is /// a template method, subclasses override RunFailed(), ClearStatus(). /// </summary> public ITest GetTest(string suiteClassName) { ITest test = null; try { test = LoadSuiteClass(suiteClassName); } catch (TypeLoadException e) { RunFailed(e.Message); return null; } catch (Exception e) { RunFailed("Error: " + e.ToString()); return null; } //ClearStatus(); return test; } /// <summary> /// Returns the loaded Class for a suite name. /// </summary> protected ITest LoadSuiteClass(string suiteClassName) { return GetLoader().LoadTest(suiteClassName); } private static void ReadPreferences() { FileStream fs= null; try { fs= GetPreferencesFile(); fPreferences= new NameValueCollection(fPreferences); ReadPrefsFromFile(ref fPreferences, fs); } catch (IOException) { try { if (fs != null) fs.Close(); } catch (IOException) { } } } /// <summary> /// Real method reads name/value pairs, populates, or maybe just /// deserializes... /// </summary> /// <param name="prefs"></param> /// <param name="fs"></param> private static void ReadPrefsFromFile(ref NameValueCollection prefs, FileStream fs) { } /// <summary> /// Override to define how to handle a failed loading of a test suite. /// </summary> protected abstract void RunFailed(string message); /// <summary> /// Truncates a String to the maximum length. /// </summary> /// <param name="message"></param> /// <returns></returns> public static string Truncate(string message) { if (fgMaxMessageLength != -1 && message.Length > fgMaxMessageLength) message = message.Substring(0, fgMaxMessageLength)+"..."; return message; } /// <summary> /// /// </summary> /// <param name="test"></param> public abstract void StartTest(ITest test); /// <summary> /// /// </summary> /// <param name="args"></param> /// <param name="wait"></param> /// <returns></returns> protected string ProcessArguments(string[] args, ref bool wait) { string suiteName=""; wait = false; foreach (string arg in args) { if (arg.Equals("/noloading")) SetLoading(false); else if (arg.Equals("/nofilterstack")) fgFilterStack = false; else if (arg.Equals("/wait")) wait = true; else if (arg.Equals("/c")) suiteName= ExtractClassName(arg); else if (arg.Equals("/v")) { Console.Error.WriteLine("NUnit "+NUnit.Runner.Version.id() + " by Philip Craig"); Console.Error.WriteLine("ported from JUnit 3.6 by Kent Beck" + " and Erich Gamma"); } else suiteName = arg; } return suiteName; } /// <summary> /// Sets the loading behaviour of the test runner /// </summary> protected void SetLoading(bool enable) { fLoading = enable; } /// <summary> /// /// </summary> /// <returns></returns> protected bool UseReloadingTestSuiteLoader() { return bool.TrueString.Equals( GetPreference("loading")) && fLoading; } } } --- NEW FILE --- namespace NUnit.Runner { using System; using System.Collections; using System.Collections.Specialized; using System.IO; /// <summary> /// A TestCollector that consults the /// class path. It considers all classes on the class path /// excluding classes in JARs. It leaves it up to subclasses /// to decide whether a class is a runnable Test. /// <see cref="ITestCollector"/> /// </summary> [Obsolete("Use StandardLoader or UnloadingLoader")] public abstract class ClassPathTestCollector : ITestCollector { /// <summary> /// /// </summary> public ClassPathTestCollector() {} /// <summary> /// /// </summary> /// <returns></returns> public string[] CollectTestsClassNames() { string classPath = Environment.GetEnvironmentVariable("Path"); char separator= Path.PathSeparator; ArrayList result = new ArrayList(); CollectFilesInRoots(classPath.Split(separator), result); string[] retVal = new string[result.Count]; result.CopyTo(retVal); return retVal; } /// <summary> /// /// </summary> /// <param name="classFileName"></param> /// <returns></returns> protected string ClassNameFromFile(string classFileName) { return classFileName; } private void CollectFilesInRoots(string[] roots, IList result) { foreach (string directory in roots) { DirectoryInfo dirInfo=new DirectoryInfo(directory); if (dirInfo.Exists) { string[] files=Directory.GetFiles(dirInfo.FullName); foreach (string file in files) { if (IsTestClass(file)) { string className=ClassNameFromFile(file); result.Add(className); } } } } } /// <summary> /// /// </summary> /// <param name="classFileName"></param> /// <returns></returns> protected virtual bool IsTestClass(string classFileName) { return ( classFileName.EndsWith(".dll") || classFileName.EndsWith(".exe")) && classFileName.IndexOf("Test") > 0; } } } --- NEW FILE --- namespace NUnit.Extensions { using System; using NUnit.Framework; /// <summary>A TestCase that expects an Exception of class fExpected /// to be thrown.</summary> /// <remarks> The other way to check that an expected exception is thrown is: /// <code> /// try { /// ShouldThrow(); /// }catch (SpecialException) { /// return; /// } /// Assertion.Fail("Expected SpecialException"); /// </code> /// /// To use ExceptionTestCase, create a TestCase like: /// <code> /// new ExceptionTestCase("TestShouldThrow", typeof(SpecialException)); /// </code></remarks> public class ExceptionTestCase: TestCase { private readonly Type fExpected; /// <summary> /// /// </summary> /// <param name="name"></param> /// <param name="exception"></param> public ExceptionTestCase(string name, Type exception) : base(name) { fExpected= exception; } /// <summary>Execute the test method expecting that an Exception of /// class fExpected or one of its subclasses will be thrown.</summary> protected override void RunTest() { try { base.RunTest(); } catch (Exception e) { if (fExpected.IsAssignableFrom(e.InnerException.GetType())) return; else throw e.InnerException; } Assertion.Fail("Expected exception " + fExpected); } } } --- NEW FILE --- namespace NUnit.Framework { using System; /// <summary> /// The given exception should be thrown by the annotated method. /// </summary> /// <remarks> /// To use this attribute, attach it to a method in a /// <see cref="TestCase"/> subclass. /// <example>Here is an example: /// <code> /// public class FooTest : TestCase { /// public ExpectExceptionTest(string name) : base(name) {} /// [ExpectException(typeof(ArgumentException))] /// [ExpectException(typeof(IndexOutOfRangeException))] /// public void TestBar() { /// throw new ArgumentException("bad argument"); /// } /// } /// </code> /// </example> /// </remarks> [AttributeUsage(AttributeTargets.Method, AllowMultiple=true)] public class ExpectExceptionAttribute : Attribute { private Type expected; /// <summary> /// /// </summary> /// <param name="exceptionExpected"></param> public ExpectExceptionAttribute(Type exceptionExpected) { this.expected = exceptionExpected; } /// <summary> /// /// </summary> /// <returns></returns> public override string ToString() { return expected.ToString(); } /// <summary> /// /// </summary> public Type ExceptionExpected { get { return expected; } } } } --- NEW FILE --- namespace NUnit.Runner { using System; using NUnit.Framework; /// <summary> /// A view to show details about a failure /// </summary> public interface IFailureDetailView { /// <summary> /// Clears the view /// </summary> void Clear(); /// <summary> /// Shows details of a TestFailure /// </summary> void ShowFailure(TestFailure failure); } } --- NEW FILE --- namespace NUnit.Framework { /// <summary> /// An <c>IProtectable</c> can be run and can throw an Exception. /// </summary> /// <seealso cref="TestResult"/> public interface IProtectable { /// <summary>Run the the following method protected.</summary> void Protect(); } } --- NEW FILE --- namespace NUnit.Framework { /// <summary>An <c>ITest</c> can be run and collect its results.</summary> /// <seealso cref="TestResult"/> public interface ITest { /// <summary> /// Counts the number of test cases that will be run by this test. /// </summary> int CountTestCases { get; } /// <summary> /// Runs a test and collects its result in a /// <see cref="TestResult"/> instance. /// </summary> /// <param name="result"></param> void Run(TestResult result); } } --- NEW FILE --- namespace NUnit.Runner { using System; /// <summary> /// Collects Test classes to be presented by the TestSelector. /// <see foocref="TestSelector"/> /// </summary> public interface ITestCollector { /// <summary> /// Returns an array of FullNames for classes that are tests. /// </summary> string[] CollectTestsClassNames(); } } --- NEW FILE --- namespace NUnit.Framework { using System; /// <summary>A Listener for test progress</summary> public interface ITestListener { /// <summary>An error occurred.</summary> void AddError(ITest test, Exception ex); /// <summary>A failure occurred.</summary> void AddFailure(ITest test, AssertionFailedError ex); /// <summary>A test ended.</summary> void EndTest(ITest test); /// <summary>A test started.</summary> void StartTest(ITest test); } #if false public class TestEventArgs : System.EventArgs { private readonly ITest fTest; public TestEventArgs(ITest test) : base() { fTest = test; } public ITest Test { get { return fTest;} } } public class TestErrorArgs : TestEventArgs { private readonly Exception fThrownException; public TestErrorArgs(ITest test, Exception thrownException) : base(test) { fThrownException = thrownException; } public TestErrorArgs(TestFailure error) : this(error.FailedTest,error.ThrownException){} public Exception ThrownException { get { return fThrownException;} } } public delegate void TestErrorHandler(TestFailure failure); public delegate void TestEventHandler(ITest test); public interface ITestEvents { event TestErrorHandler TestErred; event TestErrorHandler TestFailed; event TestEventHandler TestStarted; event TestEventHandler TestEnded; event TestEventHandler RunStarted; event TestEventHandler RunEnded; } #endif } --- NEW FILE --- namespace NUnit.Runner { using System; using NUnit.Framework; using System.Runtime.Serialization; /// <summary> /// Basic contract governing loading of tests /// </summary> public interface ITestLoader { /// <summary> /// Loads an instance of the test class specified by the name. /// Loadable in most cases will be an assembly qualified name. /// /// Other loaders could dynamically construct a test case from /// an XML file or a database record. /// </summary> ITest LoadTest(string loadableName); /// <summary> /// Return the name used by the loader to load an instance /// of the supplied test /// </summary> /// <param name="test"></param> /// <returns></returns> string GetLoadName(ITest test); } /// <summary> /// Error thrown during assembly and class loading problems /// </summary> [Serializable] public class LoaderException : NUnitException { /// <summary> /// Serialization Constructor /// </summary> protected LoaderException(SerializationInfo info, StreamingContext context) : base(info,context){} /// <summary> /// Standard constructor /// </summary> /// <param name="message">The error message that explains /// the reason for the exception</param> /// <param name="innerException">The exception that caused the /// current exception</param> public LoaderException(string message, Exception innerException) : base(message, innerException) {} /// <summary> /// Standard constructor /// </summary> /// <param name="message">The error message that explains /// the reason for the exception</param> public LoaderException(string message) : base(message) {} } } --- NEW FILE --- namespace NUnit.Runner { using System; /// <summary> /// An interface to define how a test suite should be loaded. /// </summary> [Obsolete("Use ILoader")] public interface ITestSuiteLoader { /// <summary> /// /// </summary> Type Load(string suiteClassName); //Type Reload(Type aType); } } --- NEW FILE --- namespace NUnit.Runner { using System; using System.Reflection; using NUnit.Framework; /// <summary> /// An implementation of a TestCollector that loads /// all classes on the class path and tests whether /// it is assignable from ITest or provides a static Suite property. /// <see cref="ITestCollector"/> /// </summary> [Obsolete("Use StandardLoader or UnloadingLoader")] public class LoadingClassPathTestCollector: ClassPathTestCollector { TestCaseClassLoader fLoader; /// <summary> /// /// </summary> public LoadingClassPathTestCollector() { fLoader= new TestCaseClassLoader(); } /// <summary> /// /// </summary> /// <param name="classFileName"></param> /// <returns></returns> protected override bool IsTestClass(string classFileName) { try { if (classFileName.EndsWith(".dll") || classFileName.EndsWith(".exe")) { Type testClass= ClassFromFile(classFileName); return (testClass != null); //HACK: && TestCase.IsTest(testClass); } } catch (TypeLoadException) { } return false; } private Type ClassFromFile(string classFileName) { string className = base.ClassNameFromFile(classFileName); if (!fLoader.IsExcluded(className)) return fLoader.LoadClass(className, false); return null; } } } --- NEW FILE --- <VisualStudioProject> <CSHARP ProjectType = "Local" ProductVersion = "7.0.9466" SchemaVersion = "1.0" > <Build> <Settings ApplicationIcon = "" AssemblyKeyContainerName = "" AssemblyName = "NUnitCore" AssemblyOriginatorKeyFile = "" DefaultClientScript = "JScript" DefaultHTMLPageLayout = "Flow" DefaultTargetSchema = "IE32Nav30" DelaySign = "false" OutputType = "Library" RootNamespace = "NUnitCore" StartupObject = "" > <Config Name = "Debug" AllowUnsafeBlocks = "false" BaseAddress = "0" CheckForOverflowUnderflow = "false" ConfigurationOverrideFile = "" DefineConstants = "DEBUG;TRACE" DocumentationFile = "NUnitCore.xml" DebugSymbols = "true" FileAlignment = "4096" IncrementalBuild = "false" Optimize = "false" OutputPath = "bin\Debug\" RegisterForComInterop = "false" RemoveIntegerChecks = "false" TreatWarningsAsErrors = "false" WarningLevel = "4" /> <Config Name = "Release" AllowUnsafeBlocks = "false" BaseAddress = "0" CheckForOverflowUnderflow = "false" ConfigurationOverrideFile = "" DefineConstants = "TRACE" DocumentationFile = "" DebugSymbols = "false" FileAlignment = "4096" IncrementalBuild = "false" Optimize = "true" OutputPath = "bin\Release\" RegisterForComInterop = "false" RemoveIntegerChecks = "false" TreatWarningsAsErrors = "false" WarningLevel = "4" /> </Settings> <References> <Reference Name = "System" AssemblyName = "System" /> <Reference Name = "SYSTEM.WINDOWS.FORMS" AssemblyName = "System.Windows.Forms" /> <Reference Name = "System.Data" AssemblyName = "System.Data" /> <Reference Name = "System.XML" AssemblyName = "System.Xml" /> </References> </Build> <Files> <Include> <File RelPath = "ActiveTestSuite.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "AssemblyInfo.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "AssemblyTestCollector.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "Assertion.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "AssertionFailedError.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "BaseTestRunner.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "ClassPathTestCollector.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "ExceptionTestCase.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "ExpectExceptionAttribute.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "IFailureDetailView.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "IProtectable.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "ITest.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "ITestCollector.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "ITestListener.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "ITestLoader.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "ITestSuiteLoader.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "LoadingTestCollector.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "NUnitException.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "ReflectionUtils.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "ReloadingTestSuiteLoader.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "RepeatedTest.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "StandardLoader.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "StandardTestSuiteLoader.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "TestCase.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "TestCaseClassLoader.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "TestDecorator.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "TestFailure.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "TestResult.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "TestSetup.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "TestSuite.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "Version.cs" SubType = "Code" BuildAction = "Compile" /> </Include> </Files> </CSHARP> </VisualStudioProject> --- NEW FILE --- namespace NUnit.Framework { using System; using System.Diagnostics; using System.Runtime.Serialization; /// <summary> /// Thrown when an assertion failed. Here to preserve the inner /// exception and hence its stack trace. /// </summary> [Serializable] public class NUnitException : ApplicationException { /// <summary> /// Serialization Constructor /// </summary> protected NUnitException(SerializationInfo info, StreamingContext context) : base(info,context){} /// <summary> /// Standard constructor /// </summary> /// <param name="message">The error message that explains /// the reason for the exception</param> public NUnitException(string message) : base (message){} /// <summary> /// Standard constructor /// </summary> /// <param name="message">The error message that explains /// the reason for the exception</param> /// <param name="inner">The exception that caused the /// current exception</param> public NUnitException(string message, Exception inner) : base(message, inner) {} /// <summary> /// Indicates that this exception wraps an AssertionFailedError /// exception /// </summary> public virtual bool IsAssertionFailure { get { AssertionFailedError inner = this.InnerException as AssertionFailedError; if(inner != null) return true; return false; } } } } --- NEW FILE --- namespace NUnit.Runner { using System; using System.Collections; using System.Collections.Specialized; using System.IO; using System.Reflection; using NUnit.Framework; /// <summary> /// /// </summary> [Obsolete("Use Standar Loader")] public class ReflectionUtils { /// <summary> /// /// </summary> /// <param name="testClass"></param> /// <returns></returns> [Obsolete("Use Standar Loader")] public static bool HasTests(Type testClass) { PropertyInfo suiteProperty= null; suiteProperty = testClass.GetProperty("Suite", new Type[0]); if (suiteProperty == null ) { // try to extract a test suite automatically TestSuite dummy = new TestSuite(testClass, true); return (dummy.CountTestCases > 0); } ITest test= null; try { // static property test= (ITest)suiteProperty.GetValue(null, new Type[0]); if (test == null) return false; } catch(Exception) { return false; } return true; } /// <summary> /// /// </summary> /// <param name="assemblyName"></param> /// <returns></returns> [Obsolete("Use Standar Loader")] public static StringCollection GetAssemblyClasses(string assemblyName) { StringCollection classNames = new StringCollection (); try { Assembly testAssembly = Assembly.LoadFrom(assemblyName); foreach(Type testType in testAssembly.GetExportedTypes()) { if(testType.IsClass && HasTests(testType)) { classNames.Add(testType.FullName); } } } catch(ReflectionTypeLoadException rcle) { Type[] loadedTypes = rcle.Types; Exception[] exceptions = rcle.LoaderExceptions; int exceptionCount = 0; for ( int i =0; i < loadedTypes.Length; i++ ) { Console.Error.WriteLine("Unable to load a type because {0}", exceptions[exceptionCount] ); exceptionCount++; } } catch(FileNotFoundException fnfe) { Console.Error.WriteLine(fnfe.Message); } catch(Exception e) { Console.Error.WriteLine("Error reading file {0}: {1}", assemblyName, e.Message); } return classNames; } } } --- NEW FILE --- namespace NUnit.Runner { using System; /// <summary>A TestSuite loader that can reload classes.</summary> [Obsolete("Use StandardLoader or UnloadingLoader")] public class ReloadingTestSuiteLoader: ITestSuiteLoader { /// <summary> /// /// </summary> /// <param name="suiteClassName"></param> /// <returns></returns> public Type Load(string suiteClassName) { // TestCaseClassLoader loader= new TestCaseClassLoader(); // return loader.LoadClass(suiteClassName, true); return Type.GetType(suiteClassName, true); } /// <summary> /// /// </summary> /// <param name="aClass"></param> /// <returns></returns> public Type Reload(Type aClass) { // TestCaseClassLoader loader= new TestCaseClassLoader(); // return loader.LoadClass(aClass.ToString(), true); return aClass; } } } --- NEW FILE --- namespace NUnit.Extensions { using System; using NUnit.Framework; /// <summary>A Decorator that runs a test repeatedly.</summary> public class RepeatedTest: TestDecorator { private readonly int fTimesRepeat; /// <summary> /// /// </summary> /// <param name="test"></param> /// <param name="repeat"></param> public RepeatedTest(ITest test, int repeat) : base(test) { if (repeat < 0) { throw new ArgumentOutOfRangeException("repeat", "Repetition count must be > 0"); } fTimesRepeat= repeat; } /// <summary> /// /// </summary> public override int CountTestCases { get { return base.CountTestCases * fTimesRepeat; } } /// <summary> /// /// </summary> /// <param name="result"></param> public override void Run(TestResult result) { for (int i= 0; i < fTimesRepeat; i++) { if (result.ShouldStop) break; base.Run(result); } } /// <summary> /// /// </summary> /// <returns></returns> public override string ToString() { return base.ToString()+"(repeated)"; } } } --- NEW FILE --- namespace NUnit.Runner { using System; /// <summary> /// An implementation of a TestCollector that considers /// a class to be a test class when it contains the /// pattern "Test" in its name /// <see cref="ITestCollector"/> /// </summary> public class SimpleTestCollector: ClassPathTestCollector { /// <summary> /// /// </summary> public SimpleTestCollector() { } /// <summary> /// /// </summary> /// <param name="classFileName"></param> /// <returns></returns> protected override bool IsTestClass(string classFileName) { return (classFileName.EndsWith(".dll") || classFileName.EndsWith(".exe")) && classFileName.IndexOf("Test") > 0; } } } --- NEW FILE --- namespace NUnit.Runner { using System; using System.Collections; using System.Reflection; using NUnit.Framework; /// <summary> /// Same as StandardLoader. /// TODO: Clean up "Unloading" concepts in framework /// </summary> public class UnloadingLoader : StandardLoader{} /// <summary> /// TestLoader that /// </summary> public class StandardLoader : ITestLoader { #region Overidable loader implementatioons /// <summary> /// Attempts by all means possible to return a test for the given type. /// Check in the following order: /// 1. For a static Suite property, that implments ITest. /// 2. Tries to dynamically create a suite for the type. /// </summary> /// <param name="testClass"></param> /// <returns></returns> protected virtual ITest CoerceTestFrom(Type testClass) { try { ITest test = GetStaticSuiteProperty(testClass); if (test == null ) { // try to extract a test suite automatically test = new TestSuite(testClass); } return test; } catch (Exception e) { throw new NUnitException("Error building test for class: " + testClass.FullName,e); } } /// <summary> /// Searches for the type specified by the testClassName in the /// specified assembly, and if found, attempts to coerce a test /// from the type. /// </summary> /// <param name="testClassName"></param> /// <param name="assemblyFileName"></param> /// <returns></returns> public virtual ITest LoadTest(string testClassName, string assemblyFileName) { try { return this.CoerceTestFrom( getAssembly(assemblyFileName).GetType(testClassName)); } catch (Exception e) { throw new LoaderException("Error loading test class: " + testClassName + "," + assemblyFileName, e); } } /// <summary> /// Determines if a Type is a test. /// </summary> /// <param name="typeToCheck"></param> protected virtual bool IsTestClass(Type typeToCheck) { if(typeToCheck!=null) { if( typeToCheck.IsClass && typeToCheck.IsPublic && !typeToCheck.IsAbstract) { try { if( (typeof(ITest).IsAssignableFrom(typeToCheck) // Has public single string constructor && (typeToCheck.GetConstructor(new Type[]{typeof(string)})!=null)) || GetStaticSuiteProperty(typeToCheck)!= null) { return true; } } catch(System.Security.SecurityException) { // eat security exceptions, since shouldn't // have errors on classes we can't access } } return false; } else { throw new ArgumentNullException("typeToCheck"); } } /// <summary> /// Uses reflection to obtain the suite property for the Type /// </summary> /// <param name="testClass"></param> /// <returns>The Suite property of the Type, or null if the property /// does not exist</returns> protected virtual TestSuite GetStaticSuiteProperty(Type testClass) { if(testClass!=null) { TestSuite test = null; PropertyInfo suiteProperty = testClass.GetProperty("Suite" ,BindingFlags.Static|BindingFlags.Public ,Type.DefaultBinder // unknown ,typeof(ITest) // Itest return type ,Type.EmptyTypes // no parameters ,new ParameterModifier[0] // unknown ); if (suiteProperty != null ) { test = (TestSuite)suiteProperty.GetValue(null, new Object[0]); } return test; } else { throw new ArgumentNullException ("testClass"); } } private Assembly getAssembly(string assemblyFileName) { try { return Assembly.LoadFrom(assemblyFileName); } catch(ArgumentNullException) { throw new ArgumentNullException("assemblyFileName"); } } #endregion #region ILoader Methods /// <summary> /// Implements ILoader.GetLoadName(). /// </summary> /// <param name="test"></param> /// <returns></returns> public virtual string GetLoadName(ITest test) { Type testType = test.GetType(); if(testType.Equals(typeof(TestSuite))) { string tname = test.ToString(); testType = Type.GetType(tname); } if(testType != null) return testType.FullName+","+testType.Assembly.CodeBase; else return string.Empty; } /// <summary> /// Implements ILoader.LoadTest(). /// Loads an instance of the test class specified by the /// AssemblyQualifiedName. The assembly qualified name /// contains the Full Clas Name, followed by the CodeBase /// (file or url) of the assembly. If the class is found, /// the loader will attempt to return a TestSuite for the /// class. Trying first the static Suite property, followed /// by trying to dynamically create a suite for the class. /// </summary> /// <param name="assemblyQualifiedName">The qualified name /// for the class taking the form /// "Namespace.ClassName,AssemblyFileName" without the quotes. /// Assembly file name can be a fulied qualified path name, or /// a URL.</param> /// <returns></returns> public virtual ITest LoadTest(string assemblyQualifiedName) { if(assemblyQualifiedName==null) throw new ArgumentNullException("assemblyQualifiedName"); string[] nameParts = assemblyQualifiedName.Split(new Char[]{','}); if(nameParts.Length >= 1) { return this.LoadTest(nameParts[0].Trim(),nameParts[1].Trim()); } else { throw new ArgumentException("Expected an Assembly Qualified Class" + " Name, containing the file name of the assembly", "assemblyQualifiedName"); } } #endregion /// <summary> /// Examies all types in the specified assembly and returns a list of those /// types that can be coerced into tests. /// </summary> /// <param name="assemblyFileName"></param> /// <returns></returns> public virtual Type[] GetTestTypes(string assemblyFileName) { Assembly assembly = getAssembly(assemblyFileName); ArrayList Tests = new ArrayList(assembly.GetExportedTypes().Length); foreach(Type typeToCheck in assembly.GetExportedTypes()) { if(this.IsTestClass(typeToCheck)) { Tests.Add(typeToCheck); } } Type[] ret = new Type[Tests.Count]; Tests.CopyTo(ret); return ret; } } } --- NEW FILE --- namespace NUnit.Runner { using System; using System.Reflection; using System.IO; using System.Security; /// <summary> /// The standard test suite loader. It can only load the same /// class once. /// </summary> [Obsolete("Use StandardLoader or UnloadingLoader")] public class StandardTestSuiteLoader: ITestSuiteLoader { /// <summary> /// Loads /// </summary> /// <param name="testClassName"></param> /// <returns></returns> public Type Load(string testClassName) { Type testClass; string[] classSpec=testClassName.Split(','); if (classSpec.Length > 1) { FileInfo dll=new FileInfo(classSpec[1]); if (!dll.Exists) throw new FileNotFoundException("File " + dll.FullName + " not found", dll.FullName); Assembly a = Assembly.LoadFrom(dll.FullName); testClass=a.GetType(classSpec[0], true); } else testClass = Type.GetType(testClassName, true); return testClass; } /// <summary> /// /// </summary> /// <param name="aClass"></param> /// <returns></returns> public Type Reload(Type aClass) { return aClass; } } } --- NEW FILE --- namespace NUnit.Framework { using System; using System.Reflection; /// <summary>A test case defines the fixture to run multiple Tests.</summary> /// <remarks> To define a test case /// <list type="number"> /// <item><description>implement a subclass of TestCase</description></item> /// <item><description>define instance variables that store the state /// of the fixture</description></item> /// <item><description>initialize the fixture state by overriding /// <c>SetUp</c></description></item> /// <item><description>clean-up after a test by overriding /// <c>TearDown</c></description></item> /// </list> /// Each test runs in its own fixture so there can be no side effects /// among test runs. /// <example>Here is an example: /// <code> /// public class MathTest: TestCase { /// protected double fValue1; /// protected double fValue2; /// /// public MathTest(string name) : base(name) {} /// /// protected override void SetUp() { /// fValue1= 2.0; /// fValue2= 3.0; /// } /// }</code> /// </example> /// /// For each test implement a method which interacts with the fixture. /// Verify the expected results with Assertions specified by calling /// <c>Assert</c> with a bool. /// <code> /// protected void TestAdd() { /// double result= fValue1 + fValue2; /// Assert(result == 5.0); /// } /// </code> /// Once the methods are defined you can run them. The framework supports /// both a static type safe and more dynamic way to run a test. /// In the static way you override the runTest method and define the method /// to be invoked. /// <code> /// protected class AddMathTest: TestCase { /// public void AddMathTest(string name) : base(name) {} /// protected override void RunTest() { TestAdd(); } /// } /// /// test test= new AddMathTest("Add"); /// test.Run(); /// </code> /// The dynamic way uses reflection to implement <c>RunTest</c>. It /// dynamically finds and invokes a method. In this case the name of the /// test case has to correspond to the test method to be run. /// <code> /// test= new MathTest("TestAdd"); /// test.Run(); /// </code> /// The Tests to be run can be collected into a <see cref="TestSuite"/>. /// NUnit provides different test runners which can run a test suite /// and collect the results. /// A test runner either expects a static property <c>Suite</c> as the entry /// point to get a test to run or it will extract the suite automatically. /// <code> /// public static ITest Suite { /// get { /// suite.AddTest(new MathTest("TestAdd")); /// suite.AddTest(new MathTest("TestDivideByZero")); /// return suite; /// } /// } /// </code></remarks> /// <seealso cref="TestResult"/> /// <seealso cref="TestSuite"/> public abstract class TestCase: Assertion, ITest { #region Instance Variables /// <summary>the name of the test case.</summary> private readonly string fName; #endregion #region Constructors /// <summary>Constructs a test case with no name.</summary> public TestCase() : this(String.Empty){} /// <summary>Constructs a test case with the given name.</summary> public TestCase(string testName) { this.fName = testName; } #endregion #region Properties /// <value>Counts the number of test cases executed by /// Run(TestResult result).</value> public int CountTestCases { get { return 1; } } /// <value>The name of the test case.</value> public string Name { get { return this.fName; } } #endregion #region Utility Methods /// <summary>Creates a default <see cref="TestResult"/> object.</summary> protected TestResult CreateResult() { return new TestResul... [truncated message content] |