adapdev-commits Mailing List for Adapdev.NET (Page 26)
Status: Beta
Brought to you by:
intesar66
You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
(26) |
Apr
(59) |
May
(37) |
Jun
(53) |
Jul
(13) |
Aug
(7) |
Sep
(5) |
Oct
(74) |
Nov
(404) |
Dec
(14) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(10) |
Feb
(26) |
Mar
(64) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Trevor L. <tre...@us...> - 2005-06-06 02:18:12
|
Update of /cvsroot/adapdev/Adapdev/src/Adapdev.Data/Sql In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4265/src/Adapdev.Data/Sql Modified Files: OracleSelectQuery.cs Log Message: Removed duplicate GetLimits() statement Index: OracleSelectQuery.cs =================================================================== RCS file: /cvsroot/adapdev/Adapdev/src/Adapdev.Data/Sql/OracleSelectQuery.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** OracleSelectQuery.cs 3 Jun 2005 00:28:23 -0000 1.3 --- OracleSelectQuery.cs 6 Jun 2005 02:18:02 -0000 1.4 *************** *** 22,26 **** public override string GetText() { ! string sql = "SELECT " + this.GetLimit() + this.GetColumns() + " FROM " + this._table + this._join + this.GetCriteria(); if(this.maxRecords > 0) { --- 22,26 ---- public override string GetText() { ! string sql = "SELECT " + this.GetColumns() + " FROM " + this._table + this._join + this.GetCriteria(); if(this.maxRecords > 0) { |
Update of /cvsroot/adapdev/Adapdev/src/Adapdev.UnitTest.Core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31410/src/Adapdev.UnitTest.Core Modified Files: AbstractTest.cs AbstractTestResult.cs TestAssembly.cs TestFixture.cs TestRunner.cs TestState.cs TestSuiteBuilder.cs Log Message: Fixed several bugs with SmartTreeView Fixed bugs with TestRunner Index: TestSuiteBuilder.cs =================================================================== RCS file: /cvsroot/adapdev/Adapdev/src/Adapdev.UnitTest.Core/TestSuiteBuilder.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TestSuiteBuilder.cs 27 Apr 2005 04:36:02 -0000 1.4 --- TestSuiteBuilder.cs 5 Jun 2005 08:50:32 -0000 1.5 *************** *** 104,112 **** ta.AssemblyName = fi.Name; ta.AssemblyFullName = assembly.FullName; ta.Name = assembly.GetName().Name; ta.Path = assembly.Location; ta.Location = fi.DirectoryName; ta.OriginalPath = assemblyName; - ta.Id = id++; // Build the TestFixtures --- 104,112 ---- ta.AssemblyName = fi.Name; ta.AssemblyFullName = assembly.FullName; + ta.FullName = assembly.GetName().Name; ta.Name = assembly.GetName().Name; ta.Path = assembly.Location; ta.Location = fi.DirectoryName; ta.OriginalPath = assemblyName; // Build the TestFixtures *************** *** 144,148 **** tf.Namespace = t.Namespace; tf.FullName = t.FullName; - tf.Id = id++; this.ProcessCommonAttributes(t, tf); --- 144,147 ---- *************** *** 203,207 **** t.Name = m.Name; t.FullName = tf.FullName + "." + m.Name; - t.Id = id++; this.ProcessTestAttribute(m, t); this.ProcessCommonAttributes(m, t); --- 202,205 ---- Index: TestFixture.cs =================================================================== RCS file: /cvsroot/adapdev/Adapdev/src/Adapdev.UnitTest.Core/TestFixture.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TestFixture.cs 27 Apr 2005 04:36:02 -0000 1.2 --- TestFixture.cs 5 Jun 2005 08:50:32 -0000 1.3 *************** *** 163,167 **** foreach (Test t in this.GetTests()) { ! if(t.ShouldRun) { count += t.GetTestCount(); --- 163,167 ---- foreach (Test t in this.GetTests()) { ! if(t.ShouldRun && !t.Ignore) { count += t.GetTestCount(); Index: AbstractTest.cs =================================================================== RCS file: /cvsroot/adapdev/Adapdev/src/Adapdev.UnitTest.Core/AbstractTest.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** AbstractTest.cs 14 Apr 2005 03:32:05 -0000 1.2 --- AbstractTest.cs 5 Jun 2005 08:50:31 -0000 1.3 *************** *** 48,53 **** protected string _ignoreReason = ""; protected int _sequence = 0; - protected bool _threads = false; protected int _id = 0; protected bool _repeat = false; protected int _repeatCount = 1; --- 48,53 ---- protected string _ignoreReason = ""; protected int _sequence = 0; protected int _id = 0; + protected bool _threads = false; protected bool _repeat = false; protected int _repeatCount = 1; *************** *** 59,65 **** --- 59,67 ---- protected AbstractTestResult _result = null; protected string _fullName = String.Empty; + private static int _globalid = 0; public AbstractTest() { + this._id = System.Threading.Interlocked.Increment(ref _globalid); } Index: TestAssembly.cs =================================================================== RCS file: /cvsroot/adapdev/Adapdev/src/Adapdev.UnitTest.Core/TestAssembly.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TestAssembly.cs 27 Apr 2005 04:36:02 -0000 1.2 --- TestAssembly.cs 5 Jun 2005 08:50:32 -0000 1.3 *************** *** 128,132 **** foreach (TestFixture t in this.GetTestFixtures()) { ! if(t.ShouldRun) { count += t.GetTestCount(); --- 128,132 ---- foreach (TestFixture t in this.GetTestFixtures()) { ! if(t.ShouldRun && !t.Ignore) { count += t.GetTestCount(); Index: TestRunner.cs =================================================================== RCS file: /cvsroot/adapdev/Adapdev/src/Adapdev.UnitTest.Core/TestRunner.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TestRunner.cs 27 Apr 2005 04:52:33 -0000 1.4 --- TestRunner.cs 5 Jun 2005 08:50:32 -0000 1.5 *************** *** 292,295 **** --- 292,300 ---- } } + else + { + ti.Result = "Expected Exception: " + test.ExpectedExceptionType + " was thrown. Message: " + e.InnerException.Message; + ti.State = TestState.Pass; + } } else *************** *** 307,311 **** { ti.Result = e.InnerException.Message; ! ti.State = TestState.Ignore; ti.ExceptionType = e.InnerException.GetType().FullName; ti.FullStackTrace = e.InnerException.StackTrace; --- 312,316 ---- { ti.Result = e.InnerException.Message; ! ti.State = TestState.ForcedIgnore; ti.ExceptionType = e.InnerException.GetType().FullName; ti.FullStackTrace = e.InnerException.StackTrace; Index: TestState.cs =================================================================== RCS file: /cvsroot/adapdev/Adapdev/src/Adapdev.UnitTest.Core/TestState.cs,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** TestState.cs 28 Feb 2005 01:32:22 -0000 1.1.1.1 --- TestState.cs 5 Jun 2005 08:50:32 -0000 1.2 *************** *** 49,53 **** Pass = 4, Ignore = 8, ! Fail = 16 } } \ No newline at end of file --- 49,54 ---- Pass = 4, Ignore = 8, ! Fail = 16, ! ForcedIgnore = 32 } } \ No newline at end of file Index: AbstractTestResult.cs =================================================================== RCS file: /cvsroot/adapdev/Adapdev/src/Adapdev.UnitTest.Core/AbstractTestResult.cs,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** AbstractTestResult.cs 28 Feb 2005 01:32:20 -0000 1.1.1.1 --- AbstractTestResult.cs 5 Jun 2005 08:50:32 -0000 1.2 *************** *** 91,99 **** this._state = TestState.Fail; } ! else if (this.State != TestState.Fail && ti.State != TestState.Ignore) { this._state = TestState.Pass; } ! else if (this.State != TestState.Fail && this.State != TestState.Pass && ti.State == TestState.Ignore) { this._state = TestState.Ignore; --- 91,99 ---- this._state = TestState.Fail; } ! else if (this.State != TestState.Fail && ti.State != TestState.Ignore && ti.State != TestState.ForcedIgnore) { this._state = TestState.Pass; } ! else if (this.State != TestState.Fail && this.State != TestState.Pass && (ti.State == TestState.Ignore || ti.State == TestState.ForcedIgnore)) { this._state = TestState.Ignore; |
From: Sean M. <int...@us...> - 2005-06-05 08:50:44
|
Update of /cvsroot/adapdev/Adapdev/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31410/src Modified Files: AdapdevFramework.sln AdapdevFramework.suo Log Message: Fixed several bugs with SmartTreeView Fixed bugs with TestRunner Index: AdapdevFramework.suo =================================================================== RCS file: /cvsroot/adapdev/Adapdev/src/AdapdevFramework.suo,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 Binary files /tmp/cvsYuFT0r and /tmp/cvsTCGCWm differ Index: AdapdevFramework.sln =================================================================== RCS file: /cvsroot/adapdev/Adapdev/src/AdapdevFramework.sln,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** AdapdevFramework.sln 26 May 2005 01:54:39 -0000 1.5 --- AdapdevFramework.sln 5 Jun 2005 08:50:33 -0000 1.6 *************** *** 64,67 **** --- 64,75 ---- EndProjectSection EndProject + Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Adapdev.UnitTest.Tests", "Adapdev.UnitTest.Tests\Adapdev.UnitTest.Tests.csproj", "{7DC72EED-57C5-43A3-AB03-D456816A6F1A}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection + EndProject + Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Adapdev.UnitTest.Core.Tests", "Adapdev.UnitTest.Core.Tests\Adapdev.UnitTest.Core.Tests.csproj", "{D0F97D76-E7A6-4059-B902-F792626A29A8}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection + EndProject Global GlobalSection(SolutionConfiguration) = preSolution *************** *** 134,137 **** --- 142,153 ---- {250B6F4B-3256-4DEB-84B6-8C919058FDDC}.Release.ActiveCfg = Release|.NET {250B6F4B-3256-4DEB-84B6-8C919058FDDC}.Release.Build.0 = Release|.NET + {7DC72EED-57C5-43A3-AB03-D456816A6F1A}.Debug.ActiveCfg = Debug|.NET + {7DC72EED-57C5-43A3-AB03-D456816A6F1A}.Debug.Build.0 = Debug|.NET + {7DC72EED-57C5-43A3-AB03-D456816A6F1A}.Release.ActiveCfg = Release|.NET + {7DC72EED-57C5-43A3-AB03-D456816A6F1A}.Release.Build.0 = Release|.NET + {D0F97D76-E7A6-4059-B902-F792626A29A8}.Debug.ActiveCfg = Debug|.NET + {D0F97D76-E7A6-4059-B902-F792626A29A8}.Debug.Build.0 = Debug|.NET + {D0F97D76-E7A6-4059-B902-F792626A29A8}.Release.ActiveCfg = Release|.NET + {D0F97D76-E7A6-4059-B902-F792626A29A8}.Release.Build.0 = Release|.NET EndGlobalSection GlobalSection(SolutionItems) = postSolution |
From: Sean M. <int...@us...> - 2005-06-05 08:50:44
|
Update of /cvsroot/adapdev/Adapdev/src/Adapdev.UnitTest.Core.Tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31410/src/Adapdev.UnitTest.Core.Tests Added Files: Adapdev.UnitTest.Core.Tests.csproj AssemblyInfo.cs TestAssemblyTest.cs TestTest.cs Log Message: Fixed several bugs with SmartTreeView Fixed bugs with TestRunner --- NEW FILE: Adapdev.UnitTest.Core.Tests.csproj --- <VisualStudioProject> <CSHARP ProjectType = "Local" ProductVersion = "7.10.3077" SchemaVersion = "2.0" ProjectGuid = "{D0F97D76-E7A6-4059-B902-F792626A29A8}" > <Build> <Settings ApplicationIcon = "" AssemblyKeyContainerName = "" AssemblyName = "Adapdev.UnitTest.Core.Tests" AssemblyOriginatorKeyFile = "" DefaultClientScript = "JScript" DefaultHTMLPageLayout = "Grid" DefaultTargetSchema = "IE50" DelaySign = "false" OutputType = "Library" PreBuildEvent = "" PostBuildEvent = "" RootNamespace = "Adapdev.UnitTest.Core.Tests" RunPostBuildEvent = "OnBuildSuccess" StartupObject = "" > <Config Name = "Debug" AllowUnsafeBlocks = "false" BaseAddress = "285212672" CheckForOverflowUnderflow = "false" ConfigurationOverrideFile = "" DefineConstants = "DEBUG;TRACE" DocumentationFile = "" DebugSymbols = "true" FileAlignment = "4096" IncrementalBuild = "false" NoStdLib = "false" NoWarn = "" Optimize = "false" OutputPath = "bin\Debug\" RegisterForComInterop = "false" RemoveIntegerChecks = "false" TreatWarningsAsErrors = "false" WarningLevel = "4" /> <Config Name = "Release" AllowUnsafeBlocks = "false" BaseAddress = "285212672" CheckForOverflowUnderflow = "false" ConfigurationOverrideFile = "" DefineConstants = "TRACE" DocumentationFile = "" DebugSymbols = "false" FileAlignment = "4096" IncrementalBuild = "false" NoStdLib = "false" NoWarn = "" Optimize = "true" OutputPath = "bin\Release\" RegisterForComInterop = "false" RemoveIntegerChecks = "false" TreatWarningsAsErrors = "false" WarningLevel = "4" /> </Settings> <References> <Reference Name = "System" AssemblyName = "System" HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.dll" /> <Reference Name = "System.Data" AssemblyName = "System.Data" HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Data.dll" /> <Reference Name = "System.XML" AssemblyName = "System.XML" HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.XML.dll" /> <Reference Name = "nunit.framework" AssemblyName = "nunit.framework" HintPath = "C:\Program Files\NUnit 2.2\bin\nunit.framework.dll" AssemblyFolderKey = "hklm\dn\nunit.framework" /> <Reference Name = "Adapdev.UnitTest.Core" Project = "{B8592DE8-C10B-4ACB-A422-919C02C04B05}" Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}" /> </References> </Build> <Files> <Include> <File RelPath = "AssemblyInfo.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "TestAssemblyTest.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "TestTest.cs" SubType = "Code" BuildAction = "Compile" /> </Include> </Files> </CSHARP> </VisualStudioProject> --- NEW FILE: TestTest.cs --- using System; namespace Adapdev.UnitTest.Core.Tests { /// <summary> /// Summary description for TestTest. /// </summary> public class TestTest { public TestTest() { // // TODO: Add constructor logic here // } } } --- NEW FILE: AssemblyInfo.cs --- using System.Reflection; using System.Runtime.CompilerServices; // // 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("")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("")] [assembly: AssemblyCopyright("")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] // // Version information for an assembly consists of the following four values: // // Major Version // Minor Version // Build Number // Revision // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: [assembly: AssemblyVersion("1.0.*")] // // 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 is not signed. // (*) KeyName refers to a key that has been installed in the Crypto Service // Provider (CSP) on your machine. KeyFile refers to a file which contains // a key. // (*) If the KeyFile and the KeyName values 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 KeyFile is installed into the CSP and used. // (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. // When specifying the KeyFile, the location of the KeyFile should be // relative to the project output directory which is // %Project Directory%\obj\<configuration>. For example, if your KeyFile is // located in the project directory, you would specify the AssemblyKeyFile // attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] // (*) Delay Signing is an advanced option - see the Microsoft .NET Framework // documentation for more information on this. // [assembly: AssemblyDelaySign(false)] [assembly: AssemblyKeyFile("")] [assembly: AssemblyKeyName("")] --- NEW FILE: TestAssemblyTest.cs --- using System; using NUnit.Framework; using Adapdev.UnitTest.Core; namespace Adapdev.UnitTest.Core.Tests { /// <summary> /// Summary description for Class1. /// </summary> /// [TestFixture] public class TestAssemblyTest { [Test] public void GetCount() { // Create the assembly TestAssembly ta = new TestAssembly(); // Create the first TestFixture and // add two tests TestFixture tf1 = new TestFixture(); Test t1 = new Test(); Test t2 = new Test(); t2.RepeatCount = 5; Assert.AreEqual(1, t1.GetTestCount()); Assert.AreEqual(5, t2.GetTestCount()); tf1.AddTest(t1); tf1.AddTest(t2); Assert.AreEqual(6, tf1.GetTestCount()); // Create the second TestFixture and // add two tests TestFixture tf2 = new TestFixture(); Test t3 = new Test(); Test t4 = new Test(); t4.RepeatCount = 5; Assert.AreEqual(1, t3.GetTestCount()); Assert.AreEqual(5, t4.GetTestCount()); tf2.AddTest(t3); tf2.AddTest(t4); Assert.AreEqual(6, tf2.GetTestCount()); ta.AddTestFixture(tf1); ta.AddTestFixture(tf2); // Make sure the total number of tests is correct // Should be 1 + 5 + 1 + 5 = 12 Assert.AreEqual(12, ta.GetTestCount()); // Ignore the second test t2.Ignore = true; Assert.AreEqual(7, ta.GetTestCount()); // Unignore the second test t2.Ignore = false; // Ignore the first test fixture tf1.Ignore = true; Assert.AreEqual(6, ta.GetTestCount()); // Ignore the second test fixture tf2.Ignore = true; Assert.AreEqual(0, ta.GetTestCount()); } } } |
From: Sean M. <int...@us...> - 2005-06-05 08:50:43
|
Update of /cvsroot/adapdev/Adapdev/src/Adapdev.UnitTest.Tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31410/src/Adapdev.UnitTest.Tests Added Files: Adapdev.UnitTest.Tests.csproj AssemblyInfo.cs Class1.cs Log Message: Fixed several bugs with SmartTreeView Fixed bugs with TestRunner --- NEW FILE: Adapdev.UnitTest.Tests.csproj --- <VisualStudioProject> <CSHARP ProjectType = "Local" ProductVersion = "7.10.3077" SchemaVersion = "2.0" ProjectGuid = "{7DC72EED-57C5-43A3-AB03-D456816A6F1A}" > <Build> <Settings ApplicationIcon = "" AssemblyKeyContainerName = "" AssemblyName = "Adapdev.UnitTest.Tests" AssemblyOriginatorKeyFile = "" DefaultClientScript = "JScript" DefaultHTMLPageLayout = "Grid" DefaultTargetSchema = "IE50" DelaySign = "false" OutputType = "Library" PreBuildEvent = "" PostBuildEvent = "" RootNamespace = "Adapdev.UnitTest.Tests" RunPostBuildEvent = "OnBuildSuccess" StartupObject = "" > <Config Name = "Debug" AllowUnsafeBlocks = "false" BaseAddress = "285212672" CheckForOverflowUnderflow = "false" ConfigurationOverrideFile = "" DefineConstants = "DEBUG;TRACE" DocumentationFile = "" DebugSymbols = "true" FileAlignment = "4096" IncrementalBuild = "false" NoStdLib = "false" NoWarn = "" Optimize = "false" OutputPath = "bin\Debug\" RegisterForComInterop = "false" RemoveIntegerChecks = "false" TreatWarningsAsErrors = "false" WarningLevel = "4" /> <Config Name = "Release" AllowUnsafeBlocks = "false" BaseAddress = "285212672" CheckForOverflowUnderflow = "false" ConfigurationOverrideFile = "" DefineConstants = "TRACE" DocumentationFile = "" DebugSymbols = "false" FileAlignment = "4096" IncrementalBuild = "false" NoStdLib = "false" NoWarn = "" Optimize = "true" OutputPath = "bin\Release\" RegisterForComInterop = "false" RemoveIntegerChecks = "false" TreatWarningsAsErrors = "false" WarningLevel = "4" /> </Settings> <References> <Reference Name = "System" AssemblyName = "System" HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.dll" /> <Reference Name = "System.Data" AssemblyName = "System.Data" HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Data.dll" /> <Reference Name = "System.XML" AssemblyName = "System.XML" HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.XML.dll" /> </References> </Build> <Files> <Include> <File RelPath = "AssemblyInfo.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "Class1.cs" SubType = "Code" BuildAction = "Compile" /> </Include> </Files> </CSHARP> </VisualStudioProject> --- NEW FILE: Class1.cs --- using System; namespace Adapdev.UnitTest.Tests { /// <summary> /// Summary description for Class1. /// </summary> public class Class1 { public Class1() { // // TODO: Add constructor logic here // } } } --- NEW FILE: AssemblyInfo.cs --- using System.Reflection; using System.Runtime.CompilerServices; // // 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("")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("")] [assembly: AssemblyCopyright("")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] // // Version information for an assembly consists of the following four values: // // Major Version // Minor Version // Build Number // Revision // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: [assembly: AssemblyVersion("1.0.*")] // // 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 is not signed. // (*) KeyName refers to a key that has been installed in the Crypto Service // Provider (CSP) on your machine. KeyFile refers to a file which contains // a key. // (*) If the KeyFile and the KeyName values 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 KeyFile is installed into the CSP and used. // (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. // When specifying the KeyFile, the location of the KeyFile should be // relative to the project output directory which is // %Project Directory%\obj\<configuration>. For example, if your KeyFile is // located in the project directory, you would specify the AssemblyKeyFile // attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] // (*) Delay Signing is an advanced option - see the Microsoft .NET Framework // documentation for more information on this. // [assembly: AssemblyDelaySign(false)] [assembly: AssemblyKeyFile("")] [assembly: AssemblyKeyName("")] |
From: Sean M. <int...@us...> - 2005-06-05 08:50:43
|
Update of /cvsroot/adapdev/Adapdev/src/Adapdev.Windows.Forms In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31410/src/Adapdev.Windows.Forms Modified Files: SmartTreeView.cs Log Message: Fixed several bugs with SmartTreeView Fixed bugs with TestRunner Index: SmartTreeView.cs =================================================================== RCS file: /cvsroot/adapdev/Adapdev/src/Adapdev.Windows.Forms/SmartTreeView.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SmartTreeView.cs 3 Jun 2005 03:51:19 -0000 1.3 --- SmartTreeView.cs 5 Jun 2005 08:50:33 -0000 1.4 *************** *** 9,12 **** --- 9,14 ---- using System.Text; + public delegate void StateChangedEventHandler(TreeNode node, bool state); + public class SmartTreeView : System.Windows.Forms.TreeView { *************** *** 18,21 **** --- 20,25 ---- private Hashtable state = new Hashtable(); + public event StateChangedEventHandler StateChanged; + public SmartTreeView() { *************** *** 51,54 **** --- 55,60 ---- this.CheckBoxes = true; this.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(this.SmartTreeView_AfterCheck); + this.BeforeCheck += new System.Windows.Forms.TreeViewCancelEventHandler(this.SmartTreeView_BeforeCheck); + } #endregion *************** *** 92,95 **** --- 98,107 ---- treeNode = treeNode.Parent; } + + // Set the state for the topmost node + if(treeNode == this.Nodes[0]) + { + treeNode.Checked = node.Checked; + } } *************** *** 161,173 **** { this.state[this.GetUniqueNodeName(node)] = node.Checked; } ! public void GetState(TreeNode node) { string uniqueName = this.GetUniqueNodeName(node); if(this.state.ContainsKey(uniqueName)) { ! node.Checked = (bool)this.state[uniqueName]; } } --- 173,196 ---- { this.state[this.GetUniqueNodeName(node)] = node.Checked; + this.OnStateChanged(node, node.Checked); } ! public bool GetState(TreeNode node) ! { ! if(this.HasState(node)) ! { ! return (bool)this.state[this.GetUniqueNodeName(node)]; ! } ! return false; ! } ! ! public bool HasState(TreeNode node) { string uniqueName = this.GetUniqueNodeName(node); if(this.state.ContainsKey(uniqueName)) { ! return true; } + return false; } *************** *** 179,195 **** public void LoadState() { foreach(TreeNode node in this.Nodes) { this.LoadState(node); } } protected void LoadState(TreeNode node) { - this.GetState(node); foreach(TreeNode child in node.Nodes) { this.LoadState(child); } } } --- 202,234 ---- public void LoadState() { + this.disableAfterSelect = true; foreach(TreeNode node in this.Nodes) { this.LoadState(node); } + this.disableAfterSelect = false; + } + + private void SmartTreeView_BeforeCheck(object sender, System.Windows.Forms.TreeViewCancelEventArgs e) + { + //Console.WriteLine("{0} has a parent? {1}", e.Node.Text, e.Node.Parent != null); } protected void LoadState(TreeNode node) { foreach(TreeNode child in node.Nodes) { this.LoadState(child); } + node.Checked = this.GetState(node); + } + + protected virtual void OnStateChanged(TreeNode node, bool state) + { + if (StateChanged != null) + { + //Invokes the delegates. + StateChanged(node, state); + } } } |
From: Sean M. <int...@us...> - 2005-06-05 08:50:41
|
Update of /cvsroot/adapdev/Adapdev/src/Adapdev.Windows.Forms.Tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31410/src/Adapdev.Windows.Forms.Tests Modified Files: SmartTreeViewTest.cs Log Message: Fixed several bugs with SmartTreeView Fixed bugs with TestRunner Index: SmartTreeViewTest.cs =================================================================== RCS file: /cvsroot/adapdev/Adapdev/src/Adapdev.Windows.Forms.Tests/SmartTreeViewTest.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** SmartTreeViewTest.cs 2 Jun 2005 03:26:00 -0000 1.2 --- SmartTreeViewTest.cs 5 Jun 2005 08:50:32 -0000 1.3 *************** *** 150,167 **** public void GetState() { this.GetNode1().Checked = false; Assert.IsTrue(this.GetNode1().Checked == false, "Node1 should not be checked initially"); // Check it - checked state should be saved this.GetNode1().Checked = true; // Remove it this.GetNode1().Remove(); // Readd it this.GetRoot().Nodes.Add("Node1"); ! this.GetNode1().Checked = false; ! Assert.IsTrue(this.GetNode1().Checked == false, "Node1 should not be checked after being added"); // Load the state this.tree.LoadState(); Assert.IsTrue(this.GetNode1().Checked == true, "Node1 should be checked."); // Clear the state and reload --- 150,184 ---- public void GetState() { + this.tree.StateChanged += new StateChangedEventHandler(tree_StateChanged); ; + this.GetRoot().Checked = false; this.GetNode1().Checked = false; Assert.IsTrue(this.GetNode1().Checked == false, "Node1 should not be checked initially"); + // Check it - checked state should be saved this.GetNode1().Checked = true; + Assert.IsTrue(tree.GetState(this.GetNode1()), "State wasn't saved for Node1"); + + string node1a = tree.GetUniqueNodeName(this.GetNode1()); + // Remove it + this.GetNode2().Remove(); this.GetNode1().Remove(); + // Readd it this.GetRoot().Nodes.Add("Node1"); ! this.GetRoot().Nodes.Add("Node2"); ! string node2a = tree.GetUniqueNodeName(this.GetNode1()); ! Assert.AreEqual(node1a, node2a, "Nodes should be the same for state monitoring."); ! ! Assert.IsFalse(this.GetNode1().Checked, "Node1 should not be checked after being added"); ! Assert.IsFalse(this.GetNode2().Checked, "Node2 should not be checked before LoadState."); ! Assert.IsTrue(tree.HasState(this.GetNode1()), "State no longer exists for Node1"); ! Assert.IsTrue(tree.GetState(this.GetNode1()), "State should still be true."); ! // Load the state this.tree.LoadState(); Assert.IsTrue(this.GetNode1().Checked == true, "Node1 should be checked."); + Assert.IsTrue(this.GetNode2().Checked == false, "Node1 should not be checked after LoadState."); // Clear the state and reload *************** *** 209,212 **** --- 226,234 ---- } #endregion + + private void tree_StateChanged(TreeNode node, bool state) + { + //Console.WriteLine("{0} changed to {1}", node.Text, state); + } } } |
From: Sean M. <int...@us...> - 2005-06-05 08:49:32
|
Update of /cvsroot/adapdev/Adapdev/src/Adapdev.UnitTest.Core.Tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30645/Adapdev.UnitTest.Core.Tests Log Message: Directory /cvsroot/adapdev/Adapdev/src/Adapdev.UnitTest.Core.Tests added to the repository |
From: Sean M. <int...@us...> - 2005-06-05 08:49:29
|
Update of /cvsroot/adapdev/Adapdev/src/Adapdev.UnitTest.Tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30645/Adapdev.UnitTest.Tests Log Message: Directory /cvsroot/adapdev/Adapdev/src/Adapdev.UnitTest.Tests added to the repository |
From: Sean M. <int...@us...> - 2005-06-03 11:39:41
|
Update of /cvsroot/adapdev/Adapdev/src/Adapdev.Cache In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14993/src/Adapdev.Cache Added Files: CacheStats.cs Log Message: --- NEW FILE: CacheStats.cs --- using System; using Adapdev.Diagnostics; namespace Adapdev.Cache { using System.Text; using Adapdev.Cache.Scavengers; /// <summary> /// Summary description for CacheStats. /// </summary> public class CacheStats : ICache { private ICache _cache = null; private double _retrieveTime; private double _retrieveTimeAvg; private int _retrieved; private double _insertTimeAvg; private double _insertTime; private double _inserted; private int _hitCount; private int _missCount; private readonly IPerfTimer timer = PerfTimerFactory.GetPerfTimer(PerfTimerType.HIRESSECONDS); public CacheStats(ICache cache) { this._cache = cache; } #region ICache Members public void Add(string key, object o) { timer.Start(); this._cache.Add(key, o); timer.Stop(); this._insertTime = timer.Duration; this._insertTimeAvg += timer.Duration; this._inserted++; } public void Add(int key, object o) { this.Add(key.ToString(), o); } public void Remove(Type t, int key) { this.Remove(t, key.ToString()); } public void Remove(Type t, string key) { this._cache.Remove(t, key); } public object Get(Type t, int key) { return this.Get(t, key.ToString()); } public object Get(Type t, string key) { timer.Start(); object o = this._cache.Get(t, key); timer.Stop(); this._retrieveTime = timer.Duration; this._retrieveTimeAvg += timer.Duration; this._retrieved++; if(o == null) this._missCount++; else this._hitCount++; return o; } public CacheItem GetCacheItem(Type t, string key) { return this._cache.GetCacheItem(t, key); } public CacheItem GetCacheItem(Type t, int key) { return this._cache.GetCacheItem(t, key); } public void Clear() { this._cache.Clear(); this._hitCount = 0; this._inserted = 0; this._insertTime = 0; this._insertTimeAvg = 0; this._missCount = 0; this._retrieved = 0; this._retrieveTime = 0; this._retrieveTimeAvg = 0; } public int Count { get { return this._cache.Count; } } public bool Contains(Type t, string key) { return this._cache.Contains(t, key); } public bool Contains(Type t, int key) { return this._cache.Contains(t, key); } public void Scavenge(Adapdev.Cache.Scavengers.IScavenger scavenger) { this._cache.Scavenge(scavenger); } public CacheItem[] Entries { get { return this._cache.Entries; } } public void Populate() { this._cache.Populate(); } public void Copy(ICache cache) { this._cache.Copy(cache); } public double ScavengeInterval { get{return this._cache.ScavengeInterval;} set{this._cache.ScavengeInterval = value;} } #endregion public double RetrieveTime { get{return this._retrieveTime;} } public double InsertTime { get{return this._insertTime;} } public double AverageRetrieveTime { get{return this._retrieveTimeAvg / this._retrieved;} } public double AverageInsertTime { get{return this._insertTimeAvg / this._inserted;} } public override string ToString() { StringBuilder sb = new StringBuilder(); sb.AppendFormat("Insert Time: {0}\r\n", this.InsertTime); sb.AppendFormat("Avg. Insert Time: {0}\r\n", this.AverageInsertTime); sb.AppendFormat("Retrieve Time: {0}\r\n", this.RetrieveTime); sb.AppendFormat("Avg. Retrieve Time: {0}\r\n", this.AverageRetrieveTime); sb.AppendFormat("Hit Count: {0}\r\n", this.HitCount); sb.AppendFormat("Miss Count: {0}\r\n", this.MissCount); return sb.ToString(); } public ICache Cache { get{return this._cache;} } public int HitCount { get{return this._hitCount;} } public int MissCount { get{return this._missCount;} } public void Scavenge(IScavenger scavenger, TimeSpan timespan) { this.Scavenge(scavenger, timespan); } } } |
From: Sean M. <int...@us...> - 2005-06-03 04:33:14
|
Update of /cvsroot/adapdev/Adapdev/src/Adapdev/Text/Indexing In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26938/src/Adapdev/Text/Indexing Added Files: IIndex.cs IRecord.cs ISearchExpression.cs ISearchHitFilter.cs SearchResult.cs Log Message: --- NEW FILE: IIndex.cs --- #region license // Bamboo.Prevalence - a .NET object prevalence engine // Copyright (C) 2004 Rodrigo B. de Oliveira // // Based on the original concept and implementation of Prevayler (TM) // by Klaus Wuestefeld. Visit http://www.prevayler.org for details. // // 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. // // Contact Information // // http://bbooprevalence.sourceforge.net // mailto:rod...@us... #endregion using System; namespace Adapdev.Text.Indexing { /// <summary> /// A index. /// </summary> public interface IIndex { /// <summary> /// Adds a new record to the index. /// </summary> /// <param name="record">the record</param> void Add(IRecord record); /// <summary> /// Removes a record from the index. /// </summary> /// <param name="record">existing record that /// must be removed</param> /// <remarks>for the sake of efficiency, /// reference comparison should always be preferred /// over object.Equals</remarks> void Remove(IRecord record); /// <summary> /// Removes all records from the index. /// </summary> void Clear(); /// <summary> /// Reindexes a existing record. Reindexing /// must always be explicitly started by /// the application. /// </summary> /// <param name="record">an existing record that /// was externally changed and thus should /// have its index updated</param> /// <remarks>for the sake of efficiency, /// reference comparison should always be preferred /// over object.Equals</remarks> void Update(IRecord record); /// <summary> /// Executes the search represented by the /// expression passed as argument.<br /> /// /// If the index does not know how to /// execute the search it should call /// <see cref="ISearchExpression.Evaluate"/>. Because /// of that, <see cref="ISearchExpression.Evaluate"/> /// must never call this method. /// </summary> /// <param name="expression">search expression</param> SearchResult Search(ISearchExpression expression); } } --- NEW FILE: ISearchHitFilter.cs --- #region license // Bamboo.Prevalence - a .NET object prevalence engine // Copyright (C) 2004 Rodrigo B. de Oliveira // // Based on the original concept and implementation of Prevayler (TM) // by Klaus Wuestefeld. Visit http://www.prevayler.org for details. // // 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. // // Contact Information // // http://bbooprevalence.sourceforge.net // mailto:rod...@us... #endregion using System; namespace Adapdev.Text.Indexing { /// <summary> /// SearchHit filtering condition. /// </summary> public interface ISearchHitFilter { /// <summary> /// Test if the hit matches the filtering condition. /// </summary> /// <param name="hit">the hit</param> /// <returns>true if the hit matches the condition and should be included in the /// resulting SearchResult</returns> bool Test(SearchHit hit); } } --- NEW FILE: SearchResult.cs --- #region license // Bamboo.Prevalence - a .NET object prevalence engine // Copyright (C) 2004 Rodrigo B. de Oliveira // // Based on the original concept and implementation of Prevayler (TM) // by Klaus Wuestefeld. Visit http://www.prevayler.org for details. // // 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. // // Contact Information // // http://bbooprevalence.sourceforge.net // mailto:rod...@us... #endregion using System; using System.Collections; namespace Adapdev.Text.Indexing { #region SearchHit class /// <summary> /// A single item returned from a search. /// </summary> public class SearchHit { IRecord _record; /// <summary> /// creates a new object for the /// record passed as argument. /// </summary> /// <param name="record">a record</param> public SearchHit(IRecord record) { _record = record; } /// <summary> /// combines two search hits that refer /// to the same record. all the extended /// properties such as ranking and index specific /// information should be combined. /// </summary> /// <param name="other">the SearchHit that /// should be combined to this one</param> public void Combine(SearchHit other) { } /// <summary> /// The record. /// </summary> public IRecord Record { get { return _record; } } /// <summary> /// Creates a clone from this object. /// </summary> /// <returns>a clone</returns> public SearchHit Clone() { return new SearchHit(_record); } } #endregion #region SearchResult class /// <summary> /// Accumulates the results of a search. /// </summary> public class SearchResult : IEnumerable { #region RecordFieldComparer (used by SortByField) /// <summary> /// IComparer implementation for IRecord fields. /// </summary> public class RecordFieldComparer : System.Collections.IComparer { string _field; /// <summary> /// Creates a new RecordFieldComparer for /// a specific field. /// </summary> /// <param name="field">field that should be used /// in comparisons</param> public RecordFieldComparer(string field) { _field = field; } #region Implementation of IComparer /// <summary> /// See <see cref="IComparer.Compare"/> for details. /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <returns></returns> public int Compare(object x, object y) { IRecord lhs = ((SearchHit)x).Record; IRecord rhs = ((SearchHit)y).Record; object lhsField = lhs[_field]; object rhsField = rhs[_field]; return ((IComparable)lhsField).CompareTo(rhsField); } #endregion } #endregion #region RecordComparer internal class RecordComparer : System.Collections.IComparer { System.Collections.IComparer _comparer; public RecordComparer(System.Collections.IComparer comparer) { _comparer = comparer; } #region IComparer Members public int Compare(object x, object y) { return _comparer.Compare(((SearchHit)x).Record, ((SearchHit)y).Record); } #endregion } #endregion #region SearchHitRecordEnumerator (used by GetRecordEnumerator()) /// <summary> /// Enumerates the records in a SearchResult. /// </summary> public class SearchHitRecordEnumerator : IEnumerator, IEnumerable { IEnumerator _hits; internal SearchHitRecordEnumerator(IEnumerator hits) { _hits = hits; } #region Implementation of IEnumerator /// <summary> /// See <see cref="IEnumerator.Reset"/> for details. /// </summary> public void Reset() { _hits.Reset(); } /// <summary> /// See <see cref="IEnumerator.MoveNext"/> for details. /// </summary> /// <returns></returns> public bool MoveNext() { return _hits.MoveNext(); } /// <summary> /// The current record. /// </summary> public IRecord Current { get { return ((SearchHit)_hits.Current).Record; } } object IEnumerator.Current { get { return ((SearchHit)_hits.Current).Record; } } #endregion #region Implementation of IEnumerable System.Collections.IEnumerator IEnumerable.GetEnumerator() { return this; } #endregion } #endregion long _elapsedTime; ArrayList _hits; /// <summary> /// Creates an empty SearchResult object. /// </summary> public SearchResult() { _hits = new ArrayList(); } /// <summary> /// Number of items returned by the search. /// </summary> public int Count { get { return _hits.Count; } } /// <summary> /// Checks if the specified record was returned /// by the search. /// </summary> /// <param name="record">record to be checked</param> /// <returns>true if the record was indeed returned /// by the search</returns> /// <remarks>reference comparison is always used</remarks> public bool Contains(IRecord record) { return FindSearchHit(record) != null; } /// <summary> /// Adds a new item to the collection of items /// returned by the search. If the hit /// represents an existing record it /// will be combined to the existing hit instead. /// </summary> /// <param name="hit">the hit to be added or /// combined to a existing hit</param> public void Add(SearchHit hit) { SearchHit existing = FindSearchHit(hit.Record); if (null != existing) { existing.Combine(hit); } else { _hits.Add(hit); } } /// <summary> /// How long the search took /// </summary> public long ElapsedTime { get { return _elapsedTime; } set { _elapsedTime = value; } } /// <summary> /// Returns an item by its position /// </summary> public SearchHit this[int index] { get { return (SearchHit)_hits[index]; } } /// <summary> /// Set intersection operation. Creates /// a new SearchResult with all the records /// that exist in both SearchResult objects. /// </summary> /// <param name="other"></param> /// <returns>a SearchResult representing the /// intersection between the this and other objects /// </returns> /// <remarks>all the SearchHit objects in /// the resulting SearchResult are clones from /// the original ones combined to the ones in /// other</remarks> public SearchResult Intersect(SearchResult other) { SearchResult result = new SearchResult(); foreach (SearchHit hit in _hits) { SearchHit otherHit = other.FindSearchHit(hit.Record); if (null != otherHit) { SearchHit resultingHit = hit.Clone(); resultingHit.Combine(otherHit); result.Add(resultingHit); } } return result; } /// <summary> /// Build a new SearchResult object including /// only those elements for which the /// filter returns true. /// </summary> /// <param name="filter">filter</param> /// <returns>a new SearchResult containing all the elements for which /// <see cref="ISearchHitFilter.Test"/> returned true</returns> public SearchResult Filter(ISearchHitFilter filter) { SearchResult result = new SearchResult(); foreach (SearchHit hit in _hits) { if (filter.Test(hit)) { result.Add(hit); } } return result; } /// <summary> /// Sorts the result by a specific record field. /// </summary> /// <param name="field">the field to be used in the sort</param> public void SortByField(string field) { if (null == field) { throw new ArgumentNullException("field"); } _hits.Sort(new RecordFieldComparer(field)); } /// <summary> /// Sorts the result using the specified comparer. /// </summary> /// <param name="comparer"></param> public void Sort(IComparer comparer) { if (null == comparer) { throw new ArgumentNullException("comparer"); } _hits.Sort(new RecordComparer(comparer)); } /// <summary> /// Copies all the records to an array. The /// order is mantained so that /// this[N].Record == resultingArray[N] is /// valid for every 0 <= N < this.Count. /// </summary> /// <param name="recordType">array element type</param> /// <returns>the resulting array.</returns> public Array ToRecordArray(Type recordType) { object[] records = (object[])Array.CreateInstance(recordType, _hits.Count); for (int i=0; i<records.Length; ++i) { records[i] = ((SearchHit)_hits[i]).Record; } return records; } public Array ToRecordArray() { return ToRecordArray(typeof(object)); } /// <summary> /// Returns an enumerator for all the records /// in this object. /// </summary> /// <returns></returns> public SearchHitRecordEnumerator GetRecordEnumerator() { return new SearchHitRecordEnumerator(_hits.GetEnumerator()); } /// <summary> /// Finds a SearchHit that represents a specific /// record. /// </summary> /// <param name="record">the record to search for</param> /// <returns>the found SearchHit or null</returns> protected SearchHit FindSearchHit(IRecord record) { foreach (SearchHit hit in _hits) { if (hit.Record == record) { return hit; } } return null; } #region Implementation of IEnumerable /// <summary> /// See <see cref="IEnumerable.GetEnumerator"/> for details /// </summary> /// <returns></returns> public IEnumerator GetEnumerator() { return _hits.GetEnumerator(); } #endregion } #endregion } --- NEW FILE: IRecord.cs --- #region license // Bamboo.Prevalence - a .NET object prevalence engine // Copyright (C) 2004 Rodrigo B. de Oliveira // // Based on the original concept and implementation of Prevayler (TM) // by Klaus Wuestefeld. Visit http://www.prevayler.org for details. // // 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. // // Contact Information // // http://bbooprevalence.sourceforge.net // mailto:rod...@us... #endregion using System; namespace Adapdev.Text.Indexing { /// <summary> /// A record that can be indexed by its fields. /// </summary> public interface IRecord { /// <summary> /// Field acessor. Returns the named field. /// </summary> /// <exception cref="ArgumentException">if the specified named field does not exist</exception> object this[string name] { get; } } } --- NEW FILE: ISearchExpression.cs --- #region license // Bamboo.Prevalence - a .NET object prevalence engine // Copyright (C) 2004 Rodrigo B. de Oliveira // // Based on the original concept and implementation of Prevayler (TM) // by Klaus Wuestefeld. Visit http://www.prevayler.org for details. // // 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. // // Contact Information // // http://bbooprevalence.sourceforge.net // mailto:rod...@us... #endregion using System; namespace Adapdev.Text.Indexing { /// <summary> /// Models a search over an index or a set /// of indexes. /// </summary> public interface ISearchExpression { /// <summary> /// Evaluates the expression against /// the specified index.<br /> /// If the expression can not be evaluated /// using the specified index /// it should raise ArgumentException. /// </summary> /// <param name="index">the index</param> /// <remarks>the expression must never call /// <see cref="IIndex.Search"/> unless it is completely sure /// the IIndex implementation knows how to handle the expression without /// calling this method again (what whould result in a infinite recursion loop)</remarks> /// <exception cref="ArgumentException">when the expression can not be evaluated with the specified index</exception> SearchResult Evaluate(IIndex index); } } |
Update of /cvsroot/adapdev/Adapdev/src/Adapdev/Text/Indexing/FullText/Filters In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26938/src/Adapdev/Text/Indexing/FullText/Filters Added Files: AbstractFilter.cs ConditionalFilter.cs RegexTokenFilter.cs SpecialCharactersFilter.cs TokenLengthFilter.cs WordFilter.cs Log Message: --- NEW FILE: RegexTokenFilter.cs --- #region license // Bamboo.Prevalence - a .NET object prevalence engine // Copyright (C) 2004 Rodrigo B. de Oliveira // // Based on the original concept and implementation of Prevayler (TM) // by Klaus Wuestefeld. Visit http://www.prevayler.org for details. // // 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. // // Contact Information // // http://bbooprevalence.sourceforge.net // mailto:rod...@us... #endregion using System; using System.Text.RegularExpressions; using Adapdev.Text.Indexing.FullText; namespace Adapdev.Text.Indexing.FullText.Filters { /// <summary> /// Filters off tokens based on a regular expression. /// </summary> /// <remarks>This filter will filter off /// any tokens that <b>match</b> the regular /// expression (and not the ones that don't)</remarks> [Serializable] public class RegexTokenFilter : ConditionalFilter { Regex _regex; /// <summary> /// Creates a new filter that will filter off any /// tokens that match the regular expression passed /// as argument. /// </summary> /// <param name="regex">the regular expression</param> public RegexTokenFilter(string regex) : this(null, regex) { } /// <summary> /// Creates a new filter that will filter off any /// tokens that match the regular expression passed /// as argument. /// </summary> /// <param name="previous">the previous tokenizer in the chain</param> /// <param name="regex">the regular expression</param> public RegexTokenFilter(ITokenizer previous, string regex) : base(previous) { if (null == regex) { throw new ArgumentNullException("regex", "regex can't be null!"); } _regex = new Regex(regex); } /// <summary> /// Creates a new filter that will filter off any /// tokens that match the regular expression passed /// as argument. /// </summary> /// <param name="regex">the regular expression</param> public RegexTokenFilter(Regex regex) : this(null, regex) { } /// <summary> /// Creates a new filter that will filter off any /// tokens that match the regular expression passed /// as argument. /// </summary> /// <param name="previous">the previous tokenizer in the chain</param> /// <param name="regex">the regular expression</param> public RegexTokenFilter(ITokenizer previous, Regex regex) : base(previous) { if (null == regex) { throw new ArgumentNullException("regex", "regex can't be null!"); } _regex = regex; } /// <summary> /// See <see cref="ConditionalFilter.IsValidToken"/> for details. /// </summary> /// <param name="token"></param> /// <returns></returns> protected override bool IsValidToken(Token token) { return !_regex.IsMatch(token.Value); } } } --- NEW FILE: ConditionalFilter.cs --- #region license // Bamboo.Prevalence - a .NET object prevalence engine // Copyright (C) 2004 Rodrigo B. de Oliveira // // Based on the original concept and implementation of Prevayler (TM) // by Klaus Wuestefeld. Visit http://www.prevayler.org for details. // // 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. // // Contact Information // // http://bbooprevalence.sourceforge.net // mailto:rod...@us... #endregion using System; using Adapdev.Text.Indexing.FullText; namespace Adapdev.Text.Indexing.FullText.Filters { /// <summary> /// Base class for filter implementations that /// exclude tokens from the stream based on /// a condition. /// </summary> [Serializable] public abstract class ConditionalFilter : AbstractFilter { /// <summary> /// Creates a standalone filter (with no previous /// tokenizer). /// </summary> protected ConditionalFilter() { } /// <summary> /// Creates a filter in a filter chain. /// </summary> /// <param name="previous">the previous token in the chain</param> protected ConditionalFilter(ITokenizer previous) : base(previous) { } /// <summary> /// Gets a token from the previous tokenizer in the chain /// and checks the condition implemented by IsValidToken, /// when IsValidToken returns false the token is discarded /// and a new one is tried. This process is repeated until /// IsValidToken returns true or the previous tokenizer /// returns null. /// </summary> /// <returns>the next token for which IsValidToken returns true or /// null when the previous tokenizer runs out of tokens</returns> public override Adapdev.Text.Indexing.FullText.Token NextToken() { Token token = _previous.NextToken(); while (null != token) { if (IsValidToken(token)) { break; } token = _previous.NextToken(); } return token; } /// <summary> /// Test if the token is a valid token and /// as such should be returned to the /// caller of <see cref="NextToken" />. /// </summary> /// <param name="token">token to be tested</param> /// <returns>true if the token is valid, false otherwise</returns> protected abstract bool IsValidToken(Token token); } } --- NEW FILE: AbstractFilter.cs --- #region license // Bamboo.Prevalence - a .NET object prevalence engine // Copyright (C) 2004 Rodrigo B. de Oliveira // // Based on the original concept and implementation of Prevayler (TM) // by Klaus Wuestefeld. Visit http://www.prevayler.org for details. // // 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. // // Contact Information // // http://bbooprevalence.sourceforge.net // mailto:rod...@us... #endregion using System; using Adapdev.Text.Indexing.FullText; namespace Adapdev.Text.Indexing.FullText.Filters { /// <summary> /// Basic implementation for ITokenFilter with /// support for tokenizer chaining. /// </summary> [Serializable] public abstract class AbstractFilter : ITokenFilter { /// <summary> /// the previous tokenizer in the chain /// </summary> protected ITokenizer _previous; /// <summary> /// Creates a new filter with no previous /// tokenizer. /// </summary> protected AbstractFilter() { _previous = null; } /// <summary> /// Creates a new filter with a previous /// tokenizer in a tokenizer chain. /// </summary> /// <param name="previous">the previous tokenizer /// in the chain</param> protected AbstractFilter(ITokenizer previous) { _previous = previous; } /// <summary> /// Gets/sets the previous tokenizer /// in the chain. /// </summary> public ITokenizer Previous { get { return _previous; } set { _previous = value; } } /// <summary> /// Returns a MemberwiseClone of this object /// with the guarantee that the tail argument /// will be the last tokenizer in the new /// tokenizer chain. /// </summary> /// <param name="tail">the last tokenizer for the /// new chain</param> /// <returns>cloned chain with tail as the /// last tokenizer in the chain</returns> public ITokenizer Clone(ITokenizer tail) { AbstractFilter clone = MemberwiseClone() as AbstractFilter; if (null == _previous) { clone._previous = tail; } else { clone._previous = _previous.Clone(tail); } return clone; } /// <summary> /// Must be supplied by derived classes. /// </summary> /// <returns></returns> public abstract Token NextToken(); } } --- NEW FILE: WordFilter.cs --- #region license // Bamboo.Prevalence - a .NET object prevalence engine // Copyright (C) 2004 Rodrigo B. de Oliveira // // Based on the original concept and implementation of Prevayler (TM) // by Klaus Wuestefeld. Visit http://www.prevayler.org for details. // // 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. // // Contact Information // // http://bbooprevalence.sourceforge.net // mailto:rod...@us... #endregion using System; using System.Collections; using Adapdev.Text.Indexing.FullText; namespace Adapdev.Text.Indexing.FullText.Filters { /// <summary> /// Filters off tokens by word. /// </summary> [Serializable] public class WordFilter : ConditionalFilter { Hashtable _words; /// <summary> /// See <see cref="WordFilter(string[])"/>. /// </summary> /// <param name="previous">the previous tokenizer in the chain</param> /// <param name="words">list of words that should be filtered /// off the chain</param> public WordFilter(ITokenizer previous, params string[] words) : base(previous) { if (null == words) { throw new ArgumentNullException("words"); } _words = new Hashtable(words.Length); foreach (string word in words) { _words[word] = null; } } /// <summary> /// Creates a new filter that will not allow /// any words in the list represented by the words /// argument to pass through the chain. /// </summary> /// <param name="words">list of words that should be filtered /// off the chain</param> public WordFilter(params string[] words) : this(null, words) { } /// <summary> /// See <see cref="ConditionalFilter.IsValidToken"/> for details. /// </summary> /// <param name="token"></param> /// <returns></returns> protected override bool IsValidToken(Token token) { return !_words.ContainsKey(token.Value); } } } --- NEW FILE: TokenLengthFilter.cs --- #region license // Bamboo.Prevalence - a .NET object prevalence engine // Copyright (C) 2004 Rodrigo B. de Oliveira // // Based on the original concept and implementation of Prevayler (TM) // by Klaus Wuestefeld. Visit http://www.prevayler.org for details. // // 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. // // Contact Information // // http://bbooprevalence.sourceforge.net // mailto:rod...@us... #endregion using System; using Adapdev.Text.Indexing.FullText; namespace Adapdev.Text.Indexing.FullText.Filters { /// <summary> /// Filters off tokens by length. /// </summary> [Serializable] public class TokenLengthFilter : ConditionalFilter { int _minTokenLength; /// <summary> /// Creates a new filter that will only allow /// tokens with at least minTokenLength /// characters to pass. /// </summary> /// <param name="minTokenLength">minimum token length</param> public TokenLengthFilter(int minTokenLength) { _minTokenLength = minTokenLength; } /// <summary> /// See <see cref="TokenLengthFilter(int)"/>. /// </summary> /// <param name="previous">previous tokenizer in the chain</param> /// <param name="minTokenLength">minimum token length</param> public TokenLengthFilter(ITokenizer previous, int minTokenLength) : base(previous) { _minTokenLength = minTokenLength; } /// <summary> /// See <see cref="ConditionalFilter.IsValidToken"/> for details. /// </summary> /// <param name="token"></param> /// <returns></returns> protected override bool IsValidToken(Token token) { return (token.Value.Length >= _minTokenLength); } } } --- NEW FILE: SpecialCharactersFilter.cs --- #region license // Bamboo.Prevalence - a .NET object prevalence engine // Copyright (C) 2004 Rodrigo B. de Oliveira // // Based on the original concept and implementation of Prevayler (TM) // by Klaus Wuestefeld. Visit http://www.prevayler.org for details. // // 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. // // Contact Information // // http://bbooprevalence.sourceforge.net // mailto:rod...@us... #endregion using System; using System.Globalization; using System.Text; using Adapdev.Text.Indexing.FullText; namespace Adapdev.Text.Indexing.FullText.Filters { /// <summary> /// A filter that replaces special characters by /// their simpler ASCII counterparts. /// </summary> [Serializable] public class SpecialCharactersFilter : AbstractFilter { /// <summary> /// Creates a new filter. /// </summary> public SpecialCharactersFilter() { } /// <summary> /// Creates a new filter in a tokenizer chain. /// </summary> /// <param name="previous">previous tokenizer in the chain</param> public SpecialCharactersFilter(ITokenizer previous) : base(previous) { } /// <summary> /// Gets the token from the previous tokenizer in the /// chain and replaces every "complex" character /// in the token by its simpler counterpart. /// </summary> /// <returns>the new token or null</returns> public override Token NextToken() { Token token = _previous.NextToken(); if (null != token) { token.Value = Filter(token.Value); } return token; } public static string Filter(string value) { char[] mapped = new char[value.Length]; for (int i=0; i<value.Length; ++i) { char c = char.ToLower(value[i]); switch (c) { case 'á': c = 'a'; break; case 'ã': c = 'a'; break; case 'â': c = 'a'; break; case 'à ': c = 'a'; break; case 'é': c = 'e'; break; case 'ê': c = 'e'; break; case 'Ã': c = 'i'; break; case 'ó': c = 'o'; break; case 'õ': c = 'o'; break; case 'ô': c = 'o'; break; case 'ú': c = 'u'; break; case 'ü': c = 'u'; break; case 'ç': c = 'c'; break; } mapped[i] = c; } return new string(mapped); } } } |
From: Sean M. <int...@us...> - 2005-06-03 04:33:13
|
Update of /cvsroot/adapdev/Adapdev/src/Adapdev/Text/Indexing/Records In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26938/src/Adapdev/Text/Indexing/Records Added Files: HashtableRecord.cs Log Message: --- NEW FILE: HashtableRecord.cs --- #region license // Bamboo.Prevalence - a .NET object prevalence engine // Copyright (C) 2004 Rodrigo B. de Oliveira // // Based on the original concept and implementation of Prevayler (TM) // by Klaus Wuestefeld. Visit http://www.prevayler.org for details. // // 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. // // Contact Information // // http://bbooprevalence.sourceforge.net // mailto:rod...@us... #endregion using System; using System.Collections; namespace Adapdev.Text.Indexing.Records { /// <summary> /// An IRecord implementation over a Hashtable. /// </summary> [Serializable] public class HashtableRecord : Adapdev.Text.Indexing.IRecord { /// <summary> /// The hashtable. /// </summary> protected Hashtable _hashtable; /// <summary> /// Creates an empty record. /// </summary> public HashtableRecord() { _hashtable = new Hashtable(); } /// <summary> /// Sets/Gets a hashtable field. /// </summary> public object this[string name] { get { return _hashtable[name]; } set { _hashtable[name] = value; } } /// <summary> /// Delegates to the internal hashtable. /// </summary> /// <returns></returns> public override int GetHashCode() { return _hashtable.GetHashCode(); } /// <summary> /// Delegates to the internal hashtable. /// </summary> /// <param name="rhs"></param> /// <returns></returns> public override bool Equals(object rhs) { HashtableRecord other = rhs as HashtableRecord; if (null == other) { return false; } return other._hashtable.Equals(_hashtable); } } } |
From: Sean M. <int...@us...> - 2005-06-03 04:33:13
|
Update of /cvsroot/adapdev/Adapdev/src/Adapdev/XPath In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26938/src/Adapdev/XPath Added Files: TypeInfoCache.cs XPathObjectNavigator.cs Log Message: --- NEW FILE: XPathObjectNavigator.cs --- #region license // Bamboo.Prevalence - a .NET object prevalence engine // Copyright (C) 2004 Rodrigo B. de Oliveira // // Based on the original concept and implementation of Prevayler (TM) // by Klaus Wuestefeld. Visit http://www.prevayler.org for details. // // 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. // // Contact Information // // http://bbooprevalence.sourceforge.net // mailto:rod...@us... #endregion using System; using System.Xml; using System.Xml.XPath; using Adapdev.XPath.Internal; namespace Adapdev.XPath { /// <summary> /// XPathNavigator implementation over an arbitrary /// object graph. /// </summary> /// <example> /// <code> /// Address address = new Address("Al. Calder�o Branco", 784); /// Customer customer = new Customer("Rodrigo", "Oliveira", address); /// /// XPathObjectNavigator context = new XPathObjectNavigator(customer); /// XPathNodeIterator i = context.Select("/Customer/Address/Street"); /// AssertEquals(1, i.Count); /// AssertEquals(true, i.MoveNext()); /// AssertEquals(customer.Address.Street, i.Current.Value); /// AssertEquals(customer.Address.Street, ((XPathObjectNavigator)i.Current).Node); /// </code> /// </example> public class XPathObjectNavigator : XPathNavigator { ObjectNavigatorState _state; ObjectNavigatorState _root; ObjectNavigationContext _context; string _lang; /// <summary> /// Create a new navigator for the object graph /// starting at node. The node's name is nodeName. /// </summary> /// <param name="node">root</param> /// <param name="nodeName">root's name</param> public XPathObjectNavigator(object node, string nodeName) { _context = new ObjectNavigationContext(); _context.NameTable.Add(string.Empty); _root = new ObjectNavigatorStateRoot(_context, node, nodeName); _state = _root.MoveToFirstChild(); _lang = _context.NameTable.Add("en-US"); } /// <summary> /// Create a new navigator for the object graph /// starting at node. The node name will be /// node.GetType().Name. /// </summary> /// <param name="node">root</param> public XPathObjectNavigator(object node) : this(node, null) { } /// <summary> /// copy constructor. /// </summary> /// <param name="other">navigator to be copied</param> public XPathObjectNavigator(XPathObjectNavigator other) { _context = other._context; _state = other._state; _root = other._root; _lang = other._lang; } /// <summary> /// Selects a single object from the current node. /// </summary> /// <param name="xpath">selection expression</param> /// <returns>the first object returned by the /// expression or null</returns> public object SelectObject(string xpath) { XPathNodeIterator i = Select(xpath); if (i.MoveNext()) { return ((XPathObjectNavigator)i.Current).Node; } return null; } /// <summary> /// Selects a group of objects from the current node. /// </summary> /// <param name="xpath">selection expression</param> /// <param name="returnItemType">array element type to be returned</param> /// <returns>an array with all the objects returned /// by the expression</returns> public System.Array SelectObjects(string xpath, Type returnItemType) { if (null == returnItemType) { throw new ArgumentNullException("returnItemType"); } System.Collections.ArrayList result = new System.Collections.ArrayList(); XPathNodeIterator i = Select(xpath); while (i.MoveNext()) { result.Add(((XPathObjectNavigator)i.Current).Node); } return result.ToArray(returnItemType); } /// <summary> /// Same as <see cref="SelectObjects(System.String, System.Type)"/> with /// returnItemType iguals to typeof(object). /// </summary> /// <param name="xpath"></param> /// <returns></returns> public object[] SelectObjects(string xpath) { return (object[])SelectObjects(xpath, typeof(object)); } /// <summary> /// See <see cref="System.Xml.XPath.XPathNavigator.BaseURI" /> for details. /// </summary> public override string BaseURI { get { Trace("get_BaseURI"); return _context.NameTable.Get(string.Empty); } } /// <summary> /// See <see cref="System.Xml.XPath.XPathNavigator.Clone" /> for details. /// </summary> public override System.Xml.XPath.XPathNavigator Clone() { Trace("Clone"); return new XPathObjectNavigator(this); } /// <summary> /// See <see cref="System.Xml.XPath.XPathNavigator.GetAttribute(string, string)" /> for details. /// </summary> /// <remarks>No attributes are returned.</remarks> public override string GetAttribute(string localName, string namespaceURI) { Trace("GetAttribute"); return string.Empty; } /// <summary> /// See <see cref="System.Xml.XPath.XPathNavigator.GetNamespace(string)" /> for details. /// </summary> /// <remarks>Namespace is always empty</remarks> public override string GetNamespace(string name) { Trace("GetNamespace"); return _context.NameTable.Get(string.Empty); } /// <summary> /// See <see cref="System.Xml.XPath.XPathNavigator.HasAttributes" /> for details. /// </summary> /// <remarks>false</remarks> public override bool HasAttributes { get { Trace("HasAttributes"); return false; } } /// <summary> /// See <see cref="System.Xml.XPath.XPathNavigator.HasChildren" /> for details. /// </summary> public override bool HasChildren { get { Trace("HasChildren"); return false; } } /// <summary> /// See <see cref="System.Xml.XPath.XPathNavigator.IsEmptyElement" /> for details. /// </summary> public override bool IsEmptyElement { get { Trace("IsEmptyElement"); return true; } } /// <summary> /// See <see cref="System.Xml.XPath.XPathNavigator.IsSamePosition" /> for details. /// </summary> public override bool IsSamePosition(System.Xml.XPath.XPathNavigator other) { Trace("IsSamePosition"); XPathObjectNavigator x = other as XPathObjectNavigator; if (null == x) { return false; } return _state.IsSamePosition(x._state); } /// <summary> /// See <see cref="System.Xml.XPath.XPathNavigator.LocalName" /> for details. /// </summary> public override string LocalName { get { Trace("get_LocalName"); return _state.Name; } } /// <summary> /// See <see cref="System.Xml.XPath.XPathNavigator.Name" /> for details. /// </summary> /// <remarks>Same as LocalName</remarks> public override string Name { get { Trace("get_Name"); return _state.Name; } } /// <summary> /// See <see cref="System.Xml.XPath.XPathNavigator.NamespaceURI" /> for details. /// </summary> /// <remarks>Always empty</remarks> public override string NamespaceURI { get { Trace("get_NamespaceURI"); return _context.NameTable.Get(string.Empty); } } /// <summary> /// See <see cref="System.Xml.XPath.XPathNavigator.NameTable" /> for details. /// </summary> public override System.Xml.XmlNameTable NameTable { get { Trace("get_NameTable"); return _context.NameTable; } } /// <summary> /// See <see cref="System.Xml.XPath.XPathNavigator.MoveTo" /> for details. /// </summary> public override bool MoveTo(System.Xml.XPath.XPathNavigator other) { Trace("MoveTo"); XPathObjectNavigator navigator = other as XPathObjectNavigator; if (null == other) { return false; } _state = navigator._state; _root = navigator._root; _context = navigator._context; return true; } /// <summary> /// See <see cref="System.Xml.XPath.XPathNavigator.MoveToAttribute" /> for details. /// </summary> public override bool MoveToAttribute(string localName, string namespaceURI) { Trace("MoveToAttribute"); return false; } /// <summary> /// See <see cref="System.Xml.XPath.XPathNavigator.MoveToFirst" /> for details. /// </summary> /// <remarks>Not supported.</remarks> public override bool MoveToFirst() { Trace("MoveToFirst"); return false; } /// <summary> /// See <see cref="System.Xml.XPath.XPathNavigator.MoveToFirstAttribute" /> for details. /// </summary> public override bool MoveToFirstAttribute() { Trace("MoveToFirstAttribute"); return false; } /// <summary> /// See <see cref="System.Xml.XPath.XPathNavigator.MoveToFirstChild" /> for details. /// </summary> public override bool MoveToFirstChild() { Trace("MoveToFirstChild"); ObjectNavigatorState newstate = _state.MoveToFirstChild(); if (null == newstate) { return false; } _state = newstate; return true; } /// <summary> /// See <see cref="System.Xml.XPath.XPathNavigator.MoveToFirstNamespace" /> for details. /// </summary> public override bool MoveToFirstNamespace(System.Xml.XPath.XPathNamespaceScope namespaceScope) { Trace("MoveToFirstNamespace"); return false; } /// <summary> /// See <see cref="System.Xml.XPath.XPathNavigator.MoveToId" /> for details. /// </summary> /// <remarks>Not supported.</remarks> public override bool MoveToId(string id) { Trace("MoveToId"); return false; } /// <summary> /// See <see cref="System.Xml.XPath.XPathNavigator.MoveToNamespace(string)" /> for details. /// </summary> public override bool MoveToNamespace(string name) { Trace("MoveToNamespace"); return false; } /// <summary> /// See <see cref="System.Xml.XPath.XPathNavigator.MoveToNext" /> for details. /// </summary> public override bool MoveToNext() { Trace("MoveToNext"); ObjectNavigatorState newstate = _state.MoveToNext(); if (null != newstate) { _state = newstate; return true; } return false; } /// <summary> /// See <see cref="System.Xml.XPath.XPathNavigator.MoveToNextAttribute" /> for details. /// </summary> public override bool MoveToNextAttribute() { Trace("MoveToNextAttribute"); return false; } /// <summary> /// See <see cref="System.Xml.XPath.XPathNavigator.MoveToNextNamespace" /> for details. /// </summary> public override bool MoveToNextNamespace(System.Xml.XPath.XPathNamespaceScope namespaceScope) { Trace("MoveToNextNamespace"); return false; } /// <summary> /// See <see cref="System.Xml.XPath.XPathNavigator.MoveToParent" /> for details. /// </summary> public override bool MoveToParent() { Trace("MoveToParent"); if (null != _state.Parent) { _state = _state.Parent; return true; } return false; } /// <summary> /// See <see cref="System.Xml.XPath.XPathNavigator.MoveToPrevious" /> for details. /// </summary> /// <remarks>Not supported.</remarks> public override bool MoveToPrevious() { Trace("MoveToPrevious"); return false; } /// <summary> /// See <see cref="System.Xml.XPath.XPathNavigator.MoveToRoot" /> for details. /// </summary> public override void MoveToRoot() { Trace("MoveToRoot"); _state = _root; } /// <summary> /// See <see cref="System.Xml.XPath.XPathNavigator.NodeType" /> for details. /// </summary> public override System.Xml.XPath.XPathNodeType NodeType { get { Trace("get_NodeType"); return _state.NodeType; } } /// <summary> /// See <see cref="System.Xml.XPath.XPathNavigator.Value" /> for details. /// </summary> public override string Value { get { Trace("get_Value"); return _state.Value; } } /// <summary> /// The current object. /// </summary> public object Node { get { return _state.Node; } } /// <summary> /// See <see cref="System.Xml.XPath.XPathNavigator.XmlLang" /> for details. /// </summary> public override string XmlLang { get { return _lang; } } /// <summary> /// See <see cref="System.Xml.XPath.XPathNavigator.Prefix" /> for details. /// </summary> /// <remarks>Always empty.</remarks> public override string Prefix { get { Trace("get_Prefix"); return _context.NameTable.Get(string.Empty); } } private void Trace(string format, params object[] args) { System.Diagnostics.Trace.WriteLine(string.Format(format, args)); } } } --- NEW FILE: TypeInfoCache.cs --- #region license // Bamboo.Prevalence - a .NET object prevalence engine // Copyright (C) 2004 Rodrigo B. de Oliveira // // Based on the original concept and implementation of Prevayler (TM) // by Klaus Wuestefeld. Visit http://www.prevayler.org for details. // // 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. // // Contact Information // // http://bbooprevalence.sourceforge.net // mailto:rod...@us... #endregion using System; using System.Collections; using System.Reflection; namespace Adapdev.XPath { public interface IValueProvider { string Name { get; } object GetValue(object instance); } public class PropertyInfoValueProvider : IValueProvider { PropertyInfo _pi; public PropertyInfoValueProvider(PropertyInfo pi) { _pi = pi; } public string Name { get { return _pi.Name; } } public object GetValue(object instance) { return _pi.GetValue(instance, (object[])null); } } public class FieldInfoValueProvider : IValueProvider { FieldInfo _fi; public FieldInfoValueProvider(FieldInfo fi) { _fi = fi; } public string Name { get { return _fi.Name; } } public object GetValue(object instance) { return _fi.GetValue(instance); } } /// <summary> /// A cache for the navigable properties of a type. /// </summary> public class TypeInfoCache { /// <summary> /// For types with no navigable properties (like primitives). /// </summary> public static IValueProvider[] EmptyValueProviderArray = new IValueProvider[0]; System.Collections.Hashtable _cache; /// <summary> /// Constructs an empty TypeInfoCache. /// </summary> public TypeInfoCache() { _cache = new System.Collections.Hashtable(); } /// <summary> /// Return the navigable properties for the object passed /// as argument. Any readable public property is considered /// navigable. /// </summary> /// <param name="o">object</param> /// <returns>array of navigable properties</returns> public IValueProvider[] GetNavigableProperties(object o) { IValueProvider[] properties = (IValueProvider[])_cache[o]; if (null == properties) { properties = FindNavigableProperties(o); _cache[o] = properties; } return properties; } private IValueProvider[] FindNavigableProperties(object o) { if (o.GetType().IsPrimitive) { return EmptyValueProviderArray; } ArrayList children = new ArrayList(); BindingFlags flags = BindingFlags.Instance | BindingFlags.Public; foreach (MemberInfo mi in o.GetType().FindMembers(MemberTypes.Property | MemberTypes.Field, flags, null, null)) { PropertyInfo pi = mi as PropertyInfo; if (null != pi) { if (pi.CanRead && 0 == pi.GetGetMethod().GetParameters().Length) { children.Add(new PropertyInfoValueProvider(pi)); } } else { children.Add(new FieldInfoValueProvider((FieldInfo)mi)); } } return (IValueProvider[])children.ToArray(typeof(IValueProvider)); } } } |
From: Sean M. <int...@us...> - 2005-06-03 04:33:13
|
Update of /cvsroot/adapdev/Adapdev/src/Adapdev/XPath/Internal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26938/src/Adapdev/XPath/Internal Added Files: ObjectNavigationContext.cs ObjectNavigatorState.cs ObjectNavigatorStateDictionary.cs ObjectNavigatorStateItem.cs ObjectNavigatorStateList.cs ObjectNavigatorStateRoot.cs Log Message: --- NEW FILE: ObjectNavigationContext.cs --- #region license // Bamboo.Prevalence - a .NET object prevalence engine // Copyright (C) 2004 Rodrigo B. de Oliveira // // Based on the original concept and implementation of Prevayler (TM) // by Klaus Wuestefeld. Visit http://www.prevayler.org for details. // // 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. // // Contact Information // // http://bbooprevalence.sourceforge.net // mailto:rod...@us... #endregion using System; using System.Xml; namespace Adapdev.XPath.Internal { internal class ObjectNavigationContext { public NameTable NameTable; public TypeInfoCache TypeInfoCache; public ObjectNavigationContext() { NameTable = new NameTable(); TypeInfoCache = new TypeInfoCache(); } } } --- NEW FILE: ObjectNavigatorState.cs --- #region license // Bamboo.Prevalence - a .NET object prevalence engine // Copyright (C) 2004 Rodrigo B. de Oliveira // // Based on the original concept and implementation of Prevayler (TM) // by Klaus Wuestefeld. Visit http://www.prevayler.org for details. // // 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. // // Contact Information // // http://bbooprevalence.sourceforge.net // mailto:rod...@us... #endregion using System; using System.Collections; using System.Xml; using System.Xml.XPath; namespace Adapdev.XPath.Internal { internal abstract class ObjectNavigatorState { protected int _index; protected string _name; protected ObjectNavigatorState _parent; protected object _node; protected ObjectNavigationContext _context; public ObjectNavigatorState(ObjectNavigationContext context, ObjectNavigatorState parent, object node, string name) { _parent = parent; _context = context; _node = node; _name = _context.NameTable.Add(name); _index = 0; } internal int Index { get { return _index; } set { _index = value; } } internal virtual bool IsSamePosition(ObjectNavigatorState other) { return other._node == _node && other._index == _index && other._name == _name && other._parent == _parent; } internal virtual string Name { get { return _name; } } internal virtual string Value { get { return _node.ToString(); } } internal ObjectNavigatorState Parent { get { return _parent; } } internal object Node { get { return _node; } } internal abstract XPathNodeType NodeType { get; } internal virtual ObjectNavigatorState MoveToFirstChild() { return null; } internal virtual ObjectNavigatorState MoveToNext() { return null; } internal virtual ObjectNavigatorState MoveToChild(int index) { return null; } internal static ObjectNavigatorState CreateElementState(ObjectNavigationContext context, ObjectNavigatorState parent, object node, string name) { if (node is IDictionary) { return new ObjectNavigatorStateDictionary(context, parent, node, name); } else if (node is IList) { return new ObjectNavigatorStateList(context, parent, node, name); } else { return new ObjectNavigatorStateItem(context, parent, node, name); } } } } --- NEW FILE: ObjectNavigatorStateDictionary.cs --- #region license // Bamboo.Prevalence - a .NET object prevalence engine // Copyright (C) 2004 Rodrigo B. de Oliveira // // Based on the original concept and implementation of Prevayler (TM) // by Klaus Wuestefeld. Visit http://www.prevayler.org for details. // // 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. // // Contact Information // // http://bbooprevalence.sourceforge.net // mailto:rod...@us... #endregion using System; using System.Collections; using System.Xml; using System.Xml.XPath; namespace Adapdev.XPath.Internal { internal class ObjectNavigatorStateDictionary : ObjectNavigatorState { IDictionary _dictionary; IList _children; internal ObjectNavigatorStateDictionary(ObjectNavigationContext context, ObjectNavigatorState parent, object node, string name) : base(context, parent, node, name) { _dictionary = (IDictionary)node; _children = new ArrayList(_dictionary.Keys); } internal override XPathNodeType NodeType { get { return XPathNodeType.Element; } } internal override ObjectNavigatorState MoveToFirstChild() { return MoveToChild(0); } internal override ObjectNavigatorState MoveToNext() { return _parent.MoveToChild(_index + 1); } internal override ObjectNavigatorState MoveToChild(int index) { while (index < _children.Count) { object key = _children[index]; object child = _dictionary[key]; if (null != child) { ObjectNavigatorState state = CreateElementState(_context, this, child, key.ToString()); state.Index = index; return state; } ++index; } return null; } } } --- NEW FILE: ObjectNavigatorStateItem.cs --- #region license // Bamboo.Prevalence - a .NET object prevalence engine // Copyright (C) 2004 Rodrigo B. de Oliveira // // Based on the original concept and implementation of Prevayler (TM) // by Klaus Wuestefeld. Visit http://www.prevayler.org for details. // // 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. // // Contact Information // // http://bbooprevalence.sourceforge.net // mailto:rod...@us... #endregion using System; using System.Xml; using System.Xml.XPath; using System.Reflection; namespace Adapdev.XPath.Internal { internal class ObjectNavigatorStateItem : ObjectNavigatorState { IValueProvider[] _children; internal ObjectNavigatorStateItem(ObjectNavigationContext context, ObjectNavigatorState parent, object node, string name) : base(context, parent, node, name) { } internal override XPathNodeType NodeType { get { return XPathNodeType.Element; } } internal override ObjectNavigatorState MoveToFirstChild() { return MoveToChild(0); } internal override ObjectNavigatorState MoveToNext() { return _parent.MoveToChild(_index + 1); } internal override ObjectNavigatorState MoveToChild(int index) { CheckChildren(); while (index < _children.Length) { object child = _children[index].GetValue(_node); if (null != child) { ObjectNavigatorState state = CreateElementState(_context, this, child, _children[index].Name); state.Index = index; return state; } ++index; } return null; } void CheckChildren() { if (null != _children) { return; } _children = _context.TypeInfoCache.GetNavigableProperties(_node); } } } --- NEW FILE: ObjectNavigatorStateList.cs --- #region license // Bamboo.Prevalence - a .NET object prevalence engine // Copyright (C) 2004 Rodrigo B. de Oliveira // // Based on the original concept and implementation of Prevayler (TM) // by Klaus Wuestefeld. Visit http://www.prevayler.org for details. // // 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. // // Contact Information // // http://bbooprevalence.sourceforge.net // mailto:rod...@us... #endregion using System; using System.Collections; using System.Xml; using System.Xml.XPath; namespace Adapdev.XPath.Internal { internal class ObjectNavigatorStateList : ObjectNavigatorState { IList _children; internal ObjectNavigatorStateList(ObjectNavigationContext context, ObjectNavigatorState parent, object node, string name) : base(context, parent, node, name) { _children = (IList)node; } internal override XPathNodeType NodeType { get { return XPathNodeType.Element; } } internal override ObjectNavigatorState MoveToFirstChild() { return MoveToChild(0); } internal override ObjectNavigatorState MoveToNext() { return _parent.MoveToChild(_index + 1); } internal override ObjectNavigatorState MoveToChild(int index) { while (index < _children.Count) { object child = _children[index]; if (null != child) { ObjectNavigatorState state = CreateElementState(_context, this, child, child.GetType().Name); state.Index = index; return state; } ++index; } return null; } } } --- NEW FILE: ObjectNavigatorStateRoot.cs --- #region license // Bamboo.Prevalence - a .NET object prevalence engine // Copyright (C) 2004 Rodrigo B. de Oliveira // // Based on the original concept and implementation of Prevayler (TM) // by Klaus Wuestefeld. Visit http://www.prevayler.org for details. // // 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. // // Contact Information // // http://bbooprevalence.sourceforge.net // mailto:rod...@us... #endregion using System; using System.Xml; using System.Xml.XPath; namespace Adapdev.XPath.Internal { internal class ObjectNavigatorStateRoot : ObjectNavigatorState { ObjectNavigatorState _child; internal ObjectNavigatorStateRoot(ObjectNavigationContext context, object node, string nodeName) : base(context, null, node, "#document") { if (null == nodeName) { nodeName = _node.GetType().Name; } _child = CreateElementState(context, this, node, nodeName); } internal override ObjectNavigatorState MoveToFirstChild() { return _child; } internal override XPathNodeType NodeType { get { return XPathNodeType.Root; } } } } |
From: Sean M. <int...@us...> - 2005-06-03 04:33:12
|
Update of /cvsroot/adapdev/Adapdev/src/Adapdev/Text/Indexing/FullText/Tokenizers In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26938/src/Adapdev/Text/Indexing/FullText/Tokenizers Added Files: NullTokenizer.cs StringTokenizer.cs Log Message: --- NEW FILE: StringTokenizer.cs --- #region license // Bamboo.Prevalence - a .NET object prevalence engine // Copyright (C) 2004 Rodrigo B. de Oliveira // // Based on the original concept and implementation of Prevayler (TM) // by Klaus Wuestefeld. Visit http://www.prevayler.org for details. // // 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. // // Contact Information // // http://bbooprevalence.sourceforge.net // mailto:rod...@us... #endregion using System; using Adapdev.Text.Indexing.FullText; namespace Adapdev.Text.Indexing.FullText.Tokenizers { /// <summary> /// Splits a string into tokens by considering any /// whitespace and punctuation characters as separators. /// </summary> /// <remarks> /// This tokenizer must always be the last in a /// tokenizer chain. /// </remarks> [Serializable] public class StringTokenizer : ITokenizer { string _text; int _current; /// <summary> /// Creates a new tokenizer for the string /// in the text argument. /// </summary> /// <param name="text">token source</param> public StringTokenizer(string text) : this(text, 0) { } /// <summary> /// Creates a new tokenizer for the string /// in the text argument starting from /// the position indicated by the current /// argument. /// </summary> /// <param name="text">token source</param> /// <param name="current">starting position</param> protected StringTokenizer(string text, int current) { if (null == text) { throw new ArgumentNullException("text", "text can't be null"); } _text = text; _current = current; } #region Implementation of ITokenizer /// <summary> /// Always returns null since this tokenizer /// must be the last in the chain. /// </summary> public ITokenizer Previous { get { return null; } set { throw new NotSupportedException("ITokenizer chaining not supported by StringTokenizer!"); } } /// <summary> /// See <see cref="Adapdev.Text.Indexing.FullText.ITokenizer.NextToken"/> for /// details. /// </summary> /// <returns></returns> public Adapdev.Text.Indexing.FullText.Token NextToken() { SkipSeparators(); int begin = _current; for (; _current<_text.Length; ++_current) { if (IsSeparator(_text, _current)) { break; } } if (_current > begin) { return new Token(_text.Substring(begin, _current-begin), begin); } return null; } /// <summary> /// Returns a clone. /// </summary> /// <param name="tail">must always be null</param> /// <returns>a clone</returns> public ITokenizer Clone(ITokenizer tail) { if (null != tail) { throw new NotSupportedException("ITokenizer chaining not supported by StringTokenizer!"); } return new StringTokenizer(_text, _current); } #endregion void SkipSeparators() { for (; _current<_text.Length; ++_current) { if (!IsSeparator(_text, _current)) { break; } } } bool IsSeparator(string text, int index) { char current = text[index]; return Char.IsWhiteSpace(current) || Char.IsPunctuation(current); } } } --- NEW FILE: NullTokenizer.cs --- #region license // Bamboo.Prevalence - a .NET object prevalence engine // Copyright (C) 2004 Rodrigo B. de Oliveira // // Based on the original concept and implementation of Prevayler (TM) // by Klaus Wuestefeld. Visit http://www.prevayler.org for details. // // 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. // // Contact Information // // http://bbooprevalence.sourceforge.net // mailto:rod...@us... #endregion using System; using Adapdev.Text.Indexing.FullText; namespace Adapdev.Text.Indexing.FullText.Tokenizers { /// <summary> /// Summary description for NullTokenizer. /// </summary> public class NullTokenizer : ITokenizer { /// <summary> /// The one and only NullTokenizer instance. /// </summary> public static ITokenizer Instance = new NullTokenizer(); private NullTokenizer() { } #region Implementation of ITokenizer /// <summary> /// Always returns null since this tokenizer /// must be the last in the chain. /// </summary> public ITokenizer Previous { get { return null; } set { throw new NotSupportedException("ITokenizer chaining not supported by NullTokenizer!"); } } /// <summary> /// See <see cref="Adapdev.Text.Indexing.FullText.ITokenizer.NextToken"/> for /// details. /// </summary> /// <returns></returns> public Adapdev.Text.Indexing.FullText.Token NextToken() { return null; } /// <summary> /// Returns this. /// </summary> /// <param name="tail">must always be null</param> /// <returns>a clone</returns> public ITokenizer Clone(ITokenizer tail) { return this; } #endregion } } |
From: Sean M. <int...@us...> - 2005-06-03 04:33:12
|
Update of /cvsroot/adapdev/Adapdev/src/Adapdev.Tests/Text/Indexing In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26938/src/Adapdev.Tests/Text/Indexing Added Files: FullTextSearchTests.cs RegExFilterTest.cs SearchResultTest.cs SpecialCharactersFilterTest.cs StringTokenizerTest.cs TokenAssertions.cs TokenLengthFilterTest.cs WordFilterTest.cs Log Message: --- NEW FILE: RegExFilterTest.cs --- #region license // Bamboo.Prevalence - a .NET object prevalence engine // Copyright (C) 2004 Rodrigo B. de Oliveira // // Based on the original concept and implementation of Prevayler (TM) // by Klaus Wuestefeld. Visit http://www.prevayler.org for details. // // 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. // // Contact Information // // http://bbooprevalence.sourceforge.net // mailto:rod...@us... #endregion using System; using NUnit.Framework; using Adapdev.Text.Indexing.FullText; using Adapdev.Text.Indexing.FullText.Filters; using Adapdev.Text.Indexing.FullText.Tokenizers; namespace Adapdev.Text.Indexing.Tests { /// <summary> /// Summary description for RegExFilterTest. /// </summary> [TestFixture] public class RegExFilterTest { RegexTokenFilter _filter; [SetUp] public void SetUp() { _filter = new RegexTokenFilter(@"[0-9]+\w*"); } [Test] public void TestSerializable() { _filter = (RegexTokenFilter)TokenAssertions.SerializeDeserialize(_filter); TestSimpleRegex(); } [Test] public void TestSimpleRegex() { TokenAssertions.AssertTokens("a token, 100 23 1g 144kg other token", _filter, new Token("a", 0), new Token("token", 2), new Token("other", 25), new Token("token", 31), null ); } } } --- NEW FILE: StringTokenizerTest.cs --- #region license // Bamboo.Prevalence - a .NET object prevalence engine // Copyright (C) 2004 Rodrigo B. de Oliveira // // Based on the original concept and implementation of Prevayler (TM) // by Klaus Wuestefeld. Visit http://www.prevayler.org for details. // // 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. // // Contact Information // // http://bbooprevalence.sourceforge.net // mailto:rod...@us... #endregion using System; using NUnit.Framework; using Adapdev.Text.Indexing.FullText; using Adapdev.Text.Indexing.FullText.Tokenizers; namespace Adapdev.Text.Indexing.Tests { /// <summary> /// Tests for the StringTokenizer class. /// </summary> [TestFixture] public class StringTokenizerTest : Assertion { [Test] public void TestSimpleStrings() { string text = "a foo Bar a�a\n45\n\n\n"; TokenAssertions.AssertTokens(new StringTokenizer(text), new Token("a", 0), new Token("foo", 2), new Token("Bar", 6), new Token("a�a", 10), new Token("45", 14), null ); TokenAssertions.AssertTokens(new StringTokenizer(""), (Token)null); TokenAssertions.AssertTokens(new StringTokenizer("\n\t "), (Token)null); TokenAssertions.AssertTokens(new StringTokenizer("\n\t a"), new Token("a", 4), null); } [Test] public void TestPunctuation() { string text = "A foo,bar goest! flu? Oh, yes, flu!!! really? yep.\n.\tdidn't think [so..(yep)"; TokenAssertions.AssertTokenValues(new StringTokenizer(text), "A", "foo", "bar", "goest", "flu", "Oh", "yes", "flu", "really", "yep", "didn", "t", "think", "so", "yep" ); } [Test] [ExpectedException(typeof(ArgumentNullException))] public void TestNullValues() { StringTokenizer tokenizer = new StringTokenizer(null); } } } --- NEW FILE: TokenAssertions.cs --- #region license // Bamboo.Prevalence - a .NET object prevalence engine // Copyright (C) 2004 Rodrigo B. de Oliveira // // Based on the original concept and implementation of Prevayler (TM) // by Klaus Wuestefeld. Visit http://www.prevayler.org for details. // // 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. // // Contact Information // // http://bbooprevalence.sourceforge.net // mailto:rod...@us... #endregion using System; using System.IO; using System.Runtime.Serialization.Formatters.Binary; using NUnit.Framework; using Adapdev.Text.Indexing.FullText; using Adapdev.Text.Indexing.FullText.Tokenizers; namespace Adapdev.Text.Indexing.Tests { /// <summary> /// Summary description for TokenAssertions. /// </summary> public class TokenAssertions { public static void AssertTokens(string text, ITokenFilter filter, params Token[] tokens) { AssertTokens(new StringTokenizer(text), filter, tokens); } public static void AssertTokens(ITokenizer tokenizer, ITokenFilter filter, params Token[] tokens) { ITokenizer actual = filter.Clone(tokenizer); foreach (Token expected in tokens) { Assertion.AssertEquals(expected, actual.NextToken()); } } public static void AssertTokens(ITokenizer tokenizer, params Token[] tokens) { foreach (Token expected in tokens) { Assertion.AssertEquals(expected, tokenizer.NextToken()); } } public static void AssertTokenValues(ITokenizer tokenizer, params string[] expectedValues) { foreach (string value in expectedValues) { Assertion.AssertEquals(value, tokenizer.NextToken().Value); } Assertion.AssertNull(tokenizer.NextToken()); } public static void AssertTokenValues(string text, ITokenFilter filter, params string[] expectedValues) { ITokenizer tokenizer = filter.Clone(new StringTokenizer(text)); AssertTokenValues(tokenizer, expectedValues); } public static object SerializeDeserialize(object graph) { BinaryFormatter formatter = new BinaryFormatter(); MemoryStream stream = new MemoryStream(); formatter.Serialize(stream, graph); stream.Position = 0; return formatter.Deserialize(stream); } } } --- NEW FILE: SearchResultTest.cs --- #region license // Bamboo.Prevalence - a .NET object prevalence engine // Copyright (C) 2004 Rodrigo B. de Oliveira // // Based on the original concept and implementation of Prevayler (TM) // by Klaus Wuestefeld. Visit http://www.prevayler.org for details. // // 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. // // Contact Information // // http://bbooprevalence.sourceforge.net // mailto:rod...@us... #endregion using System; using NUnit.Framework; using Adapdev.Text.Indexing; using Adapdev.Text.Indexing.Records; namespace Adapdev.Text.Indexing.Tests { class AgeFilter : ISearchHitFilter { int _min; int _max; public AgeFilter(int min, int max) { _min = min; _max = max; } public bool Test(SearchHit hit) { int age = (int)hit.Record["Age"]; return (age >= _min && age <= _max); } } class NameComparer : System.Collections.IComparer { public int Compare(object a, object b) { HashtableRecord r1 = (HashtableRecord)a; HashtableRecord r2 = (HashtableRecord)b; return ((IComparable)r1["Name"]).CompareTo(r2["Name"]); } } /// <summary> /// Summary description for SearchResultTest. /// </summary> [TestFixture] public class SearchResultTest : Assertion { HashtableRecord _record1; HashtableRecord _record2; HashtableRecord _record3; SearchResult _result; [SetUp] public void SetUp() { _record1 = CreateRecord("Teresa", 43); _record2 = CreateRecord("M�rcia", 26); _record3 = CreateRecord("Bamboo", 27); _result = new SearchResult(); _result.Add(new SearchHit(_record1)); _result.Add(new SearchHit(_record2)); _result.Add(new SearchHit(_record3)); } [Test] public void TestToRecordArray() { HashtableRecord[] records = (HashtableRecord[])_result.ToRecordArray(typeof(HashtableRecord)); AssertEquals(3, records.Length); AssertSame(_record1, records[0]); AssertSame(_record2, records[1]); AssertSame(_record3, records[2]); } [Test] public void TestSortByField() { _result.SortByField("Name"); AssertSearchHits(_result, _record3, _record2, _record1); _result.SortByField("Age"); AssertSearchHits(_result, _record2, _record3, _record1); } [Test] public void TestSort() { _result.Sort(new NameComparer()); AssertSearchHits(_result, _record3, _record2, _record1); } [Test] public void TestFilter() { AssertSearchHits(_result.Filter(new AgeFilter(25, 28)), _record2, _record3); } [Test] public void TestIntersect() { SearchResult other = new SearchResult(); other.Add(new SearchHit(_record3)); other.Add(new SearchHit(_record1)); AssertSearchHits(_result.Intersect(other), _record1, _record3); other = new SearchResult(); other.Add(new SearchHit(_record2)); AssertSearchHits(_result.Intersect(other), _record2); AssertEquals(0, _result.Intersect(new SearchResult()).Count); AssertSearchHits(_result.Intersect(_result), _record1, _record2, _record3); } [Test] public void TestForEach() { int i=0; IRecord[] expected = { _record1, _record2, _record3 }; foreach (SearchHit hit in _result) { AssertEquals(expected[i++], hit.Record); } } void AssertSearchHits(SearchResult result, params IRecord[] expectedRecords) { AssertEquals(expectedRecords.Length, result.Count); for (int i=0; i<expectedRecords.Length; ++i) { IRecord expected = expectedRecords[i]; IRecord actual = result[i].Record; AssertEquals(string.Format("{0} != {1}", expected["Name"], actual["Name"]), expected, actual); } } HashtableRecord CreateRecord(string name, int age) { HashtableRecord record = new HashtableRecord(); record["Name"] = name; record["Age"] = age; return record; } } } --- NEW FILE: TokenLengthFilterTest.cs --- #region license // Bamboo.Prevalence - a .NET object prevalence engine // Copyright (C) 2004 Rodrigo B. de Oliveira // // Based on the original concept and implementation of Prevayler (TM) // by Klaus Wuestefeld. Visit http://www.prevayler.org for details. // // 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. // // Contact Information // // http://bbooprevalence.sourceforge.net // mailto:rod...@us... #endregion using System; using NUnit.Framework; using Adapdev.Text.Indexing.FullText; using Adapdev.Text.Indexing.FullText.Filters; namespace Adapdev.Text.Indexing.Tests { /// <summary> /// Summary description for TokenLengthFilterTest. /// </summary> [TestFixture] public class TokenLengthFilterTest { [Test] public void TestFilter() { string text = "a bc dado de o"; TokenAssertions.AssertTokenValues(text, new TokenLengthFilter(1), "a", "bc", "dado", "de", "o" ); TokenAssertions.AssertTokenValues(text, new TokenLengthFilter(2), "bc", "dado", "de" ); TokenAssertions.AssertTokenValues(text, new TokenLengthFilter(3), "dado" ); TokenAssertions.AssertTokenValues(text, new TokenLengthFilter(4), "dado" ); } } } --- NEW FILE: SpecialCharactersFilterTest.cs --- #region license // Bamboo.Prevalence - a .NET object prevalence engine // Copyright (C) 2004 Rodrigo B. de Oliveira // // Based on the original concept and implementation of Prevayler (TM) // by Klaus Wuestefeld. Visit http://www.prevayler.org for details. // // 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. // // Contact Information // // http://bbooprevalence.sourceforge.net // mailto:rod...@us... #endregion using System; using NUnit.Framework; using Adapdev.Text.Indexing.FullText; using Adapdev.Text.Indexing.FullText.Filters; using Adapdev.Text.Indexing.FullText.Tokenizers; namespace Adapdev.Text.Indexing.Tests { /// <summary> /// Summary description for SpecialCharactersFilterTest. /// </summary> [TestFixture] public class SpecialCharactersFilterTest { [Test] public void TestReplacements() { string text = "áéÃóú calção aviões aiouao"; TokenAssertions.AssertTokens(text, new SpecialCharactersFilter(), new Token("aeiou", 0), new Token("calcao", 6), new Token("avioes", 13), new Token("aiouao", 20), null ); } } } --- NEW FILE: WordFilterTest.cs --- #region license // Bamboo.Prevalence - a .NET object prevalence engine // Copyright (C) 2004 Rodrigo B. de Oliveira // // Based on the original concept and implementation of Prevayler (TM) // by Klaus Wuestefeld. Visit http://www.prevayler.org for details. // // 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. // // Contact Information // // http://bbooprevalence.sourceforge.net // mailto:rod...@us... #endregion using System; using NUnit.Framework; using Adapdev.Text.Indexing.FullText; using Adapdev.Text.Indexing.FullText.Filters; namespace Adapdev.Text.Indexing.Tests { /// <summary> /// Summary description for WordFilterTest. /// </summary> [TestFixture] public class WordFilterTest : Assertion { [Test] public void TestFilter() { string[] filteredWords = { "de", "com" }; string text = "Bolo de chocolate com calda de morango"; TokenAssertions.AssertTokens(text, new WordFilter(filteredWords), new Token("Bolo", 0), new Token("chocolate", 8), new Token("calda", 22), new Token("morango", 31), null); } [Test] public void TestWordFilterChaining() { string[] filteredWords = { "de", "com" }; string text = "Bolo dé Açafrão com Rúcula"; TokenAssertions.AssertTokens(text, new WordFilter(new SpecialCharactersFilter(), filteredWords), new Token("bolo", 0), new Token("acafrao", 8), new Token("rucula", 20), null ); } } } --- NEW FILE: FullTextSearchTests.cs --- #region license // Bamboo.Prevalence - a .NET object prevalence engine // Copyright (C) 2004 Rodrigo B. de Oliveira // // Based on the original concept and implementation of Prevayler (TM) // by Klaus Wuestefeld. Visit http://www.prevayler.org for details. // // 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. // // Contact Information // // http://bbooprevalence.sourceforge.net // mailto:rod...@us... #endregion using System; using NUnit.Framework; using Adapdev.Text.Indexing; using Adapdev.Text.Indexing.FullText; using Adapdev.Text.Indexing.Records; namespace Adapdev.Text.Indexing.Tests { /// <summary> /// Test cases for the fulltext indexing/search support. /// </summary> [TestFixture] public class FullTextSearchTests : Assertion { IIndex _index; IIndex _multipleFieldIndex; HashtableRecord _record1; HashtableRecord _record2; HashtableRecord _record3; [SetUp] public void SetUp() { FullTextSearchIndex index = new FullTextSearchIndex(); index.Fields.Add("Title"); FullTextSearchIndex multipleFieldIndex = new FullTextSearchIndex(); multipleFieldIndex.Fields.Add("Title"); multipleFieldIndex.Fields.Add("Ingredients"); _index = index; _multipleFieldIndex = multipleFieldIndex; _record1 = new HashtableRecord(); _record1["Title"] = "Bolo de Chocolate"; _record1["Calories"] = 300; _record1["Ingredients"] = "3 colheres de açucar\n1 lata de nescau\nfermento"; _index.Add(_record1); _multipleFieldIndex.Add(_record1); DumpPostings(index.Postings); _record2 = new HashtableRecord(); _record2["Title"] = "Bolo de Açafrão"; _record2["Calories"] = 100; _record2["Ingredients"] = "10 folhas de açafrão\n1 colher de fermento em pó"; _index.Add(_record2); _multipleFieldIndex.Add(_record2); DumpPostings(index.Postings); _record3 = new HashtableRecord(); _record3["Title"] = "Torta de Chocolate"; _record3["Calories"] = 400; _record3["Ingredients"] = "1 lata de nescau\nchocolate granulado\naçucar"; _index.Add(_record3); _multipleFieldIndex.Add(_record3); DumpPostings(index.Postings); } [Test] public void TestClear() { _index.Clear(); AssertEquals(0, ((FullTextSearchIndex)_index).Records.Length); AssertEquals(0, ((FullTextSearchIndex)_index).Postings.Length); AssertSearchContains(_index.Search(new FullTextSearchExpression("chocolate"))); } [Test] public void TestSimpleSearch() { ISearchExpression expression = new FullTextSearchExpression("bolo"); AssertSearchContains(_index.Search(expression), _record1, _record2); expression = new FullTextSearchExpression("chocolate"); AssertSearchContains(_index.Search(expression), _record1, _record3); expression = new FullTextSearchExpression("acafrão"); AssertSearchContains(_index.Search(expression), _record2); expression = new FullTextSearchExpression("bolo AcaFrao"); AssertSearchContains(_index.Search(expression), _record1, _record2); } [Test] public void TestMultiIndexSimpleSearch() { ISearchExpression expression = new FullTextSearchExpression("nescau"); AssertSearchContains(_multipleFieldIndex.Search(expression), _record1, _record3); expression = new FullTextSearchExpression("chocolate"); AssertSearchContains(_multipleFieldIndex.Search(expression), _record1, _record3); expression = new FullTextSearchExpression("fermento"); AssertSearchContains(_multipleFieldIndex.Search(expression), _record1, _record2); } [Test] public void TestIncludeAllSearch() { ISearchExpression expression = new FullTextSearchExpression("Bolo Chocolate", FullTextSearchMode.IncludeAll); AssertSearchContains(_index.Search(expression), _record1); AssertSearchContains(_multipleFieldIndex.Search(expression), _record1); expression = new FullTextSearchExpression("Bolo Açafrão", FullTextSearchMode.IncludeAll); AssertSearchContains(_index.Search(expression), _record2); AssertSearchContains(_multipleFieldIndex.Search(expression), _record2); expression = new FullTextSearchExpression("Torta Chocolate", FullTextSearchMode.IncludeAll); AssertSearchContains(_index.Search(expression), _record3); AssertSearchContains(_multipleFieldIndex.Search(expression), _record3); } [Test] public void TestMultiIndexIncludeAllSearch() { AssertSearchContains( _multipleFieldIndex.Search(new FullTextSearchExpression("bolo nescau", FullTextSearchMode.IncludeAll)), _record1 ); AssertSearchContains( _multipleFieldIndex.Search(new FullTextSearchExpression("torta nescau", FullTextSearchMode.IncludeAll)), _record3 ); AssertSearchContains( _multipleFieldIndex.Search(new FullTextSearchExpression("bolo fermento", FullTextSearchMode.IncludeAll)), _record1, _record2 ); } [Test] public void TestRemove() { _index.Remove(_record1); _multipleFieldIndex.Remove(_record1); AssertSearchContains( _index.Search(new FullTextSearchExpression("bolo chocolate")), _record2, _record3 ); AssertSearchContains( _multipleFieldIndex.Search(new FullTextSearchExpression("açucar")), _record3 ); } [Test] [ExpectedException(typeof(ArgumentException))] public void TestInvalidSearchExpression() { // this search is invalid because // the default filter should only let // pass tokens longer // than 2 characters _index.Search(new FullTextSearchExpression("de")); } [Test] public void TestUpdate() { _record1["Title"] = "Torta de Salsinha"; _index.Update(_record1); _multipleFieldIndex.Update(_record1); ISearchExpression expression = new FullTextSearchExpression("torta salsinha"); AssertSearchContains(_index.Search(expression), _record1, _record3); AssertSearchContains(_multipleFieldIndex.Search(expression), _record1, _record3); } [Test] public void TestIndexSerialization() { _index = TokenAssertions.SerializeDeserialize(_index) as IIndex; FullTextSearchIndex index = _index as FullTextSearchIndex; IRecord[] records = index.Records; AssertEquals(3, records.Length); _record1 = FindByTitle(records, (string)_record1["Title"]); _record2 = FindByTitle(records, (string)_record2["Title"]); _record3 = FindByTitle(records, (string)_record3["Title"]); TestSimpleSearch(); } HashtableRecord FindByTitle(IRecord[] records, string title) { foreach (HashtableRecord record in records) { if (((string)record["Title"]) == title) { return record; } } throw new ArgumentException("Record not found!"); } void AssertSearchContains(SearchResult result, params IRecord[] expected) { foreach (IRecord record in expected) { if (!result.Contains(record)) { Fail(string.Format("Expected record \"{0}\"!", record["Title"])); } } AssertEquals("result.Count", expected.Length, result.Count); } void DumpPostings(Postings[] postings) { System.Diagnostics.Trace.WriteLine("\n**************"); foreach (Postings p in postings) { System.Diagnostics.Trace.WriteLine(p.ToString()); } System.Diagnostics.Trace.WriteLine("**************"); } } } |
From: Sean M. <int...@us...> - 2005-06-03 04:33:11
|
Update of /cvsroot/adapdev/Adapdev/src/Adapdev.Tests/XPath In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26938/src/Adapdev.Tests/XPath Added Files: XPathObjectNavigatorTest.cs Log Message: --- NEW FILE: XPathObjectNavigatorTest.cs --- #region license // Bamboo.Prevalence - a .NET object prevalence engine // Copyright (C) 2004 Rodrigo B. de Oliveira // // Based on the original concept and implementation of Prevayler (TM) // by Klaus Wuestefeld. Visit http://www.prevayler.org for details. // // 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. // // Contact Information // // http://bbooprevalence.sourceforge.net // mailto:rod...@us... #endregion using System; using System.Collections; using System.Collections.Specialized; using System.Xml; using System.Xml.XPath; using NUnit.Framework; using Adapdev.XPath; namespace Adapdev.XPath.Tests { public class Address { string _street; short _number; public Address(string street, short number) { _street = street; _number = number; } public string Street { get { return _street; } } public short Number { get { return _number; } } } public class Product { string _name; StringCollection _categories; public Product(string name) { _name = name; _categories = new StringCollection(); } public string Name { get { return _name; } } public StringCollection Categories { get { return _categories; } } } public class OrderItem { Product _product; int _quantity; public OrderItem(Product product, int quantity) { _product = product; _quantity = quantity; } public Product Product { get { return _product; } } public int Quantity { get { return _quantity; } } } public class Order { Customer _customer; ArrayList _items; public Order(Customer customer) { _customer = customer; _items = new ArrayList(); } public Customer Customer { get { return _customer; } } public OrderItem[] Items { get { return (OrderItem[])_items.ToArray(typeof(OrderItem)); } } public void Add(OrderItem item) { _items.Add(item); } } public class Customer { string _fname; string _lname; Address _address; IDictionary _properties; public string Email; public Customer(string fname, string lname, Address address) { _fname = fname; _lname = lname; _address = address; _properties = new Hashtable(); } public IDictionary Properties { get { return _properties; } } public Address Address { get { return _address; } } public string FirstName { get { return _fname; } } public string LastName { get { return _lname; } } } /// <summary> /// Summary description for Class1. /// </summary> [TestFixture] public class XPathObjectNavigatorTest : Assertion { [Test] public void TestSimpleProperties() { Address address = new Address("Al. Calder�o Branco", 784); Customer customer = new Customer("Rodrigo", "Oliveira", address); XPathObjectNavigator context = new XPathObjectNavigator(customer); XPathNodeIterator i = context.Select("/Customer/Address/Street"); AssertEquals(1, i.Count); AssertEquals(true, i.MoveNext()); AssertEquals(customer.Address.Street, i.Current.Value); AssertEquals(customer.Address.Street, ((XPathObjectNavigator)i.Current).Node); i = context.Select("FirstName"); AssertEquals(1, i.Count); AssertEquals(true, i.MoveNext()); AssertEquals(customer.FirstName, i.Current.Value); i = context.Select("/Customer/LastName"); AssertEquals(true, i.MoveNext()); AssertEquals(customer.LastName, i.Current.Value); } [Test] public void TestIListProperties() { Product p1 = new Product("egg"); Product p2 = new Product("Monty Python Flying Circus Box"); p2.Categories.Add("Silly Stuff"); Customer c1 = new Customer("Rodrigo", "Oliveira", new Address("Al. Ribeir�o Preto", 487)); Customer c2 = new Customer("Marcia", "Longo", new Address("Al. Ribeir�o Preto", 487)); Order o1 = new Order(c1); o1.Add(new OrderItem(p1, 10)); o1.Add(new OrderItem(p2, 1)); Order o2 = new Order(c2); o2.Add(new OrderItem(p1, 15)); o2.Add(new OrderItem(p2, 1)); Order[] orders = new Order[] { o1, o2 }; XPathObjectNavigator navigator = new XPathObjectNavigator(orders, "Orders"); AssertEquals(2, navigator.Select("//Order").Count); AssertEquals(2, navigator.Select("Order").Count); AssertEquals(o1, navigator.SelectObject("Order[1]")); AssertEquals(o2, navigator.SelectObject("Order[2]")); AssertEquals(o1, navigator.SelectObject("//Order[Customer/FirstName='Rodrigo']")); AssertEquals(o2, navigator.SelectObject("//Order[Customer/LastName='Longo']")); XPathNodeIterator i = navigator.Select("//Product[Name='egg']"); AssertEquals(2, i.Count); AssertEquals(true, i.MoveNext()); AssertEquals(p1, ((XPathObjectNavigator)i.Current).Node); AssertEquals(o2.Items[0], navigator.SelectObject("//OrderItem[Quantity>10]")); AssertEquals(p2, navigator.SelectObject("//Product[Categories/String='Silly Stuff']")); } [Test] public void TestIDictionaryProperties() { Customer customer = new Customer("Rodrigo", "Oliveira", new Address("Penny Lane", 64)); customer.Properties["email"] = "rod...@us..."; XPathObjectNavigator navigator = new XPathObjectNavigator(customer); AssertEquals(customer.Properties["email"], navigator.SelectObject("Properties/email")); } [Test] public void TestSelectObjects() { Address address = new Address("Strawberry Street", 45); Customer customer1 = new Customer("Rodrigo", "Oliveira", address); Customer customer2 = new Customer("Marcia", "Longo", address); Customer[] customers = { customer1, customer2 }; XPathObjectNavigator navigator = new XPathObjectNavigator(customers); object[] actual = navigator.SelectObjects("Customer[Address/Number = 45]"); AssertEquals(2, actual.Length); AssertEquals(customer1, actual[0]); AssertEquals(customer2, actual[1]); } [Test] public void TestSelectByField() { Customer customer1 = new Customer("Rodrigo", "Oliveira", new Address("al. Calder�o Branco", 45)); customer1.Email = "rb...@ac..."; XPathObjectNavigator navigator = new XPathObjectNavigator(customer1); AssertSame(customer1.Email, navigator.SelectObject("Email")); AssertSame(customer1, navigator.SelectObject("/Customer[Email='rb...@ac...']")); } } } |
From: Sean M. <int...@us...> - 2005-06-03 04:33:08
|
Update of /cvsroot/adapdev/Adapdev/src/Adapdev.Tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26938/src/Adapdev.Tests Added Files: CompositeValidatorTest.cs IValidatorTest.cs ObjectComparerTest.cs Log Message: --- NEW FILE: CompositeValidatorTest.cs --- using System; using System.Collections; using NUnit.Framework; using Adapdev; namespace Adapdev.Tests { /// <summary> /// Summary description for IValidatable. /// </summary> /// [TestFixture] public class CompositeValidatorTest { public static string BadHeightMessage = "Height must be greater than zero."; public static string BadWidthMessage = "Width must be greater than zero."; public static string NoSquareMessage = "Must be a rectangle, not a square. Please use the Square object for squares."; [Test] public void Invalid() { Rectangle rectangle = new Rectangle(); rectangle.Height = 2; rectangle.Width = 2; ValidationResult vr = rectangle.Validate(); Console.WriteLine(vr.Message); Assert.IsFalse(vr.IsValid, "Object should not be valid."); Assert.IsTrue(vr.Message.Length > 0); Assert.IsTrue(vr.Message.IndexOf(CompositeValidatorTest.NoSquareMessage) >= 0); Assert.AreEqual(CompositeValidatorTest.NoSquareMessage + Environment.NewLine + Environment.NewLine, vr.Message); } [Test] public void Valid() { Rectangle rectangle = new Rectangle(); rectangle.Height = 3; rectangle.Width = 2; ValidationResult vr = rectangle.Validate(); Assert.IsTrue(vr.IsValid); Assert.IsTrue(vr.Message.Length == 0, "Object should not have a validation message."); } } public class Rectangle : CompositeValidator { public Rectangle() { this.AddRule(new RectangleNoSquareRule(this)); this.AddRule(new RectangleHeightRule(this)); this.AddRule(new RectangleWidthRule(this)); } public int Height = 0; public int Width = 0; } public class RectangleNoSquareRule : IValidationRule { private Rectangle _rectangle; public RectangleNoSquareRule(Rectangle r) { this._rectangle = r; } #region IValidationRule Members public ValidationResult Validate() { ValidationResult vr = new ValidationResult(); if(this._rectangle.Height == this._rectangle.Width) { vr.IsValid = false; vr.AddMessage(CompositeValidatorTest.NoSquareMessage); } return vr; } #endregion } public class RectangleHeightRule : IValidationRule { #region IValidationRule Members private Rectangle _rectangle; public RectangleHeightRule(Rectangle r) { this._rectangle = r; } public ValidationResult Validate() { ValidationResult vr = new ValidationResult(); if(this._rectangle.Height <= 0) { vr.IsValid = false; vr.AddMessage(CompositeValidatorTest.BadHeightMessage); } return vr; } #endregion } public class RectangleWidthRule : IValidationRule { #region IValidationRule Members private Rectangle _rectangle; public RectangleWidthRule(Rectangle r) { this._rectangle = r; } public ValidationResult Validate() { ValidationResult vr = new ValidationResult(); if(this._rectangle.Width <= 0) { vr.IsValid = false; vr.AddMessage(CompositeValidatorTest.BadWidthMessage); } return vr; } #endregion } } --- NEW FILE: ObjectComparerTest.cs --- using System; using Adapdev.Mock; using NUnit.Framework; namespace Adapdev.Tests { /// <summary> /// Summary description for ObjectComparerTest. /// </summary> /// [TestFixture] public class ObjectComparerTest { [Test] public void AreEqual() { DateTime now = DateTime.Now; SuppliersEntity e1 = new SuppliersEntity(); e1.Address = "Test"; e1.SupplierID = 12; e1.Created = now; SuppliersEntity e2 = new SuppliersEntity(); e2.Address = "Test"; e2.SupplierID = 12; e2.Created = now; Assert.IsTrue(ObjectComparer.AreEqual(e1, e2), "Objects should be equal."); e2.Created = DateTime.Now.AddHours(1); Assert.IsFalse(ObjectComparer.AreEqual(e1, e2), "Objects should not be equal."); } } } --- NEW FILE: IValidatorTest.cs --- using System; using NUnit.Framework; using Adapdev; namespace Adapdev.Tests { /// <summary> /// Summary description for IValidatable. /// </summary> /// [TestFixture] public class IValidatorTest { public static string BadHeightMessage = "Height must be greater than zero."; public static string BadWidthMessage = "Width must be greater than zero."; [Test] public void Invalid() { Square square = new Square(); square.Height = -1; square.Width = 0; ValidationResult vr = square.Validate(); Console.WriteLine(vr.Message); Assert.IsFalse(vr.IsValid, "Object should not be valid."); Assert.IsTrue(vr.Message.Length > 0); Assert.IsTrue(vr.Message.IndexOf(IValidatorTest.BadHeightMessage) >= 0); Assert.IsTrue(vr.Message.IndexOf(IValidatorTest.BadWidthMessage) >= 0); } [Test] public void Valid() { Square square = new Square(); square.Height = 2; square.Width = 2; ValidationResult vr = square.Validate(); Assert.IsTrue(vr.IsValid); Assert.IsTrue(vr.Message.Length == 0, "Object should not have a validation message."); } } public class Square : IValidator { #region IValidator Members public int Height = 0; public int Width = 0; public ValidationResult Validate() { ValidationResult vr = new ValidationResult(); if(this.Height <= 0) { vr.IsValid = false; vr.AddMessage(IValidatorTest.BadHeightMessage); } if(this.Width <= 0) { vr.IsValid = false; vr.AddMessage(IValidatorTest.BadWidthMessage); } return vr; } #endregion } } |
From: Sean M. <int...@us...> - 2005-06-03 04:31:32
|
Update of /cvsroot/adapdev/Adapdev/src/Adapdev.Tests/Text/Indexing In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25904/Indexing Log Message: Directory /cvsroot/adapdev/Adapdev/src/Adapdev.Tests/Text/Indexing added to the repository |
From: Sean M. <int...@us...> - 2005-06-03 04:31:14
|
Update of /cvsroot/adapdev/Adapdev/src/Adapdev.Tests/Reflection In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25809/Reflection Log Message: Directory /cvsroot/adapdev/Adapdev/src/Adapdev.Tests/Reflection added to the repository |
From: Sean M. <int...@us...> - 2005-06-03 04:31:13
|
Update of /cvsroot/adapdev/Adapdev/src/Adapdev.Tests/XPath In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25809/XPath Log Message: Directory /cvsroot/adapdev/Adapdev/src/Adapdev.Tests/XPath added to the repository |
From: Sean M. <int...@us...> - 2005-06-03 04:31:12
|
Update of /cvsroot/adapdev/Adapdev/src/Adapdev.Tests/Text In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25809/Text Log Message: Directory /cvsroot/adapdev/Adapdev/src/Adapdev.Tests/Text added to the repository |
From: Sean M. <int...@us...> - 2005-06-03 04:30:40
|
Update of /cvsroot/adapdev/Adapdev/src/Adapdev/XPath/Internal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25689/Internal Log Message: Directory /cvsroot/adapdev/Adapdev/src/Adapdev/XPath/Internal added to the repository |
From: Sean M. <int...@us...> - 2005-06-03 04:30:36
|
Update of /cvsroot/adapdev/Adapdev/src/Adapdev/Text/Indexing/FullText/Tokenizers In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25660/Tokenizers Log Message: Directory /cvsroot/adapdev/Adapdev/src/Adapdev/Text/Indexing/FullText/Tokenizers added to the repository |