jedidotnet-commits Mailing List for JEDI.NET (Page 6)
Status: Pre-Alpha
Brought to you by:
jedi_mbe
You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(81) |
Jul
(7) |
Aug
(8) |
Sep
(2) |
Oct
|
Nov
(47) |
Dec
(30) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(32) |
Feb
|
Mar
(86) |
Apr
|
May
(1) |
Jun
(24) |
Jul
(4) |
Aug
(5) |
Sep
(4) |
Oct
|
Nov
|
Dec
(9) |
From: Marcel B. <jed...@us...> - 2005-03-01 15:07:53
|
Update of /cvsroot/jedidotnet/nunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14430/nunit Modified Files: Nunit.Jedi.System.bdsproj Log Message: Invalid character fixed. Weird error. Index: Nunit.Jedi.System.bdsproj =================================================================== RCS file: /cvsroot/jedidotnet/nunit/Nunit.Jedi.System.bdsproj,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Nunit.Jedi.System.bdsproj 1 Mar 2005 14:26:40 -0000 1.8 --- Nunit.Jedi.System.bdsproj 1 Mar 2005 15:07:27 -0000 1.9 *************** *** 180,184 **** <File FileName="source\Jedi.System.Strings.NUnit.pas" ContainerId="" ModuleName="Jedi.System.Strings.NUnit"/> <File FileName="source\Jedi.System.SourceVersioning.NUnit.pas" ContainerId="" ModuleName="Jedi.System.SourceVersioning.NUnit"/> ! <File FileName="source\Jedi.Timers.EventScheduler_NUnit.pas" Contai |
From: Marcel B. <jed...@us...> - 2005-03-01 14:26:57
|
Update of /cvsroot/jedidotnet/nunit/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2369/nunit/source Added Files: Jedi.System.CommandLine.NUnit.pas Log Message: Added test-set for CommandLine parser --- NEW FILE: Jedi.System.CommandLine.NUnit.pas --- unit Jedi.System.CommandLine.NUnit; interface uses Jedi.System.CommandLine, NUnit.Framework, System.Drawing, System.Globalization, System.IO, System.Resources; type ObjectArray = array of &Object; type BaseTestFixture = class strict protected filePath: string; responsesFile1Path: string; strict protected function StoreTo: ObjectArray; virtual; abstract; strict protected function AssemblyOutputPath: string; virtual; abstract; function Optimization: Boolean; virtual; abstract; function SearchPath: string; virtual; abstract; function UnitOutputPath: string; virtual; abstract; public [TestFixtureSetUp] procedure CreateDir; [TestFixtureTearDown] procedure DeleteDir; public [Test] procedure OptionNotSpecified; virtual; [Test] procedure OptionSpecifiedOnce; virtual; [Test] procedure OptionSpecifiedMoreThanOnce; virtual; [Test] procedure OptionSpecifiedMoreThanOnceNoToggle; virtual; [Test] procedure ResponseFile; virtual; end; type InstanceSettings = class public constructor Create; strict private FAssemblyOutputPath: string; FOptimization: Boolean; FSearchPath: string; FUnitOutputPath: string; public [CommandLineArgument(CaseSensitive = False, Name = 'O', Prefix = '-', Prefix = '/')] property Optimization: Boolean read FOptimization write FOptimization; [CommandLineArgument(CaseSensitive = False, Name = 'S', Prefix = '-', Prefix = '/')] property SearchPath: string read FSearchPath write FSearchPath; [CommandLineArgument(CaseSensitive = False, Name = 'OA', Prefix = '-', Prefix = '/')] property AssemblyOutputPath: string read FAssemblyOutputPath write FAssemblyOutputPath; [CommandLineArgument(CaseSensitive = False, Name = 'OU', Prefix = '-', Prefix = '/')] property UnitOutputPath: string read FUnitOutputPath write FUnitOutputPath; end; type [TestFixture] ToInstance = class (BaseTestFixture) strict protected FInstance: InstanceSettings; strict protected function AssemblyOutputPath: string; override; function Optimization: Boolean; override; function SearchPath: string; override; function StoreTo: ObjectArray; override; function UnitOutputPath: string; override; public [SetUp] procedure CreateInstance; [TearDown] procedure DisposeInstance; end; type CompilerSettings = class strict private class constructor Create; strict private class var FOptimization: Boolean; protected class procedure Initialize; public [CommandLineArgument(CaseSensitive = False, Name = 'O', Prefix = '-', Prefix = '/')] class property Optimization: Boolean read FOptimization write FOptimization; end; DirectorySettings = class strict private class constructor Create; strict private class var FAssemblyOutputPath: string; class var FSearchPath: string; class var FUnitOutputPath: string; protected class procedure Initialize; public [CommandLineArgument(CaseSensitive = False, Name = 'OA', Prefix = '-', Prefix = '/')] class property AssemblyOutputPath: string read FAssemblyOutputPath write FAssemblyOutputPath; [CommandLineArgument(CaseSensitive = False, Name = 'S', Prefix = '-', Prefix = '/')] class property SearchPath: string read FSearchPath write FSearchPath; [CommandLineArgument(CaseSensitive = False, Name = 'OU', Prefix = '-', Prefix = '/')] class property UnitOutputPath: string read FUnitOutputPath write FUnitOutputPath; end; type [TestFixture] ToMultipleClasses = class (BaseTestFixture) strict protected function AssemblyOutputPath: string; override; function Optimization: Boolean; override; function SearchPath: string; override; function StoreTo: ObjectArray; override; function UnitOutputPath: string; override; public [SetUp] procedure Initialize; end; type DoubleOptionSettings = class strict private class var FDummy: Integer; public [CommandLineArgument(CaseSensitive = True, Name = 'o', Prefix = '-')] class property Dummy: Integer read FDummy write FDummy; end; type [TestFixture] Errors = class public [Test, ExpectedException(TypeOf(CommandLineException), 'Duplicate command line argument (-o) specified by ' + '''Jedi.System.CommandLine.DoubleOptionSettings.Dummy''. The argument has already been assigned to '+ '''Jedi.System.CommandLine.CompilerSettings.Optimization''')] procedure DoubleOptions; [Test, ExpectedException(TypeOf(CommandLineException), 'Unknown argument: -o')] procedure NoCompilerSettings; [Test, ExpectedException(TypeOf(CommandLineException), 'Unknown argument: -z+')] procedure UnknownArgument; end; type CaseSensitiveSettings = class strict private class var FOptimization: Boolean; class var FOrigin: Integer; public class procedure Initialize; static; public [CommandLineArgument(CaseSensitive = True, Name = 'O', Prefix = '-')] class property Optimization: Boolean read FOptimization write FOptimization; [CommandLineArgument(CaseSensitive = True, Name = 'o', Prefix = '-')] class property Origin: Integer read FOrigin write FOrigin; end; SettingsCustomProcessing = class strict private class var FSize: Size; strict protected [CommandLineArgument(CaseSensitive = False, Name = 'size', Prefix = '-', ValueSeparator = ':', ValueSeparator = '=', ValueSeparator = ' ')] class procedure ProcessSize(match, commandLine: string; var index: Integer); static; public class procedure Initialize; static; public class function get_Height: Integer; static; class function get_Width: Integer; static; class procedure set_Height(value: Integer); static; class procedure set_Width(value: Integer); static; public [CommandLineArgument(CaseSensitive = False, Name = 'height', Prefix = '--', ValueSeparator = ':', ValueSeparator = '=')] class property Height: Integer read get_Height write set_Height; class property Size: Size read FSize write FSize; [CommandLineArgument(CaseSensitive = False, Name = 'width', Prefix = '--', ValueSeparator = ':', ValueSeparator = '=')] class property Width: Integer read get_Width write set_Width; end; [TestFixture] SpecialCases = class public [Test] procedure CaseSensitive; [Test] procedure CustomProcessing; [Test] procedure MixedNormalAndCustom; end; implementation {$AUTOBOX ON} { BaseTestFixture } procedure BaseTestFixture.CreateDir; var rm: ResourceManager; tw: TextWriter; begin filePath := System.String.Join(Path.DirectorySeparatorChar, [Path.GetTempPath, 'Jedi.NET', 'CommandLine tests']); Directory.CreateDirectory(filePath); responsesFile1Path := System.String.Join(Path.DirectorySeparatorChar, [filePath, 'responses1.rsp']); rm := ResourceManager.Create('Jedi.System.CommandLine', TypeOf(BaseTestFixture).Assembly); tw := StreamWriter.Create(responsesFile1Path); tw.Write(rm.GetString('responses1.rsp')); tw.Close; end; procedure BaseTestFixture.DeleteDir; begin Directory.GetParent(filePath).Delete(True); end; procedure BaseTestFixture.OptionNotSpecified; var files: array of string; begin files := CommandLine.Parse( 'process "file to compile.dpk"', StoreTo); Assert.IsFalse(Optimization, 'Optimization option changed.'); Assert.AreEqual('', SearchPath, 'SearchPath has changed.'); Assert.AreEqual('', AssemblyOutputPath, 'AssemblyOutputPath has changed.'); Assert.AreEqual('', UnitOutputPath, 'UnitOutputPath has changed.'); Assert.AreEqual(1, &Array(files).Length, 'wrong number of files returned.'); Assert.AreEqual('file to compile.dpk', files[0], 'Wrong filename.'); end; procedure BaseTestFixture.OptionSpecifiedOnce; var files: array of string; begin files := CommandLine.Parse( 'process -o -sSomePath;NextPath -oa..\Bin -ou"..\Temp Units" file_to_compile.dpk', StoreTo); Assert.IsTrue(Optimization, 'Optimization option not changed.'); Assert.AreEqual('SomePath;NextPath', SearchPath, 'SearchPath has not changed.'); Assert.AreEqual('..\Bin', AssemblyOutputPath, 'AssemblyOutputPath has not changed.'); Assert.AreEqual('..\Temp Units', UnitOutputPath, 'UnitOutputPath has not changed.'); Assert.AreEqual(1, &Array(files).Length, 'wrong number of files returned.'); Assert.AreEqual('file_to_compile.dpk', files[0], 'Wrong filename.'); end; procedure BaseTestFixture.OptionSpecifiedMoreThanOnce; var files: array of string; begin files := CommandLine.Parse( 'process -o -sSomePath;NextPath -oa..\Bin -o -sOtherPath -ou"..\Temp Units" "file to compile.dpk"', StoreTo); Assert.IsFalse(Optimization, 'Optimization option not toggled.'); Assert.AreEqual('OtherPath', SearchPath, 'SearchPath has not changed.'); Assert.AreEqual('..\Bin', AssemblyOutputPath, 'AssemblyOutputPath has not changed.'); Assert.AreEqual('..\Temp Units', UnitOutputPath, 'UnitOutputPath has not changed.'); Assert.AreEqual(1, &Array(files).Length, 'wrong number of files returned.'); Assert.AreEqual('file to compile.dpk', files[0], 'Wrong filename.'); end; procedure BaseTestFixture.OptionSpecifiedMoreThanOnceNoToggle; var files: array of string; begin files := CommandLine.Parse( 'process -o -sSomePath;NextPath -oa..\Bin -o+ -sOtherPath -ou"..\Temp Units" "file to compile.dpk"', StoreTo); Assert.IsTrue(Optimization, 'Optimization option toggled.'); Assert.AreEqual('OtherPath', SearchPath, 'SearchPath has not changed.'); Assert.AreEqual('..\Bin', AssemblyOutputPath, 'AssemblyOutputPath has not changed.'); Assert.AreEqual('..\Temp Units', UnitOutputPath, 'UnitOutputPath has not changed.'); Assert.AreEqual(1, &Array(files).Length, 'wrong number of files returned.'); Assert.AreEqual('file to compile.dpk', files[0], 'Wrong filename.'); end; procedure BaseTestFixture.ResponseFile; var files: array of string; begin files := CommandLine.Parse( System.String.Format('process @"{0}" "file to compile.dpk"', responsesFile1Path), StoreTo, '@'); Assert.IsTrue(Optimization, 'Optimization option not changed.'); Assert.AreEqual('SomePath;NextPath', SearchPath, 'SearchPath has not changed.'); Assert.AreEqual('..\Bin', AssemblyOutputPath, 'AssemblyOutputPath has not changed.'); Assert.AreEqual('..\Temp Units', UnitOutputPath, 'UnitOutputPath has not changed.'); Assert.AreEqual(1, &Array(files).Length, 'wrong number of files returned.'); Assert.AreEqual('file to compile.dpk', files[0], 'Wrong filename.'); end; { CaseSensitiveSettings } class procedure CaseSensitiveSettings.Initialize; begin FOptimization := False; FOrigin := 0; end; { CompilerSettings } class constructor CompilerSettings.Create; begin Initialize; end; class procedure CompilerSettings.Initialize; begin FOptimization := False; end; { DirectorySettings } class constructor DirectorySettings.Create; begin Initialize; end; class procedure DirectorySettings.Initialize; begin FAssemblyOutputPath := ''; FSearchPath := ''; FUnitOutputPath := ''; end; { Errors } procedure Errors.DoubleOptions; begin CommandLine.Parse('process -o123 -ou..\Lib', [TypeOf(CompilerSettings), TypeOf(DirectorySettings), TypeOf(DoubleOptionSettings)]); end; procedure Errors.NoCompilerSettings; begin CommandLine.Parse( 'process -o -sSomePath;NextPath -oa..\Bin -ou"..\Temp Units" file_to_compile.dpk', [TypeOf(DirectorySettings)]); end; procedure Errors.UnknownArgument; begin CommandLine.Parse( 'process /o -z+ "some file.dpk"', [TypeOf(CompilerSettings), TypeOf(DirectorySettings)]); end; { InstanceSettings } constructor InstanceSettings.Create; begin inherited Create; FAssemblyOutputPath := ''; FSearchPath := ''; FUnitOutputPath := ''; end; { SettingsCustomProcessing } class procedure SettingsCustomProcessing.ProcessSize(match, commandLine: string; var index: Integer); var part: string; colonPos: Integer; newWidth: Integer; newHeight: Integer; begin part := Jedi.System.CommandLine.CommandLine.GetLiteral(commandLine, index); colonPos := part.IndexOf(','); if colonPos < 0 then raise CommandLineException.Create(System.String.Format('Invalid value for argument {0}: {1}', match.Trim, part)); if colonPos = 0 then newWidth := FSize.Width else newWidth := System.Int32.Parse(part.Substring(0, colonPos), NumberFormatInfo.InvariantInfo); if colonPos = part.Length - 1 then newHeight := FSize.Height else newHeight := System.Int32.Parse(part.Substring(colonPos + 1), NumberFormatInfo.InvariantInfo); FSize := System.Drawing.Size.Create(newWidth, newHeight); end; class function SettingsCustomProcessing.get_Height: Integer; begin Result := FSize.Height; end; class function SettingsCustomProcessing.get_Width: Integer; begin Result := FSize.Width; end; class procedure SettingsCustomProcessing.Initialize; begin FSize := System.Drawing.Size.Create(0, 0); end; class procedure SettingsCustomProcessing.set_Height(value: Integer); begin FSize := System.Drawing.Size.Create(FSize.Width, value); end; class procedure SettingsCustomProcessing.set_Width(value: Integer); begin FSize := System.Drawing.Size.Create(value, FSize.Height); end; { SpecialCases } procedure SpecialCases.CaseSensitive; begin CaseSensitiveSettings.Initialize; CommandLine.Parse('process -o123 -O+', [TypeOf(CaseSensitiveSettings)]); Assert.AreEqual(123, CaseSensitiveSettings.Origin, 'Origin not set.'); Assert.IsTrue(CaseSensitiveSettings.Optimization, 'Optimization flag not set.'); end; procedure SpecialCases.CustomProcessing; begin SettingsCustomProcessing.Initialize; CommandLine.Parse('process -size=64,32', [TypeOf(SettingsCustomProcessing)]); Assert.AreEqual(64, SettingsCustomProcessing.Width, 'Width not set correctly by -size option.'); Assert.AreEqual(32, SettingsCustomProcessing.Height, 'Height not set correctly by -size option.'); end; procedure SpecialCases.MixedNormalAndCustom; begin SettingsCustomProcessing.Initialize; CommandLine.Parse('process --width:128 -size=,32', [TypeOf(SettingsCustomProcessing)]); Assert.AreEqual(128, SettingsCustomProcessing.Width, 'Width not set correctly by --width option.'); Assert.AreEqual(32, SettingsCustomProcessing.Height, 'Height not set correctly by -size option.'); end; { ToInstance } function ToInstance.AssemblyOutputPath: string; begin Result := FInstance.AssemblyOutputPath; end; procedure ToInstance.CreateInstance; begin FInstance := InstanceSettings.Create; end; procedure ToInstance.DisposeInstance; begin FInstance.Free; FInstance := nil; end; function ToInstance.Optimization: Boolean; begin Result := FInstance.Optimization; end; function ToInstance.SearchPath: string; begin Result := FInstance.SearchPath; end; function ToInstance.StoreTo: ObjectArray; begin Result := ObjectArray.Create(FInstance); end; function ToInstance.UnitOutputPath: string; begin Result := FInstance.UnitOutputPath; end; { ToMultipleClasses } function ToMultipleClasses.AssemblyOutputPath: string; begin Result := DirectorySettings.AssemblyOutputPath; end; procedure ToMultipleClasses.Initialize; begin CompilerSettings.Initialize; DirectorySettings.Initialize; end; function ToMultipleClasses.Optimization: Boolean; begin Result := CompilerSettings.Optimization; end; function ToMultipleClasses.SearchPath: string; begin Result := DirectorySettings.SearchPath; end; function ToMultipleClasses.StoreTo: ObjectArray; begin Result := ObjectArray.Create(TypeOf(CompilerSettings), TypeOf(DirectorySettings)); end; function ToMultipleClasses.UnitOutputPath: string; begin Result := DirectorySettings.UnitOutputPath; end; end. |
From: Marcel B. <jed...@us...> - 2005-03-01 14:26:57
|
Update of /cvsroot/jedidotnet/nunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2369/nunit Modified Files: Nunit.Jedi.System.bdsproj Nunit.Jedi.System.dpk Log Message: Added test-set for CommandLine parser Index: Nunit.Jedi.System.dpk =================================================================== RCS file: /cvsroot/jedidotnet/nunit/Nunit.Jedi.System.dpk,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Nunit.Jedi.System.dpk 25 Jan 2005 10:25:55 -0000 1.7 --- Nunit.Jedi.System.dpk 1 Mar 2005 14:26:41 -0000 1.8 *************** *** 24,32 **** {$IMAGEBASE $400000} {$IMPLICITBUILD OFF} requires Borland.Delphi, nunit.framework, ! Jedi.System; contains --- 24,35 ---- {$IMAGEBASE $400000} {$IMPLICITBUILD OFF} + {$R 'resources\Jedi.System.CommandLine.resources' 'resources\Jedi.System.CommandLine.resx'} requires Borland.Delphi, nunit.framework, ! Jedi.System, ! System.Data, ! System.XML; contains *************** *** 34,38 **** Jedi.System.Strings.NUnit in 'source\Jedi.System.Strings.NUnit.pas', Jedi.System.SourceVersioning.NUnit in 'source\Jedi.System.SourceVersioning.NUnit.pas', ! Jedi.Timers.EventScheduler_NUnit in 'source\Jedi.Timers.EventScheduler_NUnit.pas'; [assembly: AssemblyTitle('Nunit.Jedi.System')] --- 37,42 ---- Jedi.System.Strings.NUnit in 'source\Jedi.System.Strings.NUnit.pas', Jedi.System.SourceVersioning.NUnit in 'source\Jedi.System.SourceVersioning.NUnit.pas', ! Jedi.Timers.EventScheduler_NUnit in 'source\Jedi.Timers.EventScheduler_NUnit.pas', ! Jedi.System.CommandLine.NUnit in 'source\Jedi.System.CommandLine.NUnit.pas'; [assembly: AssemblyTitle('Nunit.Jedi.System')] Index: Nunit.Jedi.System.bdsproj =================================================================== RCS file: /cvsroot/jedidotnet/nunit/Nunit.Jedi.System.bdsproj,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Nunit.Jedi.System.bdsproj 25 Jan 2005 10:25:55 -0000 1.7 --- Nunit.Jedi.System.bdsproj 1 Mar 2005 14:26:40 -0000 1.8 *************** *** 1,3 **** ! <?xml version="1.0" encoding="utf-8"?> <BorlandProject> <PersonalityInfo> --- 1,3 ---- ! <?xml version="1.0" encoding="utf-8"?> <BorlandProject> <PersonalityInfo> *************** *** 121,125 **** <Directories Name="PackageDCPOutputDir" Type="String">bin</Directories> <Directories Name="SearchPath" Type="String">$(BDS)\Lib;..\main\bin</Directories> ! <Directories Name="Packages" Type="String">Jedi.System;nunit.framework.dll;Borland.Delphi</Directories> <Directories Name="Conditionals" Type="String"></Directories> <Directories Name="DebugSourceDirs" Type="String"></Directories> --- 121,125 ---- <Directories Name="PackageDCPOutputDir" Type="String">bin</Directories> <Directories Name="SearchPath" Type="String">$(BDS)\Lib;..\main\bin</Directories> ! <Directories Name="Packages" Type="String">System.XML.dll;System.Data.dll;Jedi.System;nunit.framework.dll;Borland.Delphi</Directories> <Directories Name="Conditionals" Type="String"></Directories> <Directories Name="DebugSourceDirs" Type="String"></Directories> *************** *** 171,181 **** </VersionInfoKeys> <FileList> <File FileName="Borland.Delphi.dll" ContainerId="DelphiDotNetAssemblyCompiler" ModuleName="Borland.Delphi" AssemblyName="borland.delphi" Version="9.0.1761.24408" LinkUnits="False"/> <File FileName="nunit.framework.dll" ContainerId="DelphiDotNetAssemblyCompiler" ModuleName="nunit.framework" AssemblyName="nunit.framework" Version="2.2.1.0" LinkUnits="False"/> <File FileName="..\main\bin\Jedi.System.dll" ContainerId="DelphiDotNetAssemblyCompiler" ModuleName="Jedi.System" AssemblyName="Jedi.System" Version="1.0.0.0" LinkUnits="False"/> <File FileName="source\Jedi.System.Attributes.NUnit.pas" ContainerId="" ModuleName="Jedi.System.Attributes.NUnit"/> <File FileName="source\Jedi.System.Strings.NUnit.pas" ContainerId="" ModuleName="Jedi.System.Strings.NUnit"/> <File FileName="source\Jedi.System.SourceVersioning.NUnit.pas" ContainerId="" ModuleName="Jedi.System.SourceVersioning.NUnit"/> ! <File FileName="source\Jedi.Timers.EventScheduler_NUnit.pas" ContainerId="" ModuleName="Jedi.Timers.EventScheduler_NUnit"/> </FileList> </DelphiDotNet.Personality> --- 171,185 ---- </VersionInfoKeys> <FileList> + <File FileName="resources\Jedi.System.CommandLine.resx" ContainerId="ResXCompiler" ModuleName="Jedi.System.CommandLine"/> <File FileName="Borland.Delphi.dll" ContainerId="DelphiDotNetAssemblyCompiler" ModuleName="Borland.Delphi" AssemblyName="borland.delphi" Version="9.0.1761.24408" LinkUnits="False"/> <File FileName="nunit.framework.dll" ContainerId="DelphiDotNetAssemblyCompiler" ModuleName="nunit.framework" AssemblyName="nunit.framework" Version="2.2.1.0" LinkUnits="False"/> <File FileName="..\main\bin\Jedi.System.dll" ContainerId="DelphiDotNetAssemblyCompiler" ModuleName="Jedi.System" AssemblyName="Jedi.System" Version="1.0.0.0" LinkUnits="False"/> + <File FileName="$(SystemRoot)\microsoft.net\framework\v1.1.4322\System.Data.dll" ContainerId="DelphiDotNetAssemblyCompiler" ModuleName="System.Data" AssemblyName="system.data" Version="1.0.5000.0" LinkUnits="False"/> + <File FileName="$(SystemRoot)\microsoft.net\framework\v1.1.4322\System.XML.dll" ContainerId="DelphiDotNetAssemblyCompiler" ModuleName="System.XML" AssemblyName="system.xml" Version="1.0.5000.0" LinkUnits="False"/> <File FileName="source\Jedi.System.Attributes.NUnit.pas" ContainerId="" ModuleName="Jedi.System.Attributes.NUnit"/> <File FileName="source\Jedi.System.Strings.NUnit.pas" ContainerId="" ModuleName="Jedi.System.Strings.NUnit"/> <File FileName="source\Jedi.System.SourceVersioning.NUnit.pas" ContainerId="" ModuleName="Jedi.System.SourceVersioning.NUnit"/> ! <File FileName="source\Jedi.Timers.EventScheduler_NUnit.pas" Contai |
From: Marcel B. <jed...@us...> - 2005-03-01 14:26:56
|
Update of /cvsroot/jedidotnet/nunit/resources In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2369/nunit/resources Added Files: Jedi.System.CommandLine.resx Log Message: Added test-set for CommandLine parser --- NEW FILE: Jedi.System.CommandLine.resx --- <?xml version="1.0" encoding="utf-8" ?> <root> <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <xsd:element name="root" msdata:IsDataSet="true"> <xsd:complexType> <xsd:choice maxOccurs="unbounded"> <xsd:element name="data"> <xsd:complexType> <xsd:sequence> <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> </xsd:sequence> <xsd:attribute name="name" type="xsd:string" /> <xsd:attribute name="type" type="xsd:string" /> <xsd:attribute name="mimetype" type="xsd:string" /> </xsd:complexType> </xsd:element> <xsd:element name="resheader"> <xsd:complexType> <xsd:sequence> <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> </xsd:sequence> <xsd:attribute name="name" type="xsd:string" use="required" /> </xsd:complexType> </xsd:element> </xsd:choice> </xsd:complexType> </xsd:element> </xsd:schema> <resheader name="ResMimeType"> <value>text/microsoft-resx</value> </resheader> <resheader name="Version"> <value>1.0.0.0</value> </resheader> <resheader name="Reader"> <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> </resheader> <resheader name="Writer"> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> </resheader> <data name="responses1.rsp"> <value>-O+ -SSomePath;NextPath -OA..\Bin -OU"..\Temp Units"</value> </data> </root> |
From: Marcel B. <jed...@us...> - 2005-03-01 14:26:17
|
Update of /cvsroot/jedidotnet/main/run In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1971/main/run Added Files: Jedi.System.CommandLine.pas Log Message: Added: CommandLine parser --- NEW FILE: Jedi.System.CommandLine.pas --- {--------------------------------------------------------------------------------------------------- The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.mozilla.org/MPL/MPL-1.1.html Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See the License for the specific language governing rights and limitations under the License. The Original Code is: Jedi.System.CommandLine.pas, released on 2005-03-01. The Initial Developer of the Original Code is Marcel Bestebroer Portions created by Marcel Bestebroer are Copyright (C) 2004 Marcel Bestebroer All Rights Reserved. Contributor(s): You may retrieve the latest version of this file at the JEDI.NET home page, located at http://sf.net/projects/jedidotnet Known Issues: - Is only able to handle Boolean, Integer (unsigned Int16, Int32 and Int64) and String types. Other types require the user to write their own processing method and register the method as a command line argument. - If an argument starts with any of the starting symbols of the registered switches, an exception is thrown ('unknown argument'). Future version will allow you to specify an option if unknown switches should be ignored or result in an exception thrown. - Boolean type switches not having a + or - behind the option work as a toggle at all times. Future version will allow you to specify if the switch is a toggle or will result in the 'True' value if neither '+' or '-' follows the switch. ---------------------------------------------------------------------------------------------------} // $Id: Jedi.System.CommandLine.pas,v 1.1 2005/03/01 14:25:53 jedi_mbe Exp $ unit Jedi.System.CommandLine; interface {$REGION 'interface uses'} uses Jedi.System.SourceVersioning, Jedi.System.Strings, System.Collections, System.Globalization, System.IO, System.Reflection; {$ENDREGION} {$REGION 'Helper types'} type ObjectArray = array of &Object; StringArray = array of string; {$ENDREGION} {$REGION 'CommandLine exception type'} type [JediSourceInfo( '$RSCfile$', '$Revision: 1.1 $', '$Date: 2005/03/01 14:25:53 $')] CommandLineException = class (SystemException); {$ENDREGION} {$REGION 'Forward declaration of attribute'} type CommandLineArgumentAttribute = class; {$ENDREGION} {$REGION 'Parser'} [JediSourceInfo( '$RSCfile$', '$Revision: 1.1 $', '$Date: 2005/03/01 14:25:53 $')] CommandLine = class {$REGION 'Data'} strict private FArguments: ArrayList; FArgumentStarters: string; FLiterals: ArrayList; FResponseFilePrefix: string; {$ENDREGION} {$REGION 'Constructor'} strict protected constructor Create(arguments: array of &Object; responseFilePrefix: string); {$ENDREGION} {$REGION 'Nested type: Argument class'} protected type Argument = class (&Object, IComparable) {$REGION 'Constructor'} public constructor Create(matches: string; caseSensitive: Boolean; instance: &Object; memberInfo: MemberInfo); {$ENDREGION} {$REGION 'Data'} strict private FCaseSensitive: Boolean; FInstance: &Object; FMatches: string; FMemberInfo: MemberInfo; {$ENDREGION} {$REGION 'IComparable method'} strict protected function CompareTo(obj: &Object): Integer; {$ENDREGION} {$REGION 'Type specific processing methods'} strict protected procedure ProcessBoolean(match, commandLine: string; var index: Integer); procedure ProcessInt(match, commandLine: string; var index: Integer); procedure ProcessString(match, commandLine: string; var index: Integer); {$ENDREGION} {$REGION 'Public method'} public procedure Process(commandLine: string; var index: Integer); {$ENDREGION} {$REGION 'Properties'} public property CaseSensitive: Boolean read FCaseSensitive; property Instance: &Object read FInstance; property Matches: string read FMatches; property MemberInfo: MemberInfo read FMemberInfo; {$ENDREGION} end; {$ENDREGION} {$REGION 'Protected methods'} strict protected procedure AddLiteral(commandLine: string; var index: Integer); function CheckAndProcessArgument(commandLine: string; var index: Integer): Boolean; function CheckAndProcessResponseFile(commandLine: string; var index: Integer): Boolean; function GetLiterals: StringArray; procedure ParseImpl(commandLine: string); procedure RegisterArgument(instance: &Object; memberInfo: MemberInfo; attr: CommandLineArgumentAttribute); overload; procedure RegisterArgument(instance: &Object; memberInfo: MemberInfo; attributes: array of &Object); overload; procedure RegisterInstance(instance: &Object); procedure RegisterInstances(instances: array of &Object); procedure RegisterType(&type: &Type); overload; procedure RegisterType(&type: &Type; instance: &Object); overload; {$ENDREGION} {$REGION 'Public static methods'} public class function GetLiteral(commandLine: string; var index: Integer): string; static; class function Parse(arguments: array of &Object): StringArray; overload; static; class function Parse(arguments: array of &Object; responseFilePrefix: string): StringArray; overload; static; class function Parse(commandLine: string; arguments: array of &Object): StringArray; overload; static; class function Parse(commandLine: string; arguments: array of &Object; responseFilePrefix: string): StringArray; overload; static; {$ENDREGION} end; {$ENDREGION} {$REGION 'Attribute'} [JediSourceInfo( '$RSCfile$', '$Revision: 1.1 $', '$Date: 2005/03/01 14:25:53 $'), AttributeUsage(AttributeTargets.Property or AttributeTargets.Method, AllowMultiple = True, &Inherited = False)] CommandLineArgumentAttribute = class (Attribute) {$REGION 'Data'} strict private FCaseSensitive: Boolean; FNames: ArrayList; FPrefixes: ArrayList; FValueSeparators: ArrayList; {$ENDREGION} {$REGION 'Constructor'} public constructor Create; {$ENDREGION} {$REGION 'Public method'} public function GetMatches: StringArray; {$ENDREGION} {$REGION 'Property access methods'} public function get_Name: string; function get_NameCount: Integer; function get_Names(index: Integer): string; function get_Prefix: string; function get_PrefixCount: Integer; function get_Prefixes(index: Integer): string; function get_ValueSeparator: string; function get_ValueSeparatorCount: Integer; function get_ValueSeparators(index: Integer): string; procedure set_Name(value: string); procedure set_Prefix(value: string); procedure set_ValueSeparator(value: string); {$ENDREGION} {$REGION 'Properties'} public property CaseSensitive: Boolean read FCaseSensitive write FCaseSensitive; property Name: string read get_Name write set_Name; property NameCount: Integer read get_NameCount; property Names[&index: Integer]: string read get_Names; property Prefix: string read get_Prefix write set_Prefix; property PrefixCount: Integer read get_PrefixCount; property Prefixes[&index: Integer]: string read get_Prefixes; property ValueSeparator: string read get_ValueSeparator write set_ValueSeparator; property ValueSeparatorCount: Integer read get_ValueSeparatorCount; property ValueSeparators[&index: Integer]: string read get_ValueSeparators; {$ENDREGION} end; {$ENDREGION} implementation {$AUTOBOX ON} {$REGION 'CommandLine'} constructor CommandLine.Create(arguments: array of &Object; responseFilePrefix: string); begin inherited Create; if &Array(arguments) = nil then raise ArgumentNullException.Create('arguments'); FArguments := ArrayList.Create; if responseFilePrefix.Length > 1 then FArgumentStarters := responseFilePrefix.Chars[0] else FArgumentStarters := ''; FLiterals := ArrayList.Create; FResponseFilePrefix := responseFilePrefix; RegisterInstances(arguments); end; procedure CommandLine.AddLiteral(commandLine: string; var index: Integer); begin FLiterals.Add(GetLiteral(commandLine, index)); end; function CommandLine.CheckAndProcessArgument(commandLine: string; var index: Integer): Boolean; var partToCheck: string; argIdx: Integer; lastCompare: Integer; thisArgument: Argument; begin if FArgumentStarters.IndexOf(commandLine.Chars[index]) >= 0 then begin partToCheck := commandLine.Substring(index); argIdx := FArguments.Count; lastCompare := 1; thisArgument := nil; while (lastCompare > 0) and (argIdx > 0) do begin Dec(argIdx); thisArgument := Argument(FArguments[argIdx]); lastCompare := IComparable(thisArgument).CompareTo(partToCheck); end; Result := lastCompare = 0; if Result then thisArgument.Process(commandLine, index) else raise CommandLineException.Create(System.String.Format('Unknown argument: {0}', GetLiteral(commandLine, index))); end else Result := False; end; function CommandLine.CheckAndProcessResponseFile(commandLine: string; var index: Integer): Boolean; var orgPrefix: string; fileName: string; tr: TextReader; begin if (FResponseFilePrefix <> '') and (System.String.Compare(FResponseFilePrefix, 0, commandLine, index, FResponseFilePrefix.Length, True) = 0) then begin Result := True; orgPrefix := FResponseFilePrefix; try Inc(index, FResponseFilePrefix.Length); FResponseFilePrefix := ''; // disable nested response file processing fileName := GetLiteral(commandLine, index); if fileName = '' then raise CommandLineException.Create('Response file argument: No filename given.'); tr := StreamReader.Create(fileName); try while tr.Peek > -1 do ParseImpl('ignored ' + tr.ReadLine); finally tr.Close; end; finally FResponseFilePrefix := orgPrefix; end; end else Result := False; end; class function CommandLine.GetLiteral(commandLine: string; var index: Integer): string; var startIndex: Integer; lastQuote: Char; quoteIdx: Integer; begin startIndex := index; lastQuote := #0; while (index < commandLine.Length) and ((lastQuote <> #0) or (commandLine.Chars[index] <> ' ')) do begin if (commandLine.Chars[index] = '"') and (lastQuote = #0) then lastQuote := '"' else if (commandLine.Chars[index] = '''') and (lastQuote = #0) then lastQuote := '"' else if (commandLine.Chars[index] = lastQuote) then lastQuote := #0; Inc(index); end; if lastQuote <> #0 then raise CommandLineException.Create('Missing end quote (' + lastQuote + ') in value.'); if index > startIndex then begin Result := StringUtils.ExtractQuotedString(commandLine.Substring(startIndex, index - startIndex), quoteIdx); Inc(quoteIdx, startIndex + 1); if (quoteIdx >= startIndex) and (quoteIdx < index) then Result := Result + commandLine.Substring(quoteIdx, index - quoteIdx) end else Result := ''; while (index < commandLine.Length) and (commandLine.Chars[index] = ' ') do Inc(index); end; function CommandLine.GetLiterals: StringArray; begin Result := StringArray(FLiterals.ToArray(TypeOf(string))); end; class function CommandLine.Parse(arguments: array of &Object): StringArray; begin Result := Parse(Environment.CommandLine, arguments, ''); end; class function CommandLine.Parse(arguments: array of &Object; responseFilePrefix: string): StringArray; begin Result := Parse(Environment.CommandLine, arguments, responseFilePrefix); end; class function CommandLine.Parse(commandLine: string; arguments: array of &Object): StringArray; begin Result := Parse(commandLine, arguments, ''); end; class function CommandLine.Parse(commandLine: string; arguments: array of &Object; responseFilePrefix: string): StringArray; var parser: Jedi.System.CommandLine.CommandLine; begin parser := Jedi.System.CommandLine.CommandLine.Create(arguments, responseFilePrefix); parser.ParseImpl(commandLine); Result := parser.GetLiterals; end; procedure CommandLine.ParseImpl(commandLine: string); var idx: Integer; begin idx := 0; commandLine := commandLine + ' '; GetLiteral(commandLine, idx); // skips the path/file of the running process while idx < commandLine.Length do begin if not CheckAndProcessResponseFile(commandLine, idx) and not CheckAndProcessArgument(commandLine, idx) then AddLiteral(commandLine, idx); end; end; procedure CommandLine.RegisterArgument(instance: &Object; memberInfo: MemberInfo; attr: CommandLineArgumentAttribute); var thisMatch: string; argument: CommandLine.Argument; idx: Integer; begin for thisMatch in attr.GetMatches do begin argument := CommandLine.Argument.Create(thisMatch, attr.CaseSensitive, instance, memberInfo); idx := FArguments.BinarySearch(argument); if idx >= 0 then raise CommandLineException.Create(System.String.Format( 'Duplicate command line argument ({0}) specified by ''{1}.{2}''. The argument has already been assigned to ''{3}.{4}''', [thisMatch, memberInfo.ReflectedType.FullName, memberInfo.Name, CommandLine.Argument(FArguments[idx]).MemberInfo.ReflectedType.FullName, CommandLine.Argument(FArguments[idx]).MemberInfo.Name])); if FArgumentStarters.IndexOf(thisMatch.Chars[0]) = -1 then FArgumentStarters := FArgumentStarters + thisMatch.Chars[0]; FArguments.Insert(not idx, argument); end; end; procedure CommandLine.RegisterArgument(instance: &Object; memberInfo: MemberInfo; attributes: array of &Object); var obj: &Object; begin for obj in attributes do RegisterArgument(instance, memberInfo, CommandLineArgumentAttribute(obj)); end; procedure CommandLine.RegisterInstance(instance: &Object); begin if instance = nil then raise ArgumentNullException.Create('instance'); if TypeOf(&Type).IsInstanceOfType(instance) then RegisterType(&Type(instance)) else RegisterType(instance.GetType, instance); end; procedure CommandLine.RegisterInstances(instances: array of &Object); var instance: &Object; begin for instance in instances do RegisterInstance(instance); end; procedure CommandLine.RegisterType(&type: &Type); begin RegisterType(&type, nil); end; procedure CommandLine.RegisterType(&type: &Type; instance: &Object); var piArray: array of PropertyInfo; pi: PropertyInfo; attrs: array of &Object; miArray: array of MethodInfo; mi: MethodInfo; pmArray: array of ParameterInfo; begin if &type = nil then raise ArgumentNullException.Create('type'); // Retrieve properties... if instance = nil then piArray := &type.GetProperties(BindingFlags.Static or BindingFlags.Public or BindingFlags.NonPublic) else piArray := &type.GetProperties(BindingFlags.Instance or BindingFlags.Public or BindingFlags.NonPublic); for pi in piArray do begin attrs := pi.GetCustomAttributes(TypeOf(CommandLineArgumentAttribute), False); if &Array(attrs).Length > 0 then RegisterArgument(instance, pi, attrs); end; // Retrieve methods... if instance = nil then miArray := &type.GetMethods(BindingFlags.Static or BindingFlags.Public or BindingFlags.NonPublic) else miArray := &type.GetMethods(BindingFlags.Instance or BindingFlags.Public or BindingFlags.NonPublic); for mi in miArray do begin attrs := mi.GetCustomAttributes(TypeOf(CommandLineArgumentAttribute), False); if &Array(attrs).Length > 0 then begin // Check signature is valid pmArray := mi.GetParameters; if &Array(pmArray).Length <> 3 then raise CommandLineException.Create('Method signature incorrect: needs three parameters.'); if not pmArray[2].ParameterType.IsByRef then raise CommandLineException.Create('Method signature incorrect: the final int parameter should be by reference. '); if not TypeOf(string).IsAssignableFrom(pmArray[0].ParameterType) or not TypeOf(string).IsAssignableFrom(pmArray[1].ParameterType) or not TypeOf(Integer).IsAssignableFrom(pmArray[2].ParameterType.GetElementType) then raise CommandLineException.Create('Method signature incorrect: needs two strings and an int parameter.'); RegisterArgument(instance, mi, attrs); end; end; end; {$ENDREGION} {$REGION 'CommandLine.Argument'} constructor CommandLine.Argument.Create(matches: string; caseSensitive: Boolean; instance: &Object; memberInfo: MemberInfo); begin inherited Create; if memberInfo = nil then raise ArgumentNullException.Create('memberInfo'); if matches = '' then raise ArgumentException.Create('Cannot me an empty string', 'matches'); FCaseSensitive := caseSensitive; FInstance := instance; FMatches := matches; FMemberInfo := memberInfo; end; function CommandLine.Argument.CompareTo(obj: &Object): Integer; var arg2: CommandLine.Argument; strPart: string; begin if obj = nil then Result := 1 else if TypeOf(CommandLine.Argument).IsInstanceOfType(obj) then begin arg2 := CommandLine.Argument(obj); Result := System.String.Compare(FMatches, arg2.FMatches, not FCaseSensitive or not arg2.FCaseSensitive); end else if TypeOf(System.String).IsInstanceOfType(obj) then begin strPart := string(obj); if strPart.Length > FMatches.Length then strPart := strPart.Substring(0, FMatches.Length); Result := System.String.Compare(FMatches, strPart, not FCaseSensitive); end else raise ArgumentException.Create('objects cannot be compared.'); end; procedure CommandLine.Argument.Process(commandLine: string; var index: Integer); var match: string; pi: PropertyInfo; params: array of &Object; begin match := commandLine.Substring(index, FMatches.Length); Inc(index, FMatches.Length); if FMatches.EndsWith(' ') then while (index < commandLine.Length) and (commandLine.Chars[index] = ' ') do Inc(index); pi := PropertyInfo(FMemberInfo); if pi = nil then begin params := ObjectArray.Create(match, commandLine, index); MethodInfo(FMemberInfo).Invoke(FInstance, params); index := Integer(params[2]); end else if TypeOf(System.Boolean).IsAssignableFrom(pi.PropertyType) then ProcessBoolean(match, commandLine, index) else if TypeOf(System.Int16).IsAssignableFrom(pi.PropertyType) or TypeOf(System.Int32).IsAssignableFrom(pi.PropertyType) or TypeOf(System.Int64).IsAssignableFrom(pi.PropertyType) then ProcessInt(match, commandLine, index) else if TypeOf(System.String).IsAssignableFrom(pi.PropertyType) then ProcessString(match, commandLine, index) end; procedure CommandLine.Argument.ProcessBoolean(match, commandLine: string; var index: Integer); var value: string; begin value := Jedi.System.CommandLine.CommandLine.GetLiteral(commandLine, index); if value = '+' then PropertyInfo(FMemberInfo).SetValue(FInstance, True, []) else if value = '-' then PropertyInfo(FMemberInfo).SetValue(FInstance, False, []) else if value = '' then PropertyInfo(FMemberInfo).SetValue(FInstance, not Boolean(PropertyInfo(FMemberInfo).GetValue(FInstance, [])), []) else raise CommandLineException.Create(System.String.Format('Invalid boolean value. Argument: {0}. Value: {1}', Matches, value)); end; procedure CommandLine.Argument.ProcessInt(match, commandLine: string; var index: Integer); var value: string; pi: PropertyInfo; flags: BindingFlags; begin value := Jedi.System.CommandLine.CommandLine.GetLiteral(commandLine, index); pi := PropertyInfo(FMemberInfo); if FInstance = nil then flags := BindingFlags.Static else flags := BindingFlags.Instance; flags := flags or BindingFlags.Public or BindingFlags.NonPublic or BindingFlags.InvokeMethod; pi.SetValue( FInstance, pi.PropertyType.InvokeMember('Parse', flags, nil, FInstance, [value, NumberFormatInfo.InvariantInfo], [], CultureInfo.InvariantCulture, ['s', 'provider']), []); end; procedure CommandLine.Argument.ProcessString(match, commandLine: string; var index: Integer); begin PropertyInfo(FMemberInfo).SetValue(FInstance, Jedi.System.CommandLine.CommandLine.GetLiteral(commandLine, index), []); end; {$ENDREGION} {$REGION 'CommandLineArgumentAttribute'} constructor CommandLineArgumentAttribute.Create; begin inherited Create; FNames := ArrayList.Create; FPrefixes := ArrayList.Create; FValueSeparators := ArrayList.Create; end; function CommandLineArgumentAttribute.GetMatches: StringArray; var tmpPrefixes: ArrayList; tmpSeparators: ArrayList; matchList: ArrayList; thisPrefix: string; thisName: string; thisSeparator: string; begin tmpPrefixes := ArrayList.Create(FPrefixes); if tmpPrefixes.Count = 0 then tmpPrefixes.Add(''); tmpSeparators := ArrayList.Create(FValueSeparators); if tmpSeparators.Count = 0 then tmpSeparators.Add(''); matchList := ArrayList.Create(tmpPrefixes.Count * FNames.Count * tmpSeparators.Count); for thisPrefix in tmpPrefixes do for thisName in FNames do for thisSeparator in tmpSeparators do matchList.Add(System.String.Format('{0}{1}{2}', thisPrefix, thisName, thisSeparator)); Result := StringArray(matchList.ToArray(TypeOf(string))); end; function CommandLineArgumentAttribute.get_Name: string; begin if FNames.Count = 0 then Result := '' else Result := string(FNames[FNames.Count - 1]); end; function CommandLineArgumentAttribute.get_NameCount: Integer; begin Result := FNames.Count; end; function CommandLineArgumentAttribute.get_Names(index: Integer): string; begin Result := string(FNames[index]); end; function CommandLineArgumentAttribute.get_Prefix: string; begin if FPrefixes.Count = 0 then Result := '' else Result := string(FPrefixes[FPrefixes.Count - 1]); end; function CommandLineArgumentAttribute.get_PrefixCount: Integer; begin Result := FPrefixes.Count; end; function CommandLineArgumentAttribute.get_Prefixes(index: Integer): string; begin Result := string(FPrefixes[index]); end; function CommandLineArgumentAttribute.get_ValueSeparator: string; begin if FValueSeparators.Count = 0 then Result := '' else Result := string(FValueSeparators[FValueSeparators.Count - 1]); end; function CommandLineArgumentAttribute.get_ValueSeparatorCount: Integer; begin Result := FValueSeparators.Count; end; function CommandLineArgumentAttribute.get_ValueSeparators(index: Integer): string; begin Result := string(FValueSeparators[index]); end; procedure CommandLineArgumentAttribute.set_Name(value: string); begin FNames.Add(value); end; procedure CommandLineArgumentAttribute.set_Prefix(value: string); begin FPrefixes.Add(value); end; procedure CommandLineArgumentAttribute.set_ValueSeparator(value: string); begin FValueSeparators.Add(value); end; {$ENDREGION} end. |
From: Marcel B. <jed...@us...> - 2005-03-01 14:26:15
|
Update of /cvsroot/jedidotnet/main/assemblies In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1971/main/assemblies Modified Files: Jedi.System.bdsproj Jedi.System.dpk Log Message: Added: CommandLine parser Index: Jedi.System.dpk =================================================================== RCS file: /cvsroot/jedidotnet/main/assemblies/Jedi.System.dpk,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Jedi.System.dpk 25 Jan 2005 10:25:54 -0000 1.5 --- Jedi.System.dpk 1 Mar 2005 14:25:51 -0000 1.6 *************** *** 35,39 **** Jedi.System.SourceVersioning in '..\run\Jedi.System.SourceVersioning.pas', Jedi.System.FrameworkResources in '..\run\Jedi.System.FrameworkResources.pas', ! Jedi.Timers.EventScheduler in '..\run\Jedi.Timers.EventScheduler.pas'; [assembly: AssemblyTitle('Jedi.System')] --- 35,40 ---- Jedi.System.SourceVersioning in '..\run\Jedi.System.SourceVersioning.pas', Jedi.System.FrameworkResources in '..\run\Jedi.System.FrameworkResources.pas', ! Jedi.Timers.EventScheduler in '..\run\Jedi.Timers.EventScheduler.pas', ! Jedi.System.CommandLine in '..\run\Jedi.System.CommandLine.pas'; [assembly: AssemblyTitle('Jedi.System')] Index: Jedi.System.bdsproj =================================================================== RCS file: /cvsroot/jedidotnet/main/assemblies/Jedi.System.bdsproj,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Jedi.System.bdsproj 25 Jan 2005 10:25:54 -0000 1.5 --- Jedi.System.bdsproj 1 Mar 2005 14:25:51 -0000 1.6 *************** *** 1,3 **** ! <?xml version="1.0" encoding="utf-8"?> <BorlandProject> <PersonalityInfo> --- 1,3 ---- ! <?xml version="1.0" encoding="utf-8"?> <BorlandProject> <PersonalityInfo> *************** *** 179,182 **** --- 179,183 ---- <File FileName="..\run\Jedi.System.FrameworkResources.pas" ContainerId="" ModuleName="Jedi.System.FrameworkResources"/> <File FileName="..\run\Jedi.Timers.EventScheduler.pas" ContainerId="" ModuleName="Jedi.Timers.EventScheduler"/> + <File FileName="..\run\Jedi.System.CommandLine.pas" ContainerId="" ModuleName="Jedi.System.CommandLine"/> </FileList> </DelphiDotNet.Personality> |
From: Marcel B. <jed...@us...> - 2005-03-01 14:23:24
|
Update of /cvsroot/jedidotnet/main/run In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv884/main/run Modified Files: Jedi.Timers.EventScheduler.pas Log Message: Added release date in header Index: Jedi.Timers.EventScheduler.pas =================================================================== RCS file: /cvsroot/jedidotnet/main/run/Jedi.Timers.EventScheduler.pas,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Jedi.Timers.EventScheduler.pas 25 Jan 2005 10:25:55 -0000 1.1 --- Jedi.Timers.EventScheduler.pas 1 Mar 2005 14:22:59 -0000 1.2 *************** *** 8,12 **** limitations under the License. ! The Original Code is: Jedi.Timers.EventScheduler.pas, released on --. The Initial Developer of the Original Code is Marcel Bestebroer --- 8,12 ---- limitations under the License. ! The Original Code is: Jedi.Timers.EventScheduler.pas, released on 2005-01-25. The Initial Developer of the Original Code is Marcel Bestebroer |
From: Marcel B. <jed...@us...> - 2005-03-01 14:22:19
|
Update of /cvsroot/jedidotnet/main/run In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv610/main/run Modified Files: Jedi.System.SourceVersioning.pas Log Message: Fixed release date in header (apparently it should've been released in about a year) Index: Jedi.System.SourceVersioning.pas =================================================================== RCS file: /cvsroot/jedidotnet/main/run/Jedi.System.SourceVersioning.pas,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Jedi.System.SourceVersioning.pas 22 Jan 2005 14:39:05 -0000 1.3 --- Jedi.System.SourceVersioning.pas 1 Mar 2005 14:22:10 -0000 1.4 *************** *** 8,12 **** limitations under the License. ! The Original Code is: Jedi.System.SourceVersioning.pas, released on 2006-01-21. The Initial Developer of the Original Code is Marcel Bestebroer --- 8,12 ---- limitations under the License. ! The Original Code is: Jedi.System.SourceVersioning.pas, released on 2005-01-21. The Initial Developer of the Original Code is Marcel Bestebroer |
From: Marcel B. <jed...@us...> - 2005-01-25 10:27:48
|
Update of /cvsroot/jedidotnet/main/assemblies In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3468/main/assemblies Modified Files: Jedi.IO.bdsproj Log Message: Updated BufferedIniFile to use the EventScheduler to schedule the AutoReload and AutoFlush. Index: Jedi.IO.bdsproj =================================================================== RCS file: /cvsroot/jedidotnet/main/assemblies/Jedi.IO.bdsproj,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Jedi.IO.bdsproj 23 Jan 2005 11:05:51 -0000 1.5 --- Jedi.IO.bdsproj 25 Jan 2005 10:27:35 -0000 1.6 *************** *** 45,49 **** <Compiler Name="ShowHints">True</Compiler> <Compiler Name="ShowWarnings">True</Compiler> ! <Compiler Name="UnitAliases">WinTypes=Borland.Vcl.Windows;WinProcs=Borland.Vcl.Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;Jedi.System=Jedi.System.Attributes, Jedi.System.FrameworkResources, Jedi.System.Strings, Jedi.System.SourceVersioning;Jedi.Collections=Jedi.Collections.InlineEditable</Compiler> <Compiler Name="NamespacePrefix"></Compiler> <Compiler Name="GenerateDocumentation">True</Compiler> --- 45,49 ---- <Compiler Name="ShowHints">True</Compiler> <Compiler Name="ShowWarnings">True</Compiler> ! <Compiler Name="UnitAliases">WinTypes=Borland.Vcl.Windows;WinProcs=Borland.Vcl.Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;Jedi.System=Jedi.System.Attributes, Jedi.System.FrameworkResources, Jedi.System.Strings, Jedi.System.SourceVersioning;Jedi.Collections=Jedi.Collections.InlineEditable;Jedi.Timers=Jedi.Timers.EventScheduler</Compiler> <Compiler Name="NamespacePrefix"></Compiler> <Compiler Name="GenerateDocumentation">True</Compiler> |
From: Marcel B. <jed...@us...> - 2005-01-25 10:27:48
|
Update of /cvsroot/jedidotnet/main/run In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3468/main/run Modified Files: Jedi.IO.IniFiles.pas Log Message: Updated BufferedIniFile to use the EventScheduler to schedule the AutoReload and AutoFlush. Index: Jedi.IO.IniFiles.pas =================================================================== RCS file: /cvsroot/jedidotnet/main/run/Jedi.IO.IniFiles.pas,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Jedi.IO.IniFiles.pas 23 Jan 2005 11:06:48 -0000 1.2 --- Jedi.IO.IniFiles.pas 25 Jan 2005 10:27:35 -0000 1.3 *************** *** 33,37 **** System.Resources, System.Threading, ! Jedi.System; {$ENDREGION} --- 33,38 ---- System.Resources, System.Threading, ! Jedi.System, ! Jedi.Timers.EventScheduler; {$ENDREGION} *************** *** 470,477 **** {$REGION 'Data'} strict private ! FAutoFlushInterval: Integer; ! FAutoFlushTimer: Timer; ! FAutoReloadInterval: Integer; ! FAutoReloadTimer: Timer; FLastWrite: DateTime; FPath: string; --- 471,476 ---- {$REGION 'Data'} strict private ! FAutoReloadEvent: ScheduledEvent; ! FAutoFlushEvent: ScheduledEvent; FLastWrite: DateTime; FPath: string; *************** *** 523,528 **** {$REGION 'Protected methods'} strict protected ! procedure AutoFlushHandler(state: &Object); ! procedure AutoReloadHandler(state: &Object); procedure FlushImpl; function NeedFlush: Boolean; --- 522,527 ---- {$REGION 'Protected methods'} strict protected ! procedure AutoFlushHandler(event: ScheduledEvent); ! procedure AutoReloadHandler(event: ScheduledEvent); procedure FlushImpl; function NeedFlush: Boolean; *************** *** 532,535 **** --- 531,536 ---- {$REGION 'Property accessors'} public + function get_AutoFlushInterval: Integer; + function get_AutoReloadInterval: Integer; procedure set_AutoFlushInterval(value: Integer); procedure set_AutoReloadInterval(value: Integer); *************** *** 537,542 **** {$REGION 'Properties'} public ! property AutoFlushInterval: Integer read FAutoFlushInterval write set_AutoFlushInterval; ! property AutoReloadInterval: Integer read FAutoReloadInterval write set_AutoReloadInterval; {$ENDREGION} end; --- 538,543 ---- {$REGION 'Properties'} public ! property AutoFlushInterval: Integer read get_AutoFlushInterval write set_AutoFlushInterval; ! property AutoReloadInterval: Integer read get_AutoReloadInterval write set_AutoReloadInterval; {$ENDREGION} end; *************** *** 552,555 **** --- 553,605 ---- {$ENDREGION} + {$REGION 'protected classes'} + type + TimerInfo = class + strict private + FInterval: Int32; + FNextTick: Int64; + public + constructor Create(interval: Int32); + public + procedure CalculateNextTick; overload; + procedure CalculateNextTick(fromLast: Boolean); overload; + public + procedure set_Interval(value: Int32); + public + property Interval: Int32 read FInterval write set_Interval; + property NextTick: Int64 read FNextTick; + end; + {$ENDREGION} + + {$REGION 'TimerInfo'} + constructor TimerInfo.Create(interval: Int32); + begin + inherited Create; + Self.Interval := interval; + end; + + procedure TimerInfo.CalculateNextTick; + begin + CalculateNextTick(True); + end; + + procedure TimerInfo.CalculateNextTick(fromLast: Boolean); + begin + if not fromLast then + FNextTick := DateTime.UtcNow.Ticks + Interval + else + FNextTick := NextTick + Interval; + end; + + procedure TimerInfo.set_Interval(value: Int32); + begin + if value <> FInterval then + begin + FInterval := value; + CalculateNextTick(False); + end; + end; + {$ENDREGION} + {$REGION 'BufferedIniFile'} constructor BufferedIniFile.Create(path: string); *************** *** 563,570 **** FPath := path; ReloadImpl(True); Self.AutoFlushInterval := autoFlushInterval; Self.AutoReloadInterval := autoReloadInterval; - FAutoFlushTimer := Timer.Create(AutoFlushHandler, nil, FAutoFlushInterval, FAutoFlushInterval); - FAutoReloadTimer := Timer.Create(AutoReloadHandler, nil, FAutoReloadInterval, FAutoReloadInterval); end; --- 613,620 ---- FPath := path; ReloadImpl(True); + FAutoFlushEvent := ScheduledEvent.Create(0, AutoFlushHandler); + FAutoReloadEvent := ScheduledEvent.Create(0, AutoReloadHandler); Self.AutoFlushInterval := autoFlushInterval; Self.AutoReloadInterval := autoReloadInterval; end; *************** *** 579,583 **** end; ! procedure BufferedIniFile.AutoFlushHandler(state: &Object); begin Monitor.Enter(Self); --- 629,633 ---- end; ! procedure BufferedIniFile.AutoFlushHandler(event: ScheduledEvent); begin Monitor.Enter(Self); *************** *** 590,594 **** end; ! procedure BufferedIniFile.AutoReloadHandler(state: &Object); begin Monitor.Enter(Self); --- 640,644 ---- end; ! procedure BufferedIniFile.AutoReloadHandler(event: ScheduledEvent); begin Monitor.Enter(Self); *************** *** 633,638 **** procedure BufferedIniFile.Dispose; begin ! FAutoFlushTimer.Dispose; ! FAutoReloadTimer.Dispose; if HasChanges then FlushImpl; --- 683,688 ---- procedure BufferedIniFile.Dispose; begin ! FAutoReloadEvent.Interval := 0; ! FAutoFlushEvent.Interval := 0; if HasChanges then FlushImpl; *************** *** 646,649 **** --- 696,705 ---- end; + procedure BufferedIniFile.Flush; + begin + if HasChanges then + FlushImpl; + end; + procedure BufferedIniFile.FlushImpl; var *************** *** 656,663 **** end; ! procedure BufferedIniFile.Flush; begin ! if HasChanges then ! FlushImpl; end; --- 712,723 ---- end; ! function BufferedIniFile.get_AutoFlushInterval: Integer; begin ! Result := FAutoFlushEvent.Interval div 10000; ! end; ! ! function BufferedIniFile.get_AutoReloadInterval: Integer; ! begin ! Result := FAutoReloadEvent.Interval div 10000; end; *************** *** 746,758 **** procedure BufferedIniFile.set_AutoFlushInterval(value: Integer); begin ! if value < Timeout.Infinite then raise ArgumentOutOfRangeException.Create('AutoFlushInterval', ! MscorlibResources.GetResourceString('ArgumentOutOfRange_NeedNonNegOrNegative1')); ! if value <> FAutoFlushInterval then ! begin ! FAutoFlushInterval := value; ! if Assigned(FAutoFlushTimer) then ! FAutoFlushTimer.Change(value, value); ! end; end; --- 806,813 ---- procedure BufferedIniFile.set_AutoFlushInterval(value: Integer); begin ! if value < 0 then raise ArgumentOutOfRangeException.Create('AutoFlushInterval', ! MscorlibResources.GetResourceString('ArgumentOutOfRange_NeedNonNegNum')); ! FAutoFlushEvent.Interval := 10000 * value; end; *************** *** 761,771 **** if value < Timeout.Infinite then raise ArgumentOutOfRangeException.Create('AutoReloadInterval', ! MscorlibResources.GetResourceString('ArgumentOutOfRange_NeedNonNegOrNegative1')); ! if value <> FAutoReloadInterval then ! begin ! FAutoReloadInterval := value; ! if Assigned(FAutoReloadTimer) then ! FAutoReloadTimer.Change(value, value); ! end; end; --- 816,821 ---- if value < Timeout.Infinite then raise ArgumentOutOfRangeException.Create('AutoReloadInterval', ! MscorlibResources.GetResourceString('ArgumentOutOfRange_NeedNonNegNum')); ! FAutoReloadEvent.Interval := 10000 * value; end; |
From: Marcel B. <jed...@us...> - 2005-01-25 10:27:47
|
Update of /cvsroot/jedidotnet/nunit/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3468/nunit/source Modified Files: Jedi.IO.IniFiles.NUnit.pas Log Message: Updated BufferedIniFile to use the EventScheduler to schedule the AutoReload and AutoFlush. Index: Jedi.IO.IniFiles.NUnit.pas =================================================================== RCS file: /cvsroot/jedidotnet/nunit/source/Jedi.IO.IniFiles.NUnit.pas,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Jedi.IO.IniFiles.NUnit.pas 23 Jan 2005 11:08:50 -0000 1.2 --- Jedi.IO.IniFiles.NUnit.pas 25 Jan 2005 10:27:35 -0000 1.3 *************** *** 57,73 **** lastWriteDate: DateTime; begin ! ini := BufferedIniFile.Create(mainIniFilePath, Timeout.Infinite, 2000); lastWriteDate := &File.GetLastWriteTimeUtc(mainIniFilePath); ! Thread.Sleep(2100); // Slightly longer than the AutoFlush interval. Assert.AreEqual(lastWriteDate, &File.GetLastWriteTimeUtc(mainIniFilePath), 'AutoFlush with no changes.'); ini.Write('[AutoFlush]', 'LastWriteDate', lastWriteDate); Assert.AreEqual(lastWriteDate, &File.GetLastWriteTimeUtc(mainIniFilePath), 'AutoFlush directly after changes.'); ! Thread.Sleep(1000); // Less than the AutoFlush interval. ! Assert.AreEqual(lastWriteDate, &File.GetLastWriteTimeUtc(mainIniFilePath), 'AutoFlush 1s after changes.'); ! Thread.Sleep(1000); // Together with previous sleep cycles, slightly longer than the AutoFlush interval. ! Assert.IsTrue(lastWriteDate< &File.GetLastWriteTimeUtc(mainIniFilePath), 'no AutoFlush 2s after changes.'); lastWriteDate := &File.GetLastWriteTimeUtc(mainIniFilePath); ! Thread.Sleep(2100); // Slightly longer than the AutoFlush interval. ! Assert.AreEqual(lastWriteDate, &File.GetLastWriteTimeUtc(mainIniFilePath), 'AutoFlush 4s after changes.'); end; --- 57,71 ---- lastWriteDate: DateTime; begin ! ini := BufferedIniFile.Create(mainIniFilePath, 0, 100); lastWriteDate := &File.GetLastWriteTimeUtc(mainIniFilePath); ! Thread.Sleep(110); // Slightly longer than the AutoFlush interval. Assert.AreEqual(lastWriteDate, &File.GetLastWriteTimeUtc(mainIniFilePath), 'AutoFlush with no changes.'); ini.Write('[AutoFlush]', 'LastWriteDate', lastWriteDate); Assert.AreEqual(lastWriteDate, &File.GetLastWriteTimeUtc(mainIniFilePath), 'AutoFlush directly after changes.'); ! Thread.Sleep(110); // Together with previous sleep cycles, slightly longer than the AutoFlush interval. ! Assert.IsTrue(lastWriteDate< &File.GetLastWriteTimeUtc(mainIniFilePath), 'no AutoFlush 100ms after changes.'); lastWriteDate := &File.GetLastWriteTimeUtc(mainIniFilePath); ! Thread.Sleep(110); // Slightly longer than the AutoFlush interval. ! Assert.AreEqual(lastWriteDate, &File.GetLastWriteTimeUtc(mainIniFilePath), 'AutoFlush 200ms after changes.'); end; *************** *** 78,96 **** ini3: BufferedIniFile; begin ! ini1 := BufferedIniFile.Create(mainIniFilePath, 500, Timeout.Infinite); ! ini2 := BufferedIniFile.Create(mainIniFilePath, Timeout.Infinite, Timeout.Infinite); ini2.Write('SecondInstance', 'Value', 1.23); - Thread.Sleep(510); - Assert.IsFalse(ini1.SectionExists('SecondInstance'), 'Ini1 contains section before possible Reload.'); ini1.Write('FirstInstance', 'Value', 5.67); Assert.IsTrue(ini1.SectionExists('FirstInstance'), 'Ini1 should contain FirstInstance section.'); ! ini2.Free; ! Thread.Sleep(500); Assert.IsTrue(ini1.SectionExists('FirstInstance'), 'Ini1 should contain FirstInstance section after Reload.'); Assert.IsTrue(ini1.SectionExists('SecondInstance'), 'Ini1 should contain SecondInstance section after Reload.'); ! ini1.Free; ! ini3 := BufferedIniFile.Create(mainIniFilePath, Timeout.Infinite, Timeout.Infinite); ! Assert.IsTrue(ini1.SectionExists('FirstInstance'), 'Ini3 should contain FirstInstance section.'); ! Assert.IsTrue(ini1.SectionExists('SecondInstance'), 'Ini3 should contain SecondInstance section.'); ini3.Free; end; --- 76,96 ---- ini3: BufferedIniFile; begin ! ini2 := BufferedIniFile.Create(mainIniFilePath, 0, 0); ! ini1 := BufferedIniFile.Create(mainIniFilePath, 100, 0); ini2.Write('SecondInstance', 'Value', 1.23); ini1.Write('FirstInstance', 'Value', 5.67); Assert.IsTrue(ini1.SectionExists('FirstInstance'), 'Ini1 should contain FirstInstance section.'); ! Assert.IsFalse(ini1.SectionExists('SecondInstance'), 'Ini1 contains section before possible Reload.'); ! Thread.Sleep(100); // wait a bit before flushing (otherwise the file's LastWriteTime may not change (lower resolution) ! ini2.Flush; ! ini2 := nil; ! Thread.Sleep(110); // add reload interval to allow the Reload taking place Assert.IsTrue(ini1.SectionExists('FirstInstance'), 'Ini1 should contain FirstInstance section after Reload.'); Assert.IsTrue(ini1.SectionExists('SecondInstance'), 'Ini1 should contain SecondInstance section after Reload.'); ! ini1.Flush; ! ini1 := nil; ! ini3 := BufferedIniFile.Create(mainIniFilePath, 0, 0); ! Assert.IsTrue(ini3.SectionExists('FirstInstance'), 'Ini3 should contain FirstInstance section.'); ! Assert.IsTrue(ini3.SectionExists('SecondInstance'), 'Ini3 should contain SecondInstance section.'); ini3.Free; end; *************** *** 127,131 **** ini2: BufferedIniFile; begin ! ini := BufferedIniFile.Create(mainIniFilePath, Timeout.Infinite, Timeout.Infinite); Assert.IsTrue(ini.SectionExists('Basics'), 'Section ''{0}'' not found', ['Basics']); Assert.IsTrue(ini.KeyExists('MyTestString'), 'Key ''{0}'' not found.', ['MyTestString']); --- 127,131 ---- ini2: BufferedIniFile; begin ! ini := BufferedIniFile.Create(mainIniFilePath, 0, 0); Assert.IsTrue(ini.SectionExists('Basics'), 'Section ''{0}'' not found', ['Basics']); Assert.IsTrue(ini.KeyExists('MyTestString'), 'Key ''{0}'' not found.', ['MyTestString']); *************** *** 140,144 **** Assert.AreEqual(15, ini.ReadInt('New section', 'IntKey'), 'Value of [New section].IntKey incorrect.'); ini.Free; // should be written ! ini2 := BufferedIniFile.Create(mainIniFilePath, Timeout.Infinite, Timeout.Infinite); Assert.IsTrue(ini2.SectionExists('New section'), 'New section not saved.'); Assert.IsTrue(ini2.KeyExists('New section', 'IntKey'), 'IntKey not saved.'); --- 140,144 ---- Assert.AreEqual(15, ini.ReadInt('New section', 'IntKey'), 'Value of [New section].IntKey incorrect.'); ini.Free; // should be written ! ini2 := BufferedIniFile.Create(mainIniFilePath, 0, 0); Assert.IsTrue(ini2.SectionExists('New section'), 'New section not saved.'); Assert.IsTrue(ini2.KeyExists('New section', 'IntKey'), 'IntKey not saved.'); |
From: Marcel B. <jed...@us...> - 2005-01-25 10:26:22
|
Update of /cvsroot/jedidotnet/nunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3028/nunit Modified Files: Nunit.Jedi.System.bdsproj Nunit.Jedi.System.dpk Log Message: New class: EventScheduler. Index: Nunit.Jedi.System.dpk =================================================================== RCS file: /cvsroot/jedidotnet/nunit/Nunit.Jedi.System.dpk,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Nunit.Jedi.System.dpk 23 Jan 2005 11:07:42 -0000 1.6 --- Nunit.Jedi.System.dpk 25 Jan 2005 10:25:55 -0000 1.7 *************** *** 33,37 **** Jedi.System.Attributes.NUnit in 'source\Jedi.System.Attributes.NUnit.pas', Jedi.System.Strings.NUnit in 'source\Jedi.System.Strings.NUnit.pas', ! Jedi.System.SourceVersioning.NUnit in 'source\Jedi.System.SourceVersioning.NUnit.pas'; [assembly: AssemblyTitle('Nunit.Jedi.System')] --- 33,38 ---- Jedi.System.Attributes.NUnit in 'source\Jedi.System.Attributes.NUnit.pas', Jedi.System.Strings.NUnit in 'source\Jedi.System.Strings.NUnit.pas', ! Jedi.System.SourceVersioning.NUnit in 'source\Jedi.System.SourceVersioning.NUnit.pas', ! Jedi.Timers.EventScheduler_NUnit in 'source\Jedi.Timers.EventScheduler_NUnit.pas'; [assembly: AssemblyTitle('Nunit.Jedi.System')] Index: Nunit.Jedi.System.bdsproj =================================================================== RCS file: /cvsroot/jedidotnet/nunit/Nunit.Jedi.System.bdsproj,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Nunit.Jedi.System.bdsproj 23 Jan 2005 11:07:41 -0000 1.6 --- Nunit.Jedi.System.bdsproj 25 Jan 2005 10:25:55 -0000 1.7 *************** *** 45,49 **** <Compiler Name="ShowHints" Type="Boolean">True</Compiler> <Compiler Name="ShowWarnings" Type="Boolean">True</Compiler> ! <Compiler Name="UnitAliases" Type="String">WinTypes=Borland.Vcl.Windows;WinProcs=Borland.Vcl.Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;Jedi.System=Jedi.System.Attributes, Jedi.System.Strings, Jedi.System.IniFiles</Compiler> <Compiler Name="NamespacePrefix" Type="String"></Compiler> <Compiler Name="GenerateDocumentation" Type="Boolean">False</Compiler> --- 45,49 ---- <Compiler Name="ShowHints" Type="Boolean">True</Compiler> <Compiler Name="ShowWarnings" Type="Boolean">True</Compiler> ! <Compiler Name="UnitAliases" Type="String">WinTypes=Borland.Vcl.Windows;WinProcs=Borland.Vcl.Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;Jedi.System=Jedi.System.Attributes, Jedi.System.IniFiles, Jedi.System.Strings;Jedi.Timers=Jedi.Timers.EventScheduler</Compiler> <Compiler Name="NamespacePrefix" Type="String"></Compiler> <Compiler Name="GenerateDocumentation" Type="Boolean">False</Compiler> *************** *** 177,180 **** --- 177,181 ---- <File FileName="source\Jedi.System.Strings.NUnit.pas" ContainerId="" ModuleName="Jedi.System.Strings.NUnit"/> <File FileName="source\Jedi.System.SourceVersioning.NUnit.pas" ContainerId="" ModuleName="Jedi.System.SourceVersioning.NUnit"/> + <File FileName="source\Jedi.Timers.EventScheduler_NUnit.pas" ContainerId="" ModuleName="Jedi.Timers.EventScheduler_NUnit"/> </FileList> </DelphiDotNet.Personality> |
From: Marcel B. <jed...@us...> - 2005-01-25 10:26:22
|
Update of /cvsroot/jedidotnet/main/run In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3028/main/run Added Files: Jedi.Timers.EventScheduler.pas Log Message: New class: EventScheduler. --- NEW FILE: Jedi.Timers.EventScheduler.pas --- {--------------------------------------------------------------------------------------------------- The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.mozilla.org/MPL/MPL-1.1.html Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See the License for the specific language governing rights and limitations under the License. The Original Code is: Jedi.Timers.EventScheduler.pas, released on --. The Initial Developer of the Original Code is Marcel Bestebroer Portions created by Marcel Bestebroer are Copyright (C) 2004 Marcel Bestebroer All Rights Reserved. Contributor(s): You may retrieve the latest version of this file at the JEDI.NET home page, located at http://sf.net/projects/jedidotnet Known Issues: ---------------------------------------------------------------------------------------------------} // $Id: Jedi.Timers.EventScheduler.pas,v 1.1 2005/01/25 10:25:55 jedi_mbe Exp $ unit Jedi.Timers.EventScheduler; interface {$REGION 'implementation uses'} uses System.Collections, System.Threading, Jedi.System.SourceVersioning; {$ENDREGION} {$REGION 'Scheduled event class'} type ScheduledEvent = class; [JediSourceInfo('$Header: /cvsroot/jedidotnet/main/run/Jedi.Timers.EventScheduler.pas,v 1.1 2005/01/25 10:25:55 jedi_mbe Exp $')] ScheduledEventCallback = procedure(event: ScheduledEvent) of object; [JediSourceInfo('$Header: /cvsroot/jedidotnet/main/run/Jedi.Timers.EventScheduler.pas,v 1.1 2005/01/25 10:25:55 jedi_mbe Exp $')] ScheduledEvent = class sealed (&Object) {$REGION 'Constructor'} public constructor Create(interval: Int64; callback: ScheduledEventCallback); {$ENDREGION} {$REGION 'Data'} strict private FCallback: ScheduledEventCallback; FInterval: Int64; FScheduledFor: Int64; {$ENDREGION} {$REGION 'Internal methods'} strict private procedure Reschedule(fromNow: Boolean); protected procedure RunAndReschedule(state: &Object); {$ENDREGION} {$REGION 'Property access methods'} public procedure set_Interval(value: Int64); {$ENDREGION} {$REGION 'Properties'} public property Interval: Int64 read FInterval write set_Interval; property ScheduledFor: Int64 read FScheduledFor; {$ENDREGION} end; {$ENDREGION} {$REGION 'Scheduled events background thread'} type [JediSourceInfo('$Header: /cvsroot/jedidotnet/main/run/Jedi.Timers.EventScheduler.pas,v 1.1 2005/01/25 10:25:55 jedi_mbe Exp $')] ScheduledEvents = class sealed (&Object) {$REGION 'Constructors'} strict private class constructor Create; strict protected constructor Create; {$ENDREGION} {$REGION 'Data'} strict private class var FThread: Thread; class var FEvents: ArrayList; class var FNotifier: AutoResetEvent; class var FNotifications: ArrayList; {$ENDREGION} {$REGION 'Data for information on the scheduler'} strict protected class var FHasStarted: Boolean; class var FHasStopped: Boolean; class var FQueueCount: Integer; class var FWaitEndedCount: Integer; class var FEventTriggerChecks: Integer; {$ENDREGION} {$REGION 'Information on the scheduler'} public class function EventsWaiting: Integer; static; class function NotificationsWaiting: Integer; static; class property HasStarted: Boolean read FHasStarted; class property HasStopped: Boolean read FHasStopped; class property QueueCount: Integer read FQueueCount; class property WaitEndedCount: Integer read FWaitEndedCount; class property EventTriggerChecks: Integer read FEventTriggerChecks; {$ENDREGION} {$REGION 'Internal methods'} strict protected class function CompareTimes: IComparer; static; class procedure ProcessNotifications; static; class procedure TimerLoop; static; {$ENDREGION} {$REGION 'Notification methods'} protected class procedure AddEvent(event: ScheduledEvent); static; class procedure RemoveEvent(event: ScheduledEvent); static; {$ENDREGION} end; {$ENDREGION} implementation {$REGION 'implementation uses'} uses Jedi.System.FrameworkResources; {$ENDREGION} {$REGION 'protected types'} type NotificationType = (Add, Delete); NotificationInfo = record strict private FEvent: ScheduledEvent; FNotificationType: NotificationType; public constructor Create(notificationType: NotificationType; event: ScheduledEvent); property Event: ScheduledEvent read FEvent; property NotificationType: NotificationType read FNotificationType; end; type TimeComparer = class (&Object, IComparer) strict private class constructor Create; strict private class var FDefault: TimeComparer; strict protected function Compare(x, y: &Object): Integer; public class function Default: IComparer; static; end; {$ENDREGION} {$REGION 'NotificationInfo'} constructor NotificationInfo.Create(notificationType: NotificationType; event: ScheduledEvent); begin inherited Create; FEvent := event; FNotificationType := notificationType; end; {$ENDREGION} {$REGION 'ScheduledEvent'} constructor ScheduledEvent.Create(interval: Int64; callback: ScheduledEventCallback); begin inherited Create; FCallback := callback; set_Interval(interval); end; procedure ScheduledEvent.Reschedule(fromNow: Boolean); begin Monitor.Enter(Self); try if Interval > 0 then begin if fromNow or (FScheduledFor = 0) then FScheduledFor := DateTime.UtcNow.Ticks + Interval else FScheduledFor := FScheduledFor + Interval; ScheduledEvents.AddEvent(Self); end; finally Monitor.&Exit(Self); end; end; procedure ScheduledEvent.RunAndReschedule(state: &Object); begin FCallback(Self); Reschedule(False); end; procedure ScheduledEvent.set_Interval(value: Int64); begin Monitor.Enter(Self); try if value < 0 then raise ArgumentOutOfRangeException.Create('Interval', MscorlibResources.GetResourceString('ArgumentOutOfRange_NeedNonNegNum')); if value <> Interval then begin FInterval := value; ScheduledEvents.RemoveEvent(Self); if value > 0 then Reschedule(True); end; finally Monitor.&Exit(Self); end; end; {$ENDREGION} {$REGION 'ScheduledEvents'} class constructor ScheduledEvents.Create; begin FEvents := ArrayList.Create; FNotifier := AutoResetEvent.Create(False); FNotifications := ArrayList.Create; FThread := Thread.Create(ScheduledEvents.TimerLoop); FThread.IsBackground := True; FThread.Start; end; constructor ScheduledEvents.Create; begin inherited Create; end; class procedure ScheduledEvents.AddEvent(event: ScheduledEvent); begin Monitor.Enter(FNotifications); try FNotifications.Add(NotificationInfo.Create(Add, event)); finally Monitor.Exit(FNotifications); FNotifier.&Set; end; end; class function ScheduledEvents.CompareTimes: IComparer; begin Result := TimeComparer.Default; end; class procedure ScheduledEvents.ProcessNotifications; var info: NotificationInfo; idx: Integer; begin Monitor.Enter(FNotifications); try for info in FNotifications do begin if info.NotificationType = Add then begin idx := FEvents.BinarySearch(&Object(info.Event), CompareTimes); if idx < 0 then idx := not idx; FEvents.Insert(idx, info.Event); end else if info.NotificationType = Delete then FEvents.Remove(info.Event); end; FNotifications.Clear; finally Monitor.Exit(FNotifications); end; end; class procedure ScheduledEvents.RemoveEvent(event: ScheduledEvent); begin Monitor.Enter(FNotifications); try FNotifications.Add(NotificationInfo.Create(Delete, event)); finally Monitor.Exit(FNotifications); FNotifier.&Set; end; end; class procedure ScheduledEvents.TimerLoop; var maxWait: Int64; notified: Boolean; nowTicks: Int64; event: ScheduledEvent; begin FHasStarted := True; try while True do begin if FEvents.Count > 0 then begin maxWait := ScheduledEvent(FEvents[0]).ScheduledFor - DateTime.UtcNow.Ticks; if maxWait < 0 then maxWait := 1; notified := FNotifier.WaitOne(TimeSpan.Create(maxWait), False); end else notified := FNotifier.WaitOne(Timeout.Infinite, False); Inc(FWaitEndedCount); if notified then ProcessNotifications; nowTicks := DateTime.UtcNow.Ticks; Inc(FEventTriggerChecks); while (FEvents.Count > 0) and (ScheduledEvent(FEvents[0]).ScheduledFor <= nowTicks) do begin event := ScheduledEvent(FEvents[0]); FEvents.RemoveAt(0); ThreadPool.QueueUserWorkItem(event.RunAndReschedule); Inc(FQueueCount); end; end; finally FHasStopped := True; end; end; class function ScheduledEvents.EventsWaiting: Integer; begin Result := FEvents.Count; end; class function ScheduledEvents.NotificationsWaiting: Integer; begin Result := FNotifications.Count; end; {$ENDREGION} {$REGION 'TimeComparer'} class constructor TimeComparer.Create; begin FDefault := TimeComparer.Create; end; function TimeComparer.Compare(x, y: &Object): Integer; var ev1: ScheduledEvent; ev2: ScheduledEvent; begin if not Assigned(x) and not Assigned(y) then Result := 0 else if not Assigned(x) then Result := 1 else if not Assigned(y) then Result := -1 else begin ev1 := ScheduledEvent(x); ev2 := ScheduledEvent(y); if not Assigned(ev1) then raise ArgumentException.Create('', 'x'); if not Assigned(ev2) then raise ArgumentException.Create('', 'y'); Result := ev1.ScheduledFor.CompareTo(&Object(ev2.ScheduledFor)); end; end; class function TimeComparer.Default: IComparer; begin Result := FDefault; end; {$ENDREGION} end. |
From: Marcel B. <jed...@us...> - 2005-01-25 10:26:22
|
Update of /cvsroot/jedidotnet/main/assemblies In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3028/main/assemblies Modified Files: Jedi.System.bdsproj Jedi.System.dpk Log Message: New class: EventScheduler. Index: Jedi.System.dpk =================================================================== RCS file: /cvsroot/jedidotnet/main/assemblies/Jedi.System.dpk,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Jedi.System.dpk 23 Jan 2005 11:03:15 -0000 1.4 --- Jedi.System.dpk 25 Jan 2005 10:25:54 -0000 1.5 *************** *** 34,38 **** Jedi.System.Strings in '..\run\Jedi.System.Strings.pas', Jedi.System.SourceVersioning in '..\run\Jedi.System.SourceVersioning.pas', ! Jedi.System.FrameworkResources in '..\run\Jedi.System.FrameworkResources.pas'; [assembly: AssemblyTitle('Jedi.System')] --- 34,39 ---- Jedi.System.Strings in '..\run\Jedi.System.Strings.pas', Jedi.System.SourceVersioning in '..\run\Jedi.System.SourceVersioning.pas', ! Jedi.System.FrameworkResources in '..\run\Jedi.System.FrameworkResources.pas', ! Jedi.Timers.EventScheduler in '..\run\Jedi.Timers.EventScheduler.pas'; [assembly: AssemblyTitle('Jedi.System')] Index: Jedi.System.bdsproj =================================================================== RCS file: /cvsroot/jedidotnet/main/assemblies/Jedi.System.bdsproj,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Jedi.System.bdsproj 23 Jan 2005 11:03:14 -0000 1.4 --- Jedi.System.bdsproj 25 Jan 2005 10:25:54 -0000 1.5 *************** *** 178,181 **** --- 178,182 ---- <File FileName="..\run\Jedi.System.SourceVersioning.pas" ContainerId="" ModuleName="Jedi.System.SourceVersioning"/> <File FileName="..\run\Jedi.System.FrameworkResources.pas" ContainerId="" ModuleName="Jedi.System.FrameworkResources"/> + <File FileName="..\run\Jedi.Timers.EventScheduler.pas" ContainerId="" ModuleName="Jedi.Timers.EventScheduler"/> </FileList> </DelphiDotNet.Personality> |
From: Marcel B. <jed...@us...> - 2005-01-25 10:26:22
|
Update of /cvsroot/jedidotnet/nunit/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3028/nunit/source Added Files: Jedi.Timers.EventScheduler_NUnit.pas Log Message: New class: EventScheduler. --- NEW FILE: Jedi.Timers.EventScheduler_NUnit.pas --- unit Jedi.Timers.EventScheduler_NUnit; interface uses System.Collections, NUnit.Framework, Jedi.Timers.EventScheduler; type [TestFixture] EventScheduler = class strict private FEveryTwoSeconds: ScheduledEvent; FEveryTwoSecondsList: ArrayList; strict protected procedure EventCallback(event: ScheduledEvent); public [Test] procedure SingleScheduleEveryPointTwoSeconds; [Test] procedure SingleScheduleEveryPointTwoSecondsNoSleep; end; implementation uses System.Globalization, System.Threading; procedure EventScheduler.EventCallback(event: ScheduledEvent); begin if event = FEveryTwoSeconds then FEveryTwoSecondsList.Add(&Object(event.ScheduledFor)); end; procedure EventScheduler.SingleScheduleEveryPointTwoSeconds; var FirstTicks: Int64; begin FEveryTwoSecondsList := ArrayList.Create; FEveryTwoSeconds := ScheduledEvent.Create(2000000, EventCallback); FirstTicks := FEveryTwoSeconds.ScheduledFor; Thread.Sleep(410); FEveryTwoSeconds.Interval := 0; // no more events Thread.Sleep(410); Assert.IsTrue(ScheduledEvents.HasStarted, 'Thread never started.'); Assert.IsFalse(ScheduledEvents.HasStopped, 'Thread stopped.'); Assert.AreEqual(2, FEveryTwoSecondsList.Count, 'Item count after 4 seconds.'); Assert.AreEqual(Decimal(FirstTicks + 0000000), Decimal(Int64(FEveryTwoSecondsList[0])), 'Trigger 1.'); Assert.AreEqual(Decimal(FirstTicks + 2000000), Decimal(Int64(FEveryTwoSecondsList[1])), 'Trigger 2.'); FEveryTwoSeconds.Free; FEveryTwoSecondsList.Free; end; procedure EventScheduler.SingleScheduleEveryPointTwoSecondsNoSleep; var FirstTicks: Int64; begin FEveryTwoSecondsList := ArrayList.Create; FEveryTwoSeconds := ScheduledEvent.Create(2000000, EventCallback); FirstTicks := FEveryTwoSeconds.ScheduledFor; repeat until DateTime.UtcNow.Ticks > (FirstTicks + 2100000); // Thread.Sleep(410); FEveryTwoSeconds.Interval := 0; // no more events // Thread.Sleep(410); repeat until DateTime.UtcNow.Ticks > (FirstTicks + 4200000); Console.WriteLine('Events {0}; Notifications: {0}', &Object(ScheduledEvents.EventsWaiting), &Object(ScheduledEvents.NotificationsWaiting)); Assert.IsTrue(ScheduledEvents.HasStarted, 'Thread never started.'); Assert.IsFalse(ScheduledEvents.HasStopped, 'Thread stopped.'); Assert.AreEqual(2, FEveryTwoSecondsList.Count, 'Item count after 4 seconds.'); Assert.AreEqual(Decimal(FirstTicks + 0000000), Decimal(Int64(FEveryTwoSecondsList[0])), 'Trigger 1.'); Assert.AreEqual(Decimal(FirstTicks + 2000000), Decimal(Int64(FEveryTwoSecondsList[1])), 'Trigger 2.'); FEveryTwoSeconds.Free; FEveryTwoSecondsList.Free; end; end. |
From: Marcel B. <jed...@us...> - 2005-01-23 11:08:59
|
Update of /cvsroot/jedidotnet/nunit/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10394/nunit/source Modified Files: Jedi.IO.IniFiles.NUnit.pas Log Message: Added BufferedIniFile test-set. Index: Jedi.IO.IniFiles.NUnit.pas =================================================================== RCS file: /cvsroot/jedidotnet/nunit/source/Jedi.IO.IniFiles.NUnit.pas,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Jedi.IO.IniFiles.NUnit.pas 22 Jan 2005 17:59:50 -0000 1.1 --- Jedi.IO.IniFiles.NUnit.pas 23 Jan 2005 11:08:50 -0000 1.2 *************** *** 10,17 **** type [TestFixture] MemoryBased = class strict private - class var rm: ResourceManager; class constructor Create; public [Test] procedure KeyCollection; --- 10,40 ---- type [TestFixture] + BufferedFile = class + strict protected + filePath: string; + mainIniFilePath: string; + public + [TestFixtureSetUp] + procedure CreateDir; + [TestFixtureTearDown] + procedure DeleteDir; + public + [SetUp] + procedure CreateTempFileCopy; + [TearDown] + procedure DeleteTempFileCopy; + public + [Test] procedure AutoFlush; + [Test] procedure AutoReload; + [Test] procedure LoadSaveLoad; + end; + + type + [TestFixture] MemoryBased = class strict private class constructor Create; + protected + class var rm: ResourceManager; public [Test] procedure KeyCollection; *************** *** 26,30 **** System.Collections, System.IO, ! System.Text; { MemoryBased } --- 49,148 ---- System.Collections, System.IO, ! System.Text, ! System.Threading; ! ! procedure BufferedFile.AutoFlush; ! var ! ini: BufferedIniFile; ! lastWriteDate: DateTime; ! begin ! ini := BufferedIniFile.Create(mainIniFilePath, Timeout.Infinite, 2000); ! lastWriteDate := &File.GetLastWriteTimeUtc(mainIniFilePath); ! Thread.Sleep(2100); // Slightly longer than the AutoFlush interval. ! Assert.AreEqual(lastWriteDate, &File.GetLastWriteTimeUtc(mainIniFilePath), 'AutoFlush with no changes.'); ! ini.Write('[AutoFlush]', 'LastWriteDate', lastWriteDate); ! Assert.AreEqual(lastWriteDate, &File.GetLastWriteTimeUtc(mainIniFilePath), 'AutoFlush directly after changes.'); ! Thread.Sleep(1000); // Less than the AutoFlush interval. ! Assert.AreEqual(lastWriteDate, &File.GetLastWriteTimeUtc(mainIniFilePath), 'AutoFlush 1s after changes.'); ! Thread.Sleep(1000); // Together with previous sleep cycles, slightly longer than the AutoFlush interval. ! Assert.IsTrue(lastWriteDate< &File.GetLastWriteTimeUtc(mainIniFilePath), 'no AutoFlush 2s after changes.'); ! lastWriteDate := &File.GetLastWriteTimeUtc(mainIniFilePath); ! Thread.Sleep(2100); // Slightly longer than the AutoFlush interval. ! Assert.AreEqual(lastWriteDate, &File.GetLastWriteTimeUtc(mainIniFilePath), 'AutoFlush 4s after changes.'); ! end; ! ! procedure BufferedFile.AutoReload; ! var ! ini1: BufferedIniFile; ! ini2: BufferedIniFile; ! ini3: BufferedIniFile; ! begin ! ini1 := BufferedIniFile.Create(mainIniFilePath, 500, Timeout.Infinite); ! ini2 := BufferedIniFile.Create(mainIniFilePath, Timeout.Infinite, Timeout.Infinite); ! ini2.Write('SecondInstance', 'Value', 1.23); ! Thread.Sleep(510); ! Assert.IsFalse(ini1.SectionExists('SecondInstance'), 'Ini1 contains section before possible Reload.'); ! ini1.Write('FirstInstance', 'Value', 5.67); ! Assert.IsTrue(ini1.SectionExists('FirstInstance'), 'Ini1 should contain FirstInstance section.'); ! ini2.Free; ! Thread.Sleep(500); ! Assert.IsTrue(ini1.SectionExists('FirstInstance'), 'Ini1 should contain FirstInstance section after Reload.'); ! Assert.IsTrue(ini1.SectionExists('SecondInstance'), 'Ini1 should contain SecondInstance section after Reload.'); ! ini1.Free; ! ini3 := BufferedIniFile.Create(mainIniFilePath, Timeout.Infinite, Timeout.Infinite); ! Assert.IsTrue(ini1.SectionExists('FirstInstance'), 'Ini3 should contain FirstInstance section.'); ! Assert.IsTrue(ini1.SectionExists('SecondInstance'), 'Ini3 should contain SecondInstance section.'); ! ini3.Free; ! end; ! ! procedure BufferedFile.CreateDir; ! begin ! filePath := System.String.Join(Path.DirectorySeparatorChar, [Path.GetTempPath, 'Jedi.NET', 'ini_tests']); ! Directory.CreateDirectory(filePath); ! mainIniFilePath := System.String.Join(Path.DirectorySeparatorChar, [filePath, 'main.ini']); ! end; ! ! procedure BufferedFile.CreateTempFileCopy; ! var ! mem: MemoryIniFile; ! begin ! mem := MemoryIniFile.Create; ! mem.Load(StringReader.Create(MemoryBased.rm.GetString('initest'))); ! mem.Save(mainIniFilePath); ! end; ! ! procedure BufferedFile.DeleteDir; ! begin ! Directory.GetParent(filePath).Delete(True); ! end; ! ! procedure BufferedFile.DeleteTempFileCopy; ! begin ! &File.Delete(mainIniFilePath); ! end; ! ! procedure BufferedFile.LoadSaveLoad; ! var ! ini: BufferedIniFile; ! ini2: BufferedIniFile; ! begin ! ini := BufferedIniFile.Create(mainIniFilePath, Timeout.Infinite, Timeout.Infinite); ! Assert.IsTrue(ini.SectionExists('Basics'), 'Section ''{0}'' not found', ['Basics']); ! Assert.IsTrue(ini.KeyExists('MyTestString'), 'Key ''{0}'' not found.', ['MyTestString']); ! Assert.AreEqual( ! 'Abcdef ghij klmnop; 1+1=2 #a comment, or maybe not, depending on settings', ! ini.ReadString('MyTestString'), ! 'Key ''{0}''.', ! ['MyTestString']); ! ini.Write('New section', 'IntKey', 15); ! Assert.IsTrue(ini.SectionExists('New section'), 'New section not created.'); ! Assert.IsTrue(ini.KeyExists('New section', 'IntKey'), 'IntKey not created.'); ! Assert.AreEqual(15, ini.ReadInt('New section', 'IntKey'), 'Value of [New section].IntKey incorrect.'); ! ini.Free; // should be written ! ini2 := BufferedIniFile.Create(mainIniFilePath, Timeout.Infinite, Timeout.Infinite); ! Assert.IsTrue(ini2.SectionExists('New section'), 'New section not saved.'); ! Assert.IsTrue(ini2.KeyExists('New section', 'IntKey'), 'IntKey not saved.'); ! Assert.AreEqual(15, ini2.ReadInt('New section', 'IntKey'), 'Value of [New section].IntKey incorrectly saved.'); ! end; { MemoryBased } |
From: Marcel B. <jed...@us...> - 2005-01-23 11:08:24
|
Update of /cvsroot/jedidotnet/nunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10263/nunit Modified Files: Nunit.Jedi.IO.bdsproj Nunit.Jedi.IO.dpk Log Message: Added required assembly reference to Jedi.System Index: Nunit.Jedi.IO.bdsproj =================================================================== RCS file: /cvsroot/jedidotnet/nunit/Nunit.Jedi.IO.bdsproj,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Nunit.Jedi.IO.bdsproj 22 Jan 2005 17:59:49 -0000 1.3 --- Nunit.Jedi.IO.bdsproj 23 Jan 2005 11:08:15 -0000 1.4 *************** *** 124,128 **** <Directories Name="Conditionals"></Directories> <Directories Name="DebugSourceDirs"></Directories> ! <Directories Name="UsePackages">True</Directories> </Directories> <Parameters> --- 124,128 ---- <Directories Name="Conditionals"></Directories> <Directories Name="DebugSourceDirs"></Directories> ! <Directories Name="UsePackages">False</Directories> </Directories> <Parameters> *************** *** 162,165 **** --- 162,166 ---- <File FileName="..\main\bin\Jedi.IO.dll" ContainerId="DelphiDotNetAssemblyCompiler" ModuleName="Jedi.IO" AssemblyName="Jedi.IO" Version="1.0.0.0" LinkUnits="False"/> <File FileName="nunit.framework.dll" ContainerId="DelphiDotNetAssemblyCompiler" ModuleName="nunit.framework" AssemblyName="nunit.framework" Version="2.2.1.0" LinkUnits="False"/> + <File FileName="..\main\bin\Jedi.System.dll" ContainerId="DelphiDotNetAssemblyCompiler" ModuleName="Jedi.System" AssemblyName="Jedi.System" Version="1.0.0.0" LinkUnits="False"/> <File FileName="source\Jedi.IO.Paths.Nunit.pas" ContainerId="" ModuleName="Jedi.IO.Paths.Nunit"/> <File FileName="source\Jedi.IO.NUnit.pas" ContainerId="" ModuleName="Jedi.IO.NUnit"/> Index: Nunit.Jedi.IO.dpk =================================================================== RCS file: /cvsroot/jedidotnet/nunit/Nunit.Jedi.IO.dpk,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Nunit.Jedi.IO.dpk 22 Jan 2005 17:59:49 -0000 1.3 --- Nunit.Jedi.IO.dpk 23 Jan 2005 11:08:15 -0000 1.4 *************** *** 29,33 **** Borland.Delphi, Jedi.IO, ! nunit.framework; contains --- 29,34 ---- Borland.Delphi, Jedi.IO, ! nunit.framework, ! Jedi.System; contains |
From: Marcel B. <jed...@us...> - 2005-01-23 11:07:52
|
Update of /cvsroot/jedidotnet/nunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10106/nunit Modified Files: Nunit.Jedi.System.bdsproj Nunit.Jedi.System.dpk Log Message: Removed not needed assembly references Index: Nunit.Jedi.System.dpk =================================================================== RCS file: /cvsroot/jedidotnet/nunit/Nunit.Jedi.System.dpk,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Nunit.Jedi.System.dpk 22 Jan 2005 15:31:41 -0000 1.5 --- Nunit.Jedi.System.dpk 23 Jan 2005 11:07:42 -0000 1.6 *************** *** 28,35 **** Borland.Delphi, nunit.framework, ! Jedi.System, ! System, ! System.Data, ! System.XML; contains --- 28,32 ---- Borland.Delphi, nunit.framework, ! Jedi.System; contains Index: Nunit.Jedi.System.bdsproj =================================================================== RCS file: /cvsroot/jedidotnet/nunit/Nunit.Jedi.System.bdsproj,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Nunit.Jedi.System.bdsproj 22 Jan 2005 15:31:41 -0000 1.5 --- Nunit.Jedi.System.bdsproj 23 Jan 2005 11:07:41 -0000 1.6 *************** *** 121,125 **** <Directories Name="PackageDCPOutputDir" Type="String">bin</Directories> <Directories Name="SearchPath" Type="String">$(BDS)\Lib;..\main\bin</Directories> ! <Directories Name="Packages" Type="String">System.XML.dll;System.Data.dll;Jedi.System;nunit.framework.dll;Borland.Delphi</Directories> <Directories Name="Conditionals" Type="String"></Directories> <Directories Name="DebugSourceDirs" Type="String"></Directories> --- 121,125 ---- <Directories Name="PackageDCPOutputDir" Type="String">bin</Directories> <Directories Name="SearchPath" Type="String">$(BDS)\Lib;..\main\bin</Directories> ! <Directories Name="Packages" Type="String">Jedi.System;nunit.framework.dll;Borland.Delphi</Directories> <Directories Name="Conditionals" Type="String"></Directories> <Directories Name="DebugSourceDirs" Type="String"></Directories> *************** *** 171,181 **** </VersionInfoKeys> <FileList> - <File FileName="..\docs\Jedi.System.IniFiles.xml" ContainerId="File" ModuleName="Jedi.System.IniFiles"/> <File FileName="Borland.Delphi.dll" ContainerId="DelphiDotNetAssemblyCompiler" ModuleName="Borland.Delphi" AssemblyName="borland.delphi" Version="9.0.1761.24408" LinkUnits="False"/> <File FileName="nunit.framework.dll" ContainerId="DelphiDotNetAssemblyCompiler" ModuleName="nunit.framework" AssemblyName="nunit.framework" Version="2.2.1.0" LinkUnits="False"/> <File FileName="..\main\bin\Jedi.System.dll" ContainerId="DelphiDotNetAssemblyCompiler" ModuleName="Jedi.System" AssemblyName="Jedi.System" Version="1.0.0.0" LinkUnits="False"/> - <File FileName="$(SystemRoot)\microsoft.net\framework\v1.1.4322\System.dll" ContainerId="DelphiDotNetAssemblyCompiler" ModuleName="System" AssemblyName="system" Version="1.0.5000.0" LinkUnits="False"/> - <File FileName="$(SystemRoot)\microsoft.net\framework\v1.1.4322\System.Data.dll" ContainerId="DelphiDotNetAssemblyCompiler" ModuleName="System.Data" AssemblyName="system.data" Version="1.0.5000.0" LinkUnits="False"/> - <File FileName="$(SystemRoot)\microsoft.net\framework\v1.1.4322\System.XML.dll" ContainerId="DelphiDotNetAssemblyCompiler" ModuleName="System.XML" AssemblyName="system.xml" Version="1.0.5000.0" LinkUnits="False"/> <File FileName="source\Jedi.System.Attributes.NUnit.pas" ContainerId="" ModuleName="Jedi.System.Attributes.NUnit"/> <File FileName="source\Jedi.System.Strings.NUnit.pas" ContainerId="" ModuleName="Jedi.System.Strings.NUnit"/> --- 171,177 ---- |
From: Marcel B. <jed...@us...> - 2005-01-23 11:07:01
|
Update of /cvsroot/jedidotnet/main/run In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9926/main/run Modified Files: Jedi.IO.IniFiles.pas Log Message: * Used new resource static classes. * Fixed a number of bugs Index: Jedi.IO.IniFiles.pas =================================================================== RCS file: /cvsroot/jedidotnet/main/run/Jedi.IO.IniFiles.pas,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Jedi.IO.IniFiles.pas 22 Jan 2005 17:59:14 -0000 1.1 --- Jedi.IO.IniFiles.pas 23 Jan 2005 11:06:48 -0000 1.2 *************** *** 92,96 **** ReturnType: Integer; Version: Integer; - class var rm: ResourceManager; {$ENDREGION} {$REGION 'Return type constants'} --- 92,95 ---- *************** *** 127,131 **** {$REGION 'protected methods'} strict protected - class constructor Create; constructor Create(IniFile: IniFileBase; iterationType, returnType: Integer; section: string); function SectionImpl: string; virtual; abstract; --- 126,129 ---- *************** *** 318,323 **** strict private FCount: Integer; - protected - class var rm: ResourceManager; strict protected KeyType: Integer; --- 316,319 ---- *************** *** 328,333 **** {$ENDREGION 'Internal data'} {$REGION 'Constructors'} - strict private - class constructor Create; public constructor Create(IniFile: MemoryIniFileBase; keyType: Integer); overload; --- 324,327 ---- *************** *** 471,475 **** {$REGION 'Constructors'} public ! constructor Create(path: string); {$ENDREGION} {$REGION 'Data'} --- 465,470 ---- {$REGION 'Constructors'} public ! constructor Create(path: string); overload; ! constructor Create(path: string; autoReloadInterval, autoFlushInterval: Integer); overload; {$ENDREGION} {$REGION 'Data'} *************** *** 519,522 **** --- 514,524 ---- procedure WriteImpl(section, key, value: string); override; {$ENDREGION} + {$REGION 'Public interface'} + public + procedure FullReload; + procedure Flush; + procedure Reload; overload; + procedure Reload(fileOverridesChanges: Boolean); overload; + {$ENDREGION} {$REGION 'Protected methods'} strict protected *************** *** 526,530 **** function NeedFlush: Boolean; function NeedReload: Boolean; ! procedure ReloadImpl; {$ENDREGION} {$REGION 'Property accessors'} --- 528,532 ---- function NeedFlush: Boolean; function NeedReload: Boolean; ! procedure ReloadImpl(fileOverridesChanges: Boolean); {$ENDREGION} {$REGION 'Property accessors'} *************** *** 547,552 **** {$REGION 'implementation uses'} uses ! System.Globalization, ! Jedi.System.Strings; {$ENDREGION} --- 549,553 ---- {$REGION 'implementation uses'} uses ! System.Globalization; {$ENDREGION} *************** *** 554,562 **** constructor BufferedIniFile.Create(path: string); begin inherited Create(True, True); FPath := path; ! ReloadImpl; ! FAutoFlushInterval := 10000; ! FAutoReloadInterval := 1000; FAutoFlushTimer := Timer.Create(AutoFlushHandler, nil, FAutoFlushInterval, FAutoFlushInterval); FAutoReloadTimer := Timer.Create(AutoReloadHandler, nil, FAutoReloadInterval, FAutoReloadInterval); --- 555,568 ---- constructor BufferedIniFile.Create(path: string); begin + Create(path, 10000, 1000); + end; + + constructor BufferedIniFile.Create(path: string; autoReloadInterval, autoFlushInterval: Integer); + begin inherited Create(True, True); FPath := path; ! ReloadImpl(True); ! Self.AutoFlushInterval := autoFlushInterval; ! Self.AutoReloadInterval := autoReloadInterval; FAutoFlushTimer := Timer.Create(AutoFlushHandler, nil, FAutoFlushInterval, FAutoFlushInterval); FAutoReloadTimer := Timer.Create(AutoReloadHandler, nil, FAutoReloadInterval, FAutoReloadInterval); *************** *** 589,593 **** try if NeedReload then ! ReloadImpl; finally Monitor.Exit(Self); --- 595,599 ---- try if NeedReload then ! ReloadImpl(False); finally Monitor.Exit(Self); *************** *** 644,648 **** sw: StreamWriter; begin ! sw := StreamWriter.Create(&File.Open(FPath, FileMode.CreateNew, FileAccess.Write, FileShare.Read)); SaveImpl(sw, True, ';'); sw.Close; --- 650,654 ---- sw: StreamWriter; begin ! sw := StreamWriter.Create(&File.Open(FPath, FileMode.Create, FileAccess.Write, FileShare.Read)); SaveImpl(sw, True, ';'); sw.Close; *************** *** 650,653 **** --- 656,665 ---- end; + procedure BufferedIniFile.Flush; + begin + if HasChanges then + FlushImpl; + end; + function BufferedIniFile.GetEnumerator(iteratorType, returnType: Integer; sect: string): IIniFileEnumerator; begin *************** *** 700,704 **** end; ! procedure BufferedIniFile.ReloadImpl; var sr: StreamReader; --- 712,735 ---- end; ! procedure BufferedIniFile.FullReload; ! begin ! ClearImpl; ! if NeedReload then ! ReloadImpl(True); ! end; ! ! procedure BufferedIniFile.Reload; ! begin ! if NeedReload then ! ReloadImpl(False); ! end; ! ! procedure BufferedIniFile.Reload(fileOverridesChanges: Boolean); ! begin ! if NeedReload then ! ReloadImpl(fileOverridesChanges); ! end; ! ! procedure BufferedIniFile.ReloadImpl(fileOverridesChanges: Boolean); var sr: StreamReader; *************** *** 707,711 **** begin sr := StreamReader.Create(&File.Open(FPath, FileMode.Open, FileAccess.Read, FileShare.Read)); ! LoadImpl(sr, ['#', ';', ''''], False, False); FLastWrite := &File.GetLastWriteTimeUtc(FPath); sr.Close; --- 738,742 ---- begin sr := StreamReader.Create(&File.Open(FPath, FileMode.Open, FileAccess.Read, FileShare.Read)); ! LoadImpl(sr, ['#', ';', ''''], False, fileOverridesChanges); FLastWrite := &File.GetLastWriteTimeUtc(FPath); sr.Close; *************** *** 715,722 **** procedure BufferedIniFile.set_AutoFlushInterval(value: Integer); begin if value <> FAutoFlushInterval then begin FAutoFlushInterval := value; ! FAutoFlushTimer.Change(value, value); end; end; --- 746,757 ---- procedure BufferedIniFile.set_AutoFlushInterval(value: Integer); begin + if value < Timeout.Infinite then + raise ArgumentOutOfRangeException.Create('AutoFlushInterval', + MscorlibResources.GetResourceString('ArgumentOutOfRange_NeedNonNegOrNegative1')); if value <> FAutoFlushInterval then begin FAutoFlushInterval := value; ! if Assigned(FAutoFlushTimer) then ! FAutoFlushTimer.Change(value, value); end; end; *************** *** 724,731 **** procedure BufferedIniFile.set_AutoReloadInterval(value: Integer); begin if value <> FAutoReloadInterval then begin FAutoReloadInterval := value; ! FAutoReloadTimer.Change(value, value); end; end; --- 759,770 ---- procedure BufferedIniFile.set_AutoReloadInterval(value: Integer); begin + if value < Timeout.Infinite then + raise ArgumentOutOfRangeException.Create('AutoReloadInterval', + MscorlibResources.GetResourceString('ArgumentOutOfRange_NeedNonNegOrNegative1')); if value <> FAutoReloadInterval then begin FAutoReloadInterval := value; ! if Assigned(FAutoReloadTimer) then ! FAutoReloadTimer.Change(value, value); end; end; *************** *** 1108,1116 **** {$REGION 'IniFileBase.IniFileEnumerator'} - class constructor IniFileBase.IniFileEnumerator.Create; - begin - rm := ResourceManager.Create('mscorlib', TypeOf(System.String).Assembly); - end; - constructor IniFileBase.IniFileEnumerator.Create(IniFile: IniFileBase; iterationType, returnType: Integer; section: string); --- 1147,1150 ---- *************** *** 1136,1142 **** begin if (Version <> IniFile.Version) then ! raise InvalidOperationException.Create(rm.GetString('InvalidOperation_EnumFailedVersion')); if not Current then ! raise InvalidOperationException.Create(rm.GetString('InvalidOperation_EnumOpCantHappen')); Result := SectionImpl; end; --- 1170,1176 ---- begin if (Version <> IniFile.Version) then ! raise InvalidOperationException.Create(MscorlibResources.GetResourceString('InvalidOperation_EnumFailedVersion')); if not Current then ! raise InvalidOperationException.Create(MscorlibResources.GetResourceString('InvalidOperation_EnumOpCantHappen')); Result := SectionImpl; end; *************** *** 1145,1151 **** begin if (Version <> IniFile.Version) then ! raise InvalidOperationException.Create(rm.GetString('InvalidOperation_EnumFailedVersion')); if not Current then ! raise InvalidOperationException.Create(rm.GetString('InvalidOperation_EnumOpCantHappen')); Result := KeyImpl; end; --- 1179,1185 ---- begin if (Version <> IniFile.Version) then ! raise InvalidOperationException.Create(MscorlibResources.GetResourceString('InvalidOperation_EnumFailedVersion')); if not Current then ! raise InvalidOperationException.Create(MscorlibResources.GetResourceString('InvalidOperation_EnumOpCantHappen')); Result := KeyImpl; end; *************** *** 1154,1160 **** begin if (Version <> IniFile.Version) then ! raise InvalidOperationException.Create(rm.GetString('InvalidOperation_EnumFailedVersion')); if not Current then ! raise InvalidOperationException.Create(rm.GetString('InvalidOperation_EnumOpCantHappen')); Result := ValueImpl; end; --- 1188,1194 ---- begin if (Version <> IniFile.Version) then ! raise InvalidOperationException.Create(MscorlibResources.GetResourceString('InvalidOperation_EnumFailedVersion')); if not Current then ! raise InvalidOperationException.Create(MscorlibResources.GetResourceString('InvalidOperation_EnumOpCantHappen')); Result := ValueImpl; end; *************** *** 1163,1169 **** begin if (Version <> IniFile.Version) then ! raise InvalidOperationException.Create(rm.GetString('InvalidOperation_EnumFailedVersion')); if not Current then ! raise InvalidOperationException.Create(rm.GetString('InvalidOperation_EnumOpCantHappen')); case ReturnType of ReturnSectionKeyAndValue: --- 1197,1203 ---- begin if (Version <> IniFile.Version) then ! raise InvalidOperationException.Create(MscorlibResources.GetResourceString('InvalidOperation_EnumFailedVersion')); if not Current then ! raise InvalidOperationException.Create(MscorlibResources.GetResourceString('InvalidOperation_EnumOpCantHappen')); case ReturnType of ReturnSectionKeyAndValue: *************** *** 1185,1189 **** begin if (Version <> IniFile.Version) then ! raise InvalidOperationException.Create(rm.GetString('InvalidOperation_EnumFailedVersion')); Result := MoveNextImpl; Current := Result; --- 1219,1223 ---- begin if (Version <> IniFile.Version) then ! raise InvalidOperationException.Create(MscorlibResources.GetResourceString('InvalidOperation_EnumFailedVersion')); Result := MoveNextImpl; Current := Result; *************** *** 1193,1197 **** begin if (Version <> IniFile.Version) then ! raise InvalidOperationException.Create(rm.GetString('InvalidOperation_EnumFailedVersion')); Current := False; ResetImpl; --- 1227,1231 ---- begin if (Version <> IniFile.Version) then ! raise InvalidOperationException.Create(MscorlibResources.GetResourceString('InvalidOperation_EnumFailedVersion')); Current := False; ResetImpl; *************** *** 1338,1342 **** function MemoryIniFileBase.HasSectionImpl(section: string): Boolean; begin ! if not Assigned(section) or (section = '') then Result := FSections.Contains(section) else --- 1372,1376 ---- function MemoryIniFileBase.HasSectionImpl(section: string): Boolean; begin ! if Assigned(section) and (section <> '') then Result := FSections.Contains(section) else *************** *** 1560,1571 **** function MemoryIniFileBase.KeyOrValueList.Add(value: &Object): Integer; begin ! raise NotSupportedException.Create(MemoryIniFileBase.KeyValueDictionary.rm.GetString( ! 'NotSupported_ReadOnlyCollection')); end; procedure MemoryIniFileBase.KeyOrValueList.Clear; begin ! raise NotSupportedException.Create(MemoryIniFileBase.KeyValueDictionary.rm.GetString( ! 'NotSupported_ReadOnlyCollection')); end; --- 1594,1603 ---- function MemoryIniFileBase.KeyOrValueList.Add(value: &Object): Integer; begin ! raise NotSupportedException.Create(MscorlibResources.GetResourceString('NotSupported_ReadOnlyCollection')); end; procedure MemoryIniFileBase.KeyOrValueList.Clear; begin ! raise NotSupportedException.Create(MscorlibResources.GetResourceString('NotSupported_ReadOnlyCollection')); end; *************** *** 1586,1597 **** raise ArgumentNullException.Create('array'); if &array.Rank <> 1 then ! raise ArgumentException.Create(MemoryIniFileBase.KeyValueDictionary.rm.GetString( ! 'Arg_RankMultiDimNotSupported')); if (index < &array.GetLowerBound(0)) or (index > &array.GetUpperBound(0)) then ! raise ArgumentOutOfRangeException.Create('index', MemoryIniFileBase.KeyValueDictionary.rm.GetString( ! 'Arg_IndexOutOfRangeException')); tempCount := get_Count; if (index + tempCount - 1) > &array.GetUpperBound(0) then ! raise ArgumentException.Create(MemoryIniFileBase.KeyValueDictionary.rm.GetString('Arg_ArrayPlusOffTooSmall')); enum := GetEnumerator; while enum.MoveNext do --- 1618,1627 ---- raise ArgumentNullException.Create('array'); if &array.Rank <> 1 then ! raise ArgumentException.Create(MscorlibResources.GetResourceString('Arg_RankMultiDimNotSupported')); if (index < &array.GetLowerBound(0)) or (index > &array.GetUpperBound(0)) then ! raise ArgumentOutOfRangeException.Create('index', MscorlibResources.GetResourceString('Arg_IndexOutOfRangeException')); tempCount := get_Count; if (index + tempCount - 1) > &array.GetUpperBound(0) then ! raise ArgumentException.Create(MscorlibResources.GetResourceString('Arg_ArrayPlusOffTooSmall')); enum := GetEnumerator; while enum.MoveNext do *************** *** 1650,1683 **** procedure MemoryIniFileBase.KeyOrValueList.Insert(index: Integer; value: &Object); begin ! raise NotSupportedException.Create(MemoryIniFileBase.KeyValueDictionary.rm.GetString( ! 'NotSupported_ReadOnlyCollection')); end; procedure MemoryIniFileBase.KeyOrValueList.Remove(value: &Object); begin ! raise NotSupportedException.Create(MemoryIniFileBase.KeyValueDictionary.rm.GetString( ! 'NotSupported_ReadOnlyCollection')); end; procedure MemoryIniFileBase.KeyOrValueList.RemoveAt(index: Integer); begin ! raise NotSupportedException.Create(MemoryIniFileBase.KeyValueDictionary.rm.GetString( ! 'NotSupported_ReadOnlyCollection')); end; procedure MemoryIniFileBase.KeyOrValueList.set_Item(index: Integer; value: &Object); begin ! raise NotSupportedException.Create(MemoryIniFileBase.KeyValueDictionary.rm.GetString( ! 'NotSupported_ReadOnlyCollection')); end; {$ENDREGION} {$REGION 'MemoryIniFileBase.KeyValueDictionary'} - - class constructor MemoryIniFileBase.KeyValueDictionary.Create; - begin - rm := ResourceManager.Create('mscorlib', TypeOf(System.String).Assembly); - end; - constructor MemoryIniFileBase.KeyValueDictionary.Create(IniFile: MemoryIniFileBase; keyType: Integer); begin --- 1680,1703 ---- procedure MemoryIniFileBase.KeyOrValueList.Insert(index: Integer; value: &Object); begin ! raise NotSupportedException.Create(MscorlibResources.GetResourceString('NotSupported_ReadOnlyCollection')); end; procedure MemoryIniFileBase.KeyOrValueList.Remove(value: &Object); begin ! raise NotSupportedException.Create(MscorlibResources.GetResourceString('NotSupported_ReadOnlyCollection')); end; procedure MemoryIniFileBase.KeyOrValueList.RemoveAt(index: Integer); begin ! raise NotSupportedException.Create(MscorlibResources.GetResourceString('NotSupported_ReadOnlyCollection')); end; procedure MemoryIniFileBase.KeyOrValueList.set_Item(index: Integer; value: &Object); begin ! raise NotSupportedException.Create(MscorlibResources.GetResourceString('NotSupported_ReadOnlyCollection')); end; {$ENDREGION} {$REGION 'MemoryIniFileBase.KeyValueDictionary'} constructor MemoryIniFileBase.KeyValueDictionary.Create(IniFile: MemoryIniFileBase; keyType: Integer); begin *************** *** 1701,1710 **** procedure MemoryIniFileBase.KeyValueDictionary.Add(key, value: &Object); begin ! raise NotSupportedException.Create(rm.GetString('NotSupported_ReadOnlyCollection')); end; procedure MemoryIniFileBase.KeyValueDictionary.Clear; begin ! raise NotSupportedException.Create(rm.GetString('NotSupported_ReadOnlyCollection')); end; --- 1721,1730 ---- procedure MemoryIniFileBase.KeyValueDictionary.Add(key, value: &Object); begin ! raise NotSupportedException.Create(MscorlibResources.GetResourceString('NotSupported_ReadOnlyCollection')); end; procedure MemoryIniFileBase.KeyValueDictionary.Clear; begin ! raise NotSupportedException.Create(MscorlibResources.GetResourceString('NotSupported_ReadOnlyCollection')); end; *************** *** 1723,1732 **** raise ArgumentNullException.Create('array'); if &array.Rank <> 1 then ! raise ArgumentException.Create(rm.GetString('Arg_RankMultiDimNotSupported')); if (index < &array.GetLowerBound(0)) or (index > &array.GetUpperBound(0)) then ! raise ArgumentOutOfRangeException.Create('index', rm.GetString('Arg_IndexOutOfRangeException')); tempCount := get_Count; if (index + tempCount - 1) > &array.GetUpperBound(0) then ! raise ArgumentException.Create(rm.GetString('Arg_ArrayPlusOffTooSmall')); enum := GetDictionaryEnumerator; while enum.MoveNext do --- 1743,1752 ---- raise ArgumentNullException.Create('array'); if &array.Rank <> 1 then ! raise ArgumentException.Create(MscorlibResources.GetResourceString('Arg_RankMultiDimNotSupported')); if (index < &array.GetLowerBound(0)) or (index > &array.GetUpperBound(0)) then ! raise ArgumentOutOfRangeException.Create('index', MscorlibResources.GetResourceString('Arg_IndexOutOfRangeException')); tempCount := get_Count; if (index + tempCount - 1) > &array.GetUpperBound(0) then ! raise ArgumentException.Create(MscorlibResources.GetResourceString('Arg_ArrayPlusOffTooSmall')); enum := GetDictionaryEnumerator; while enum.MoveNext do *************** *** 1880,1889 **** procedure MemoryIniFileBase.KeyValueDictionary.Remove(key: &Object); begin ! raise NotSupportedException.Create(rm.GetString('NotSupported_ReadOnlyCollection')); end; procedure MemoryIniFileBase.KeyValueDictionary.set_Item(key, value: &Object); begin ! raise NotSupportedException.Create(rm.GetString('NotSupported_ReadOnlyCollection')); end; --- 1900,1909 ---- procedure MemoryIniFileBase.KeyValueDictionary.Remove(key: &Object); begin ! raise NotSupportedException.Create(MscorlibResources.GetResourceString('NotSupported_ReadOnlyCollection')); end; procedure MemoryIniFileBase.KeyValueDictionary.set_Item(key, value: &Object); begin ! raise NotSupportedException.Create(MscorlibResources.GetResourceString('NotSupported_ReadOnlyCollection')); end; *************** *** 1943,1951 **** begin if (FVersion <> FKeyValueDictionary.IniFile.Version) then ! raise InvalidOperationException.Create(MemoryIniFileBase.KeyValueDictionary.rm.GetString( ! 'InvalidOperation_EnumFailedVersion')); if (FIndex < 0) or (FIndex >= IDictionary(FKeyValueDictionary).Count) then ! raise InvalidOperationException.Create(MemoryIniFileBase.KeyValueDictionary.rm.GetString( ! 'InvalidOperation_EnumOpCantHappen')); Result := FKeyValueDictionary.GetDictionaryEntry(FIndex); end; --- 1963,1969 ---- begin if (FVersion <> FKeyValueDictionary.IniFile.Version) then ! raise InvalidOperationException.Create(MscorlibResources.GetResourceString('InvalidOperation_EnumFailedVersion')); if (FIndex < 0) or (FIndex >= IDictionary(FKeyValueDictionary).Count) then ! raise InvalidOperationException.Create(MscorlibResources.GetResourceString('InvalidOperation_EnumOpCantHappen')); Result := FKeyValueDictionary.GetDictionaryEntry(FIndex); end; *************** *** 1964,1969 **** begin if (FVersion <> FKeyValueDictionary.IniFile.Version) then ! raise InvalidOperationException.Create(MemoryIniFileBase.KeyValueDictionary.rm.GetString( ! 'InvalidOperation_EnumFailedVersion')); Inc(FIndex); Result := FIndex < IDictionary(FKeyValueDictionary).Count; --- 1982,1986 ---- begin if (FVersion <> FKeyValueDictionary.IniFile.Version) then ! raise InvalidOperationException.Create(MscorlibResources.GetResourceString('InvalidOperation_EnumFailedVersion')); Inc(FIndex); Result := FIndex < IDictionary(FKeyValueDictionary).Count; *************** *** 1975,1980 **** begin if (FVersion <> FKeyValueDictionary.IniFile.Version) then ! raise InvalidOperationException.Create(MemoryIniFileBase.KeyValueDictionary.rm.GetString( ! 'InvalidOperation_EnumFailedVersion')); FIndex := -1; end; --- 1992,1996 ---- begin if (FVersion <> FKeyValueDictionary.IniFile.Version) then ! raise InvalidOperationException.Create(MscorlibResources.GetResourceString('InvalidOperation_EnumFailedVersion')); FIndex := -1; end; *************** *** 2021,2040 **** procedure MemoryIniFile.Save(path: string); begin ! SaveImpl(StreamWriter.Create(path), True, #0); end; procedure MemoryIniFile.Save(path: string; commentChar: Char); begin ! SaveImpl(StreamWriter.Create(path), True, commentChar); end; procedure MemoryIniFile.Save(path: string; emptyLineBetweenSections: Boolean); begin ! SaveImpl(StreamWriter.Create(path), emptyLineBetweenSections, #0); end; procedure MemoryIniFile.Save(path: string; commentChar: Char; emptyLineBetweenSections: Boolean); begin ! SaveImpl(StreamWriter.Create(path), emptyLineBetweenSections, commentChar); end; --- 2037,2063 ---- procedure MemoryIniFile.Save(path: string); begin ! Save(path, #0, True); end; procedure MemoryIniFile.Save(path: string; commentChar: Char); begin ! Save(path, commentChar, True); end; procedure MemoryIniFile.Save(path: string; emptyLineBetweenSections: Boolean); begin ! Save(path, #0, emptyLineBetweenSections); end; procedure MemoryIniFile.Save(path: string; commentChar: Char; emptyLineBetweenSections: Boolean); + var + sw: StreamWriter; begin ! sw := StreamWriter.Create(path); ! try ! SaveImpl(sw, emptyLineBetweenSections, commentChar); ! finally ! sw.Close; ! end; end; |
From: Marcel B. <jed...@us...> - 2005-01-23 11:06:03
|
Update of /cvsroot/jedidotnet/main/assemblies In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9769/main/assemblies Modified Files: Jedi.IO.bdsproj Log Message: Used new resource static classes. Index: Jedi.IO.bdsproj =================================================================== RCS file: /cvsroot/jedidotnet/main/assemblies/Jedi.IO.bdsproj,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Jedi.IO.bdsproj 22 Jan 2005 17:59:14 -0000 1.4 --- Jedi.IO.bdsproj 23 Jan 2005 11:05:51 -0000 1.5 *************** *** 45,49 **** <Compiler Name="ShowHints">True</Compiler> <Compiler Name="ShowWarnings">True</Compiler> ! <Compiler Name="UnitAliases">WinTypes=Borland.Vcl.Windows;WinProcs=Borland.Vcl.Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;Jedi.System=Jedi.System.Attributes, Jedi.System.Strings, Jedi.System.SourceVersioning;Jedi.Collections=Jedi.Collections.InlineEditable</Compiler> <Compiler Name="NamespacePrefix"></Compiler> <Compiler Name="GenerateDocumentation">True</Compiler> --- 45,49 ---- <Compiler Name="ShowHints">True</Compiler> <Compiler Name="ShowWarnings">True</Compiler> ! <Compiler Name="UnitAliases">WinTypes=Borland.Vcl.Windows;WinProcs=Borland.Vcl.Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;Jedi.System=Jedi.System.Attributes, Jedi.System.FrameworkResources, Jedi.System.Strings, Jedi.System.SourceVersioning;Jedi.Collections=Jedi.Collections.InlineEditable</Compiler> <Compiler Name="NamespacePrefix"></Compiler> <Compiler Name="GenerateDocumentation">True</Compiler> |
From: Marcel B. <jed...@us...> - 2005-01-23 11:06:02
|
Update of /cvsroot/jedidotnet/main/run In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9769/main/run Modified Files: Jedi.Collections.InlineEditable.pas Log Message: Used new resource static classes. Index: Jedi.Collections.InlineEditable.pas =================================================================== RCS file: /cvsroot/jedidotnet/main/run/Jedi.Collections.InlineEditable.pas,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Jedi.Collections.InlineEditable.pas 22 Jan 2005 15:05:05 -0000 1.2 --- Jedi.Collections.InlineEditable.pas 23 Jan 2005 11:05:51 -0000 1.3 *************** *** 159,163 **** uses System.ComponentModel.Design, ! System.Resources; {$ENDREGION} --- 159,163 ---- uses System.ComponentModel.Design, ! Jedi.System.FrameworkResources; {$ENDREGION} *************** *** 992,1007 **** {$REGION 'InlineCollectionUtils'} class function InlineCollectionUtils.CollectionConverterText: string; - var - rm: ResourceManager; begin if FCollectionValue = System.String.Empty then ! begin ! rm := ResourceManager.Create('System', TypeOf(Uri).Module.Assembly); ! try ! FCollectionValue := rm.GetString('CollectionConverterText'); ! finally ! rm.Free; ! end; ! end; Result := FCollectionValue; end; --- 992,998 ---- {$REGION 'InlineCollectionUtils'} class function InlineCollectionUtils.CollectionConverterText: string; begin if FCollectionValue = System.String.Empty then ! FCollectionValue := SystemResources.GetResourceString('CollectionConverterText'); Result := FCollectionValue; end; |
From: Marcel B. <jed...@us...> - 2005-01-23 11:04:14
|
Update of /cvsroot/jedidotnet/main/assemblies In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9343/main/assemblies Modified Files: Jedi.System.bdsproj Jedi.System.dpk Log Message: Added static class to access resource strings from the mscorlib and System assemblies. Index: Jedi.System.dpk =================================================================== RCS file: /cvsroot/jedidotnet/main/assemblies/Jedi.System.dpk,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Jedi.System.dpk 22 Jan 2005 14:38:23 -0000 1.3 --- Jedi.System.dpk 23 Jan 2005 11:03:15 -0000 1.4 *************** *** 33,37 **** Jedi.System.Attributes in '..\run\Jedi.System.Attributes.pas', Jedi.System.Strings in '..\run\Jedi.System.Strings.pas', ! Jedi.System.SourceVersioning in '..\run\Jedi.System.SourceVersioning.pas'; [assembly: AssemblyTitle('Jedi.System')] --- 33,38 ---- Jedi.System.Attributes in '..\run\Jedi.System.Attributes.pas', Jedi.System.Strings in '..\run\Jedi.System.Strings.pas', ! Jedi.System.SourceVersioning in '..\run\Jedi.System.SourceVersioning.pas', ! Jedi.System.FrameworkResources in '..\run\Jedi.System.FrameworkResources.pas'; [assembly: AssemblyTitle('Jedi.System')] Index: Jedi.System.bdsproj =================================================================== RCS file: /cvsroot/jedidotnet/main/assemblies/Jedi.System.bdsproj,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Jedi.System.bdsproj 22 Jan 2005 14:38:23 -0000 1.3 --- Jedi.System.bdsproj 23 Jan 2005 11:03:14 -0000 1.4 *************** *** 177,180 **** --- 177,181 ---- <File FileName="..\run\Jedi.System.Strings.pas" ContainerId="" ModuleName="Jedi.System.Strings"/> <File FileName="..\run\Jedi.System.SourceVersioning.pas" ContainerId="" ModuleName="Jedi.System.SourceVersioning"/> + <File FileName="..\run\Jedi.System.FrameworkResources.pas" ContainerId="" ModuleName="Jedi.System.FrameworkResources"/> </FileList> </DelphiDotNet.Personality> |
From: Marcel B. <jed...@us...> - 2005-01-23 11:03:34
|
Update of /cvsroot/jedidotnet/main/run In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9343/main/run Added Files: Jedi.System.FrameworkResources.pas Log Message: Added static class to access resource strings from the mscorlib and System assemblies. --- NEW FILE: Jedi.System.FrameworkResources.pas --- {--------------------------------------------------------------------------------------------------- The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.mozilla.org/MPL/MPL-1.1.html Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See the License for the specific language governing rights and limitations under the License. The Original Code is: Jedi.System.FrameworkResources.pas, released on 2005-01-23. The Initial Developer of the Original Code is Marcel Bestebroer Portions created by Marcel Bestebroer are Copyright (C) 2004 Marcel Bestebroer All Rights Reserved. Contributor(s): You may retrieve the latest version of this file at the JEDI.NET home page, located at http://sf.net/projects/jedidotnet Known Issues: ---------------------------------------------------------------------------------------------------} // $Id: Jedi.System.FrameworkResources.pas,v 1.1 2005/01/23 11:03:16 jedi_mbe Exp $ unit Jedi.System.FrameworkResources; interface {$REGION 'interface uses'} uses Jedi.System.SourceVersioning, System.Globalization, System.Resources; {$ENDREGION} {$REGION 'mscorlib resources'} type [JediSourceInfo('$Header: /cvsroot/jedidotnet/main/run/Jedi.System.FrameworkResources.pas,v 1.1 2005/01/23 11:03:16 jedi_mbe Exp $')] MscorlibResources = class sealed (&Object) {$REGION 'Constructors'} strict private class constructor Create; strict protected constructor Create; {$ENDREGION} {$REGION 'Data'} strict private class var rm: ResourceManager; {$ENDREGION} {$REGION 'String retrieval'} public class function GetResourceString(id: string): string; overload; static; class function GetResourceString(culture: CultureInfo; id: string): string; overload; static; class function GetResourceString(id: string; arg0: &Object): string; overload; static; class function GetResourceString(culture: CultureInfo; id: string; arg0: &Object): string; overload; static; class function GetResourceString(id: string; arg0, arg1: &Object): string; overload; static; class function GetResourceString(culture: CultureInfo; id: string; arg0, arg1: &Object): string; overload; static; class function GetResourceString(id: string; arg0, arg1, arg2: &Object): string; overload; static; class function GetResourceString(culture: CultureInfo; id: string; arg0, arg1, arg2: &Object): string; overload; static; class function GetResourceString(id: string; args: array of &Object): string; overload; static; class function GetResourceString(culture: CultureInfo; id: string; args: array of &Object): string; overload; static; {$ENDREGION} end; {$ENDREGION} {$REGION 'System resources'} type [JediSourceInfo('$Header: /cvsroot/jedidotnet/main/run/Jedi.System.FrameworkResources.pas,v 1.1 2005/01/23 11:03:16 jedi_mbe Exp $')] SystemResources = class sealed (&Object) {$REGION 'Constructors'} strict private class constructor Create; strict protected constructor Create; {$ENDREGION} {$REGION 'Data'} strict private class var rm: ResourceManager; {$ENDREGION} {$REGION 'String retrieval'} public class function GetResourceString(id: string): string; overload; static; class function GetResourceString(culture: CultureInfo; id: string): string; overload; static; class function GetResourceString(id: string; arg0: &Object): string; overload; static; class function GetResourceString(culture: CultureInfo; id: string; arg0: &Object): string; overload; static; class function GetResourceString(id: string; arg0, arg1: &Object): string; overload; static; class function GetResourceString(culture: CultureInfo; id: string; arg0, arg1: &Object): string; overload; static; class function GetResourceString(id: string; arg0, arg1, arg2: &Object): string; overload; static; class function GetResourceString(culture: CultureInfo; id: string; arg0, arg1, arg2: &Object): string; overload; static; class function GetResourceString(id: string; args: array of &Object): string; overload; static; class function GetResourceString(culture: CultureInfo; id: string; args: array of &Object): string; overload; static; {$ENDREGION} end; {$ENDREGION} implementation {$REGION 'MscorlibResources'} class constructor MscorlibResources.Create; begin rm := ResourceManager.Create('mscorlib', TypeOf(System.String).Assembly); end; constructor MscorlibResources.Create; begin inherited Create; end; class function MscorlibResources.GetResourceString(id: string): string; begin Result := GetResourceString(CultureInfo.CurrentCulture, id); end; class function MscorlibResources.GetResourceString(culture: CultureInfo; id: string): string; begin Result := rm.GetString(id, culture); end; class function MscorlibResources.GetResourceString(id: string; arg0: &Object): string; begin Result := System.String.Format(GetResourceString(CultureInfo.CurrentCulture, id), arg0); end; class function MscorlibResources.GetResourceString(culture: CultureInfo; id: string; arg0: &Object): string; begin Result := System.String.Format(GetResourceString(culture, id), arg0); end; class function MscorlibResources.GetResourceString(id: string; arg0, arg1: &Object): string; begin Result := System.String.Format(GetResourceString(CultureInfo.CurrentCulture, id), arg0, arg1); end; class function MscorlibResources.GetResourceString(culture: CultureInfo; id: string; arg0, arg1: &Object): string; begin Result := System.String.Format(GetResourceString(culture, id), arg0, arg1); end; class function MscorlibResources.GetResourceString(id: string; arg0, arg1, arg2: &Object): string; begin Result := System.String.Format(GetResourceString(CultureInfo.CurrentCulture, id), arg0, arg1, arg2); end; class function MscorlibResources.GetResourceString(culture: CultureInfo; id: string; arg0, arg1, arg2: &Object): string; begin Result := System.String.Format(GetResourceString(culture, id), arg0, arg1, arg2); end; class function MscorlibResources.GetResourceString(id: string; args: array of &Object): string; begin Result := System.String.Format(GetResourceString(CultureInfo.CurrentCulture, id), args); end; class function MscorlibResources.GetResourceString(culture: CultureInfo; id: string; args: array of &Object): string; begin Result := System.String.Format(GetResourceString(culture, id), args); end; {$ENDREGION} {$REGION 'SystemResources'} class constructor SystemResources.Create; begin rm := ResourceManager.Create('System', TypeOf(Uri).Assembly); end; constructor SystemResources.Create; begin inherited Create; end; class function SystemResources.GetResourceString(id: string): string; begin Result := GetResourceString(CultureInfo.CurrentCulture, id); end; class function SystemResources.GetResourceString(culture: CultureInfo; id: string): string; begin Result := rm.GetString(id, culture); end; class function SystemResources.GetResourceString(id: string; arg0: &Object): string; begin Result := System.String.Format(GetResourceString(CultureInfo.CurrentCulture, id), arg0); end; class function SystemResources.GetResourceString(culture: CultureInfo; id: string; arg0: &Object): string; begin Result := System.String.Format(GetResourceString(culture, id), arg0); end; class function SystemResources.GetResourceString(id: string; arg0, arg1: &Object): string; begin Result := System.String.Format(GetResourceString(CultureInfo.CurrentCulture, id), arg0, arg1); end; class function SystemResources.GetResourceString(culture: CultureInfo; id: string; arg0, arg1: &Object): string; begin Result := System.String.Format(GetResourceString(culture, id), arg0, arg1); end; class function SystemResources.GetResourceString(id: string; arg0, arg1, arg2: &Object): string; begin Result := System.String.Format(GetResourceString(CultureInfo.CurrentCulture, id), arg0, arg1, arg2); end; class function SystemResources.GetResourceString(culture: CultureInfo; id: string; arg0, arg1, arg2: &Object): string; begin Result := System.String.Format(GetResourceString(culture, id), arg0, arg1, arg2); end; class function SystemResources.GetResourceString(id: string; args: array of &Object): string; begin Result := System.String.Format(GetResourceString(CultureInfo.CurrentCulture, id), args); end; class function SystemResources.GetResourceString(culture: CultureInfo; id: string; args: array of &Object): string; begin Result := System.String.Format(GetResourceString(culture, id), args); end; {$ENDREGION} end. |
From: Marcel B. <jed...@us...> - 2005-01-22 17:59:59
|
Update of /cvsroot/jedidotnet/nunit/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25409/nunit/source Added Files: Jedi.IO.IniFiles.NUnit.pas Removed Files: Jedi.System.IniFile.NUnit.pas Log Message: * Renamed Jedi.System.IniFiles to Jedi.IO.IniFiles * Added Jedi.IO.IniFIles to Jedi.IO package * Renamed classes from *ConfigFile* to *IniFile* * renamed classes from InMemory* to Memory* --- Jedi.System.IniFile.NUnit.pas DELETED --- --- NEW FILE: Jedi.IO.IniFiles.NUnit.pas --- unit Jedi.IO.IniFiles.NUnit; interface uses System.Resources, Jedi.IO.IniFiles, NUnit.Framework; type [TestFixture] MemoryBased = class strict private class var rm: ResourceManager; class constructor Create; public [Test] procedure KeyCollection; [Test] procedure Loading; [Test] procedure SectionCollection; [Test] procedure SectionKeyCollection; end; implementation uses System.Collections, System.IO, System.Text; { MemoryBased } class constructor MemoryBased.Create; begin rm := ResourceManager.Create('Jedi.IO.IniFiles', TypeOf(MemoryBased).Assembly); end; procedure MemoryBased.KeyCollection; var mem: MemoryIniFile; kc: ICollection; kl: IList; begin mem := MemoryIniFile.Create; mem.Load(StringReader.Create(rm.GetString('initest'))); kc := mem.Keys; Assert.IsNotNull(kc, 'MemoryIniFile.Keys does not return an ICollection.'); kl := IList(kc); Assert.IsNotNull(kl, 'MemoryIniFile.Keys does not return an IList.'); Assert.AreEqual(1, kl.Count, 'Count'); Assert.AreEqual('MyTestString', kl[0], 'Item[0]'); kl := IList(mem.Keys('')); Assert.IsNotNull(kl, 'MemoryIniFile.Keys('''') does not return an IList.'); Assert.AreEqual(1, kl.Count, 'Count'); Assert.AreEqual('MyTestString', kl[0], 'Item[0] (empty section name)'); kl := IList(mem.Keys('TempList')); Assert.IsNotNull(kl, 'MemoryIniFile.Keys(''TempList'') does not return an IList.'); Assert.AreEqual(4, kl.Count, 'Count (TempList)'); Assert.AreEqual('Count', kl[0], 'Item[0] (TempList)'); Assert.AreEqual('Item1', kl[1], 'Item[1] (TempList)'); Assert.AreEqual('Item2', kl[2], 'Item[2] (TempList)'); Assert.AreEqual('Item3', kl[3], 'Item[3] (TempList)'); end; procedure MemoryBased.Loading; var mem: MemoryIniFile; begin mem := MemoryIniFile.Create; mem.Load(StringReader.Create(rm.GetString('initest'))); Assert.IsTrue(mem.SectionExists('Basics'), 'Section ''{0}'' not found', ['Basics']); Assert.IsTrue(mem.KeyExists('MyTestString'), 'Key ''{0}'' not found.', ['MyTestString']); Assert.AreEqual( 'Abcdef ghij klmnop; 1+1=2 #a comment, or maybe not, depending on settings', mem.ReadString('MyTestString'), 'Key ''{0}''.', ['MyTestString']); end; procedure MemoryBased.SectionCollection; var mem: MemoryIniFile; sc: ICollection; sl: IList; begin mem := MemoryIniFile.Create; mem.Load(StringReader.Create(rm.GetString('initest'))); sc := mem.Sections; Assert.IsNotNull(sc, 'MemoryIniFile.Sections does not return an ICollection.'); sl := IList(sc); Assert.IsNotNull(sl, 'MemoryIniFile.Sections does not return an IList.'); Assert.AreEqual(2, sl.Count, 'sl.Count'); Assert.AreEqual('Basics', sl[0], 'sl[0]'); Assert.AreEqual('TempList', sl[1], 'sl[1]'); end; procedure MemoryBased.SectionKeyCollection; type StringArray = array of string; var mem: MemoryIniFile; sc: ICollection; sl: IList; strArray: StringArray; enumC: IEnumerator; enumA: IEnumerator; begin mem := MemoryIniFile.Create; mem.Load(StringReader.Create(rm.GetString('initest'))); sc := mem.SectionKeys; Assert.IsNotNull(sc, 'MemoryIniFile.SectionKeys does not return an ICollection.'); sl := IList(sc); Assert.IsNotNull(sl, 'MemoryIniFile.SectionKeys does not return an IList.'); Assert.IsTrue(sl.IsReadOnly, 'IsReadOnly'); Assert.IsTrue(sl.IsFixedSize, 'IsFixedSize'); Assert.IsFalse(sl.IsSynchronized, 'IsReadOnly'); Assert.AreEqual(9, sl.Count, 'sl.Count'); Assert.AreEqual('MyTestString', sl[0], 'sl[0]'); Assert.AreEqual( System.String.Concat('Basics', IniFileBase.SectionKeySeperatorChar, 'AutoWriteSettings'), sl[1], 'sl[1]'); Assert.AreEqual( System.String.Concat('Basics', IniFileBase.SectionKeySeperatorChar, 'EmptyString'), sl[2], 'sl[2]'); Assert.AreEqual( System.String.Concat('Basics', IniFileBase.SectionKeySeperatorChar, 'TestString'), sl[3], 'sl[3]'); Assert.AreEqual( System.String.Concat('Basics', IniFileBase.SectionKeySeperatorChar, 'UseKeyMapper'), sl[4], 'sl[4]'); Assert.AreEqual( System.String.Concat('TempList', IniFileBase.SectionKeySeperatorChar, 'Count'), sl[5], 'sl[5]'); Assert.AreEqual( System.String.Concat('TempList', IniFileBase.SectionKeySeperatorChar, 'Item1'), sl[6], 'sl[6]'); Assert.AreEqual( System.String.Concat('TempList', IniFileBase.SectionKeySeperatorChar, 'Item2'), sl[7], 'sl[7]'); Assert.AreEqual( System.String.Concat('TempList', IniFileBase.SectionKeySeperatorChar, 'Item3'), sl[8], 'sl[8]'); strArray := StringArray.Create( 'MyTestString', System.String.Concat('Basics', IniFileBase.SectionKeySeperatorChar, 'AutoWriteSettings'), System.String.Concat('Basics', IniFileBase.SectionKeySeperatorChar, 'EmptyString'), System.String.Concat('Basics', IniFileBase.SectionKeySeperatorChar, 'TestString'), System.String.Concat('Basics', IniFileBase.SectionKeySeperatorChar, 'UseKeyMapper'), System.String.Concat('TempList', IniFileBase.SectionKeySeperatorChar, 'Count'), System.String.Concat('TempList', IniFileBase.SectionKeySeperatorChar, 'Item1'), System.String.Concat('TempList', IniFileBase.SectionKeySeperatorChar, 'Item2'), System.String.Concat('TempList', IniFileBase.SectionKeySeperatorChar, 'Item3'), ); enumC := sc.GetEnumerator; enumA := &Array(strArray).GetEnumerator; while enumC.MoveNext and enumA.MoveNext do Assert.AreEqual(enumA.Current, enumC.Current, 'Enumerator check.'); end; end. |
From: Marcel B. <jed...@us...> - 2005-01-22 17:59:59
|
Update of /cvsroot/jedidotnet/nunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25409/nunit Modified Files: Nunit.Jedi.IO.bdsproj Nunit.Jedi.IO.dpk Log Message: * Renamed Jedi.System.IniFiles to Jedi.IO.IniFiles * Added Jedi.IO.IniFIles to Jedi.IO package * Renamed classes from *ConfigFile* to *IniFile* * renamed classes from InMemory* to Memory* Index: Nunit.Jedi.IO.bdsproj =================================================================== RCS file: /cvsroot/jedidotnet/nunit/Nunit.Jedi.IO.bdsproj,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Nunit.Jedi.IO.bdsproj 6 Dec 2004 11:44:09 -0000 1.2 --- Nunit.Jedi.IO.bdsproj 22 Jan 2005 17:59:49 -0000 1.3 *************** *** 45,49 **** <Compiler Name="ShowHints">True</Compiler> <Compiler Name="ShowWarnings">True</Compiler> ! <Compiler Name="UnitAliases">WinTypes=Borland.Vcl.Windows;WinProcs=Borland.Vcl.Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;Jedi.System=Jedi.System.Attributes, Jedi.System.Strings;Jedi.Collections=Jedi.Collections.InlineEditable;Jedi.IO=Jedi.IO.Paths</Compiler> <Compiler Name="NamespacePrefix"></Compiler> <Compiler Name="GenerateDocumentation">False</Compiler> --- 45,49 ---- <Compiler Name="ShowHints">True</Compiler> <Compiler Name="ShowWarnings">True</Compiler> ! <Compiler Name="UnitAliases">WinTypes=Borland.Vcl.Windows;WinProcs=Borland.Vcl.Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;Jedi.System=Jedi.System.Attributes, Jedi.System.Strings, Jedi.System.SourceVersioning;Jedi.Collections=Jedi.Collections.InlineEditable;Jedi.IO=Jedi.IO.FileOfRec, Jedi.IO.IniFiles, Jedi.IO.Paths</Compiler> <Compiler Name="NamespacePrefix"></Compiler> <Compiler Name="GenerateDocumentation">False</Compiler> *************** *** 120,128 **** <Directories Name="PackageDLLOutputDir">bin</Directories> <Directories Name="PackageDCPOutputDir">bin</Directories> ! <Directories Name="SearchPath">$(BDS)\Lib;..\main\bin</Directories> <Directories Name="Packages">nunit.framework.dll;Jedi.IO;Borland.Delphi</Directories> <Directories Name="Conditionals"></Directories> <Directories Name="DebugSourceDirs"></Directories> ! <Directories Name="UsePackages">False</Directories> </Directories> <Parameters> --- 120,128 ---- <Directories Name="PackageDLLOutputDir">bin</Directories> <Directories Name="PackageDCPOutputDir">bin</Directories> ! <Directories Name="SearchPath">$(BDS)\Lib;..\main\bin;resources</Directories> <Directories Name="Packages">nunit.framework.dll;Jedi.IO;Borland.Delphi</Directories> <Directories Name="Conditionals"></Directories> <Directories Name="DebugSourceDirs"></Directories> ! <Directories Name="UsePackages">True</Directories> </Directories> <Parameters> *************** *** 158,161 **** --- 158,162 ---- </VersionInfoKeys> <FileList> + <File FileName="resources\Jedi.IO.IniFiles.resx" ContainerId="ResXCompiler" ModuleName="Jedi.IO.IniFiles"/> <File FileName="Borland.Delphi.dll" ContainerId="DelphiDotNetAssemblyCompiler" ModuleName="Borland.Delphi" AssemblyName="borland.delphi" Version="9.0.1761.24408" LinkUnits="False"/> <File FileName="..\main\bin\Jedi.IO.dll" ContainerId="DelphiDotNetAssemblyCompiler" ModuleName="Jedi.IO" AssemblyName="Jedi.IO" Version="1.0.0.0" LinkUnits="False"/> *************** *** 163,166 **** --- 164,168 ---- <File FileName="source\Jedi.IO.Paths.Nunit.pas" ContainerId="" ModuleName="Jedi.IO.Paths.Nunit"/> <File FileName="source\Jedi.IO.NUnit.pas" ContainerId="" ModuleName="Jedi.IO.NUnit"/> + <File FileName="source\Jedi.IO.IniFiles.NUnit.pas" ContainerId="" ModuleName="Jedi.IO.IniFiles.NUnit"/> </FileList> </DelphiDotNet.Personality> Index: Nunit.Jedi.IO.dpk =================================================================== RCS file: /cvsroot/jedidotnet/nunit/Nunit.Jedi.IO.dpk,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Nunit.Jedi.IO.dpk 6 Dec 2004 11:44:09 -0000 1.2 --- Nunit.Jedi.IO.dpk 22 Jan 2005 17:59:49 -0000 1.3 *************** *** 24,27 **** --- 24,28 ---- {$IMAGEBASE $400000} {$IMPLICITBUILD OFF} + {$R 'resources\Jedi.IO.IniFiles.resources' 'resources\Jedi.IO.IniFiles.resx'} requires *************** *** 32,36 **** contains Jedi.IO.Paths.Nunit in 'source\Jedi.IO.Paths.Nunit.pas', ! Jedi.IO.NUnit in 'source\Jedi.IO.NUnit.pas'; [assembly: AssemblyTitle('Nunit.Jedi.IO')] --- 33,38 ---- contains Jedi.IO.Paths.Nunit in 'source\Jedi.IO.Paths.Nunit.pas', ! Jedi.IO.NUnit in 'source\Jedi.IO.NUnit.pas', ! Jedi.IO.IniFiles.NUnit in 'source\Jedi.IO.IniFiles.NUnit.pas'; [assembly: AssemblyTitle('Nunit.Jedi.IO')] |