Initial import

This commit is contained in:
mlemanczyk committed 2012-09-24 20:55:07 +02:00
1 parent ea3f8549e4
commit fa6feafba7
133 files changed
+17503 -4

No files matched your search

@@ -0,0 +1,63 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using DelphiProjectHandler.Model;
using DelphiProjectHandler.Operations;
using System.IO;
namespace DelphiProjectHandler.Tests
{
[TestFixture]
public class BulkOperationLoaderTests
{
protected const string cXml =
@"<?xml version=""1.0"" encoding=""UTF-8""?>" +
@"<projects>" +
@" <project name=""c:\source\fpm\dpr\Murte2mm.dpr"">" +
@" <remove>" +
@" <file>c:\source\fpm\u\Utils\RteSegsUtils.pas</file>" +
@" <file>c:\source\fpm\u\Utils\NextDataRefreshTimeState.pas</file>" +
@" </remove>" +
@" <add>" +
@" <file>c:\source\fpm\u\Utils\AbsoluteIdUtils.pas</file>" +
@" <file>c:\source\fpm\u\Utils\CycleDateState.pas</file>" +
@" </add>" +
@" </project>" +
@" <project name=""c:\source\fpm\dpr\Code.dpr"">" +
@" <remove>" +
@" <file>c:\source\fpm\u\Utils\AbsoluteIdUtils.pas</file>" +
@" </remove>" +
@" <add>" +
@" <file>c:\source\fpm\u\IO\CodeTableInterface.pas</file>" +
@" <file>c:\source\fpm\u\IO\CodeTable.pas</file>" +
@" </add>" +
@" </project>" +
@"</projects>";
[Test]
public void Load()
{
Stream vMemoryStream = new MemoryStream();
TextWriter vWriter = new StreamWriter(vMemoryStream);
vWriter.Write(cXml);
vWriter.Flush();
vMemoryStream.Position = 0;
ProjectBulkOperations vOperations = ProjectBulkOperationLoader.FromStream(vMemoryStream);
Assert.AreEqual(2, vOperations.Count, "Invalid no. of projects read");
Assert.AreEqual(2, vOperations[0].Add.Count, "Invalid no. of files to add - Project 0");
Assert.AreEqual(2, vOperations[1].Add.Count, "Invalid no. of files to add - Project 1");
Assert.AreEqual(2, vOperations[0].Remove.Count, "Invalid no. of files to remove - Project 0");
Assert.AreEqual(1, vOperations[1].Remove.Count, "Invalid no. of files to remove - Project 1");
Assert.AreEqual(@"c:\source\fpm\u\Utils\RteSegsUtils.pas", vOperations[0].Remove[0], "Wrong file to remove. Project 0, Item 0");
Assert.AreEqual(@"c:\source\fpm\u\Utils\NextDataRefreshTimeState.pas", vOperations[0].Remove[1], "Wrong file to remove. Project 0, Item 1");
Assert.AreEqual(@"c:\source\fpm\u\Utils\AbsoluteIdUtils.pas", vOperations[0].Add[0], "Wrong file to add. Project 0, Item 0");
Assert.AreEqual(@"c:\source\fpm\u\Utils\CycleDateState.pas", vOperations[0].Add[1], "Wrong file to add. Project 0, Item 1");
Assert.AreEqual(@"c:\source\fpm\u\Utils\AbsoluteIdUtils.pas", vOperations[1].Remove[0], "Wrong file to remove. Project 1, Item 0");
Assert.AreEqual(@"c:\source\fpm\u\IO\CodeTableInterface.pas", vOperations[1].Add[0], "Wrong file to add. Project 1, Item 0");
Assert.AreEqual(@"c:\source\fpm\u\IO\CodeTable.pas", vOperations[1].Add[1], "Wrong file to add. Project 1, Item 1");
}
}
}
@@ -0,0 +1,149 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{C5750BD9-B5F5-49D4-BE26-5883BFA2894F}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>DelphiProjectHandler.Tests</RootNamespace>
<AssemblyName>DelphiProjectHandler.Tests</AssemblyName>
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>3.5</OldToolsVersion>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<StartupObject>
</StartupObject>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<UseVSHostingProcess>false</UseVSHostingProcess>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<UseVSHostingProcess>false</UseVSHostingProcess>
</PropertyGroup>
<ItemGroup>
<Reference Include="nunit.framework">
<HintPath>..\..\..\..\..\Program Files\TestDriven.NET 3\NUnit\2.5\framework\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Data.DataSetExtensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="BulkOperationLoaderTests.cs" />
<Compile Include="DelphiUnitCleanerOperationTests.cs" />
<Compile Include="IcarusAnalyzerTests.cs" />
<Compile Include="LibraryPaths\ClipboardLibraryPathsProviderTests.cs" />
<Compile Include="LibraryPaths\DelphiLibraryPathBuilderTests.cs" />
<Compile Include="LibraryPaths\DelphiLibraryPathProviderTests.cs" />
<Compile Include="LibraryPaths\DelphiRegistryKeysTests.cs" />
<Compile Include="LibraryPaths\LibraryPathProviderFactoryTests.cs" />
<Compile Include="Utils\RelativePathClassTests.cs" />
<Compile Include="SourceControl\SourceOffsiteClassTests.cs" />
<Compile Include="TestsRunner.cs" />
<Compile Include="UnitFormReaderClassTests.cs" />
<Compile Include="UnitItemClassTests.cs" />
<Compile Include="UnitListClassTests.cs" />
<Compile Include="UsesClauseReaderClassTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Utilities\MethodRunnerClass.cs" />
<Compile Include="Utilities\MethodRunnerClassTests.cs" />
<Compile Include="Utils\ListUtilsTests.cs" />
<Compile Include="Utils\PathUtilsClassTests.cs" />
<Compile Include="Utils\StringListUtilsTests.cs" />
<Content Include="ProfilingSessions\Session20090809_153225.sdps" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\DelphiProjectHandler\DelphiProjectHandler.csproj">
<Project>{5C84FFF1-2B72-440F-A36D-7D411CF7AE61}</Project>
<Name>DelphiProjectHandler</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<WCFMetadata Include="Service References\" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.2.0">
<Visible>False</Visible>
<ProductName>.NET Framework 2.0 %28x86%29</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.0">
<Visible>False</Visible>
<ProductName>.NET Framework 3.0 %28x86%29</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
<Visible>False</Visible>
<ProductName>Windows Installer 3.1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,360 @@
/*
* Created by SharpDevelop.
* User: SG0894652
* Date: 8/11/2009
* Time: 2:41 AM
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using NUnit.Framework;
using DelphiProjectHandler;
namespace DelphiProjectHandler.Tests
{
[TestFixture]
public class IcarusAnalyzerTests
{
protected void CompareUnitCount(SuggestedUnitStructure iList, int iExpectedInterface, int iExpectedImplementation, int iExpectedMovedCount, int iExpectedDeletedCount, string iErrorMsg)
{
Assert.AreEqual(iExpectedInterface, iList.Uses.Interface.Count, "Invalid no. of returned interface units. " + iErrorMsg);
Assert.AreEqual(iExpectedImplementation, iList.Uses.Implementation.Count, "Invalid no. of returned implementation units. " + iErrorMsg);
Assert.AreEqual(iExpectedMovedCount, iList.MoveToInterface.Count, "Invalid no. of units moved to implementation. " + iErrorMsg);
Assert.AreEqual(iExpectedDeletedCount, iList.ToDelete.Count, "Invalid no. of deleted units. " + iErrorMsg);
}
[Test]
public void Parse()
{
#region (Test value)
const string cReport =
"****************************************************************************\r\n" +
"* Uses Report for *\r\n" +
"* D:\\DM\\SG894652_MAIN_CCRC\\DISPMGR\\DPR\\ACARSAPI.DPR *\r\n" +
"* 8/11/2009 1:21:21 AM *\r\n" +
"****************************************************************************\r\n" +
"\r\n" +
"Usage:\r\n" +
"----------------------------------------------------------------------------\r\n" +
"\r\n" +
"Module AbsoluteIdUtils uses:\r\n" +
"\r\n" +
" Units used in implementation:\r\n" +
"\r\n" +
" SysUtils in implementation (has initialization, used by unit with init)\r\n" +
" StrUtils in implementation (used by unit with init)\r\n" +
" gdeclare in implementation (has initialization, used by unit with init)\r\n" +
" DBStatusCodes in implementation (used by unit with init)\r\n" +
" Aptio in implementation (has initialization, used by unit with init)\r\n" +
" Navio in implementation (used by unit with init)\r\n" +
" Wptio in implementation (used by unit with init)\r\n" +
"\r\n" +
"Module AbstractCacheStreamerClass uses:\r\n" +
"\r\n" +
" Units used in interface:\r\n" +
"\r\n" +
" --> SqlCacheUtils in implementation (used by unit with init)\r\n" +
" Logger in interface (has initialization, used by unit with init)\r\n" +
" ==> DBUNIT unnecessary (has initialization, used by unit with init)\r\n" +
" ConnectionInfoClass in interface (used by unit with init)\r\n" +
" --> DatabaseQueryFactoryClass in implementation (used by unit with init)\r\n" +
"\r\n" +
"Module AbstractCacheStreamerClass uses:\r\n" +
"\r\n" +
" Units used in implementation:\r\n" +
"\r\n" +
" Windows source not found\r\n" +
" SysUtils in implementation (has initialization, used by unit with init)\r\n" +
" StrUtils in implementation (used by unit with init)\r\n" +
" ==> ActiveX unnecessary (used by unit with init)\r\n" +
" gdeclare in implementation (has initialization, used by unit with init)\r\n" +
" DBStatusCodes in implementation (used by unit with init)\r\n" +
" Aptio in implementation (has initialization, used by unit with init)\r\n" +
" Navio in implementation (used by unit with init)\r\n" +
" Wptio in implementation (used by unit with init)\r\n" +
"Module AbstractTable uses:\r\n" +
"\r\n" +
" Units used in implementation:\r\n" +
"\r\n" +
" SysUtils in implementation (has initialization, used by unit with init)\r\n" +
" LoggerCategories in implementation (used by unit with init)\r\n" +
"\r\n" +
"Library ACARSAPI uses:\r\n" +
"\r\n" +
" Used units:\r\n" +
"\r\n" +
" Windows source not found\r\n" +
" ==> Messages unnecessary (used by unit with init)\r\n" +
" SysUtils in implementation (has initialization, used by unit with init)\r\n" +
" Classes in implementation (has initialization, used by unit with init)\r\n" +
" Controls in implementation (has initialization, used by unit with init)\r\n" +
" Dialogs in implementation (has initialization, used by unit with init)\r\n" +
" ==> CommonTypes unnecessary (used by unit with init)\r\n" +
" DateTime in implementation (has initialization, used by unit with init)\r\n" +
" Mystd in implementation (used by unit with init)\r\n" +
" ==> DBUNIT unnecessary (has initialization, used by unit with init)\r\n" +
" CommonConsts in implementation (used by unit with init)\r\n" +
" GDeclare in implementation (has initialization, used by unit with init)\r\n" +
" CODEio in implementation (used by unit with init)\r\n" +
" ACWGTSio in implementation (used by unit with init)\r\n" +
" APTio in implementation (has initialization, used by unit with init)\r\n" +
" FltEdits in implementation (has initialization, used by unit with init)\r\n" +
" FSDLYio in implementation (has initialization, used by unit with init)\r\n" +
" oWait in implementation (used by unit with init)\r\n" +
" WINDEV in implementation (has initialization, used by unit with init)\r\n" +
"\r\n" +
"Note:\r\n" +
"Units that are marked as \"unnecessary\" in the project source\r\n" +
"are not needed in the main code block. However you would\r\n" +
"normally want to keep them listed anyway, because it tells\r\n" +
"the Delphi IDE that the unit belongs to the project.\r\n" +
"\r\n" +
"Module ActiveX uses:\r\n" +
"\r\n" +
" Units used in interface:\r\n" +
"\r\n" +
" Windows source not found\r\n" +
" Messages in interface (used by unit with init)\r\n" +
"\r\n" +
"Module ActnList uses:\r\n" +
"\r\n" +
" Units used in interface:\r\n" +
"\r\n" +
" Messages in interface (used by unit with init)\r\n" +
" Classes in interface (has initialization, used by unit with init)\r\n" +
" ==> Contnrs unnecessary (used by unit with init)\r\n" +
" ImgList in interface (used by unit with init)\r\n" +
"\r\n" +
"Module ActnList uses:\r\n" +
"\r\n" +
" Units used in implementation:\r\n" +
"\r\n" +
" Windows source not found\r\n" +
" SysUtils in implementation (has initialization, used by unit with init)\r\n" +
" ==> Graphics unnecessary (has initialization, used by unit with init)\r\n" +
" Consts in implementation (used by unit with init)\r\n" +
" Menus in implementation (has initialization, used by unit with init)\r\n" +
" Controls in implementation (has initialization, used by unit with init)\r\n" +
" Forms in implementation (has initialization, used by unit with init)\r\n" +
"\r\n" +
"Module ACWGTSBroker uses:\r\n" +
"\r\n" +
" Units used in interface:\r\n" +
"\r\n" +
" --> SysUtils in implementation (has initialization, used by unit with init)\r\n" +
" --> Classes in implementation (has initialization, used by unit with init)\r\n" +
" Contnrs in interface (used by unit with init)\r\n" +
" QueryInterface in interface (used by unit with init)\r\n" +
" --> DatabaseQueryFactoryClass in implementation (used by unit with init)\r\n" +
" ==> DatabaseProviderFactoryClass unnecessary (has initialization, used by unit with init)\r\n" +
" AbstractQuery in interface (used by unit with init)\r\n" +
" ==> MetaTableAgentClass unnecessary (has initialization, used by unit with init)\r\n" +
" ACWGTSio in interface (used by unit with init)\r\n" +
" ==> oConsole unnecessary (used by unit with init)\r\n" +
" DMBaseBrokerClass in interface (used by unit with init)\r\n" +
" --> DMBaseSQLBrokerClass in implementation (used by unit with init)\r\n" +
" DMBaseArchSQLBrokerClass in interface (used by unit with init)\r\n" +
"\r\n" +
"Module ACWGTSBroker uses:\r\n" +
"\r\n" +
" Units used in implementation:\r\n" +
"\r\n" +
" ==> Datetime unnecessary (has initialization, used by unit with init)\r\n" +
" MyStd in implementation (used by unit with init)\r\n" +
" DBUNIT in implementation (has initialization, used by unit with init)\r\n" +
" CommonConsts in implementation (used by unit with init)\r\n" +
" DMGlobals in implementation (used by unit with init)\r\n" +
" gdeclare in implementation (has initialization, used by unit with init)\r\n" +
" ==> OracleKeywordClass unnecessary (has initialization, used by unit with init)\r\n" +
" ==> DMUtils unnecessary (used by unit with init)\r\n" +
" DMBtrvQueryFactory in implementation (has initialization, used by unit with init)\r\n" +
" DMSQLQueryFactory in implementation (has initialization, used by unit with init)\r\n" +
"\r\n" +
"Module WinSpool uses:\r\n" +
"\r\n" +
" Units used in interface:\r\n" +
"\r\n" +
" Windows source not found\r\n" +
"\r\n" +
"Module WPTIO uses:\r\n" +
"\r\n" +
" Units used in interface:\r\n" +
"\r\n" +
" --> Sysutils in implementation (has initialization, used by unit with init)\r\n" +
" --> MYSTD in implementation (used by unit with init)\r\n" +
" --> DBunit in implementation (has initialization, used by unit with init)\r\n" +
" GDeclare in interface (has initialization, used by unit with init)\r\n" +
" --> GEODESIC in implementation (used by unit with init)\r\n" +
"\r\n" +
"Module WPTIO uses:\r\n" +
"\r\n" +
" Units used in implementation:\r\n" +
"\r\n" +
" ==> CommonTypes unnecessary (used by unit with init)\r\n" +
" CommonConsts in implementation (used by unit with init)\r\n" +
" DMGlobals in implementation (used by unit with init)\r\n" +
" DBOperations in implementation (used by unit with init)\r\n" +
" CODEIO in implementation (used by unit with init)\r\n" +
"\r\n" +
"\r\n" +
"\r\n" +
"\r\n" +
"Modules that are referenced in the Delphi project file, but not used:\r\n" +
"----------------------------------------------------------------------------\r\n" +
"\r\n" +
"CommonTypes (used by unit with init)\r\n" +
"DBUNIT (has initialization, used by unit with init)\r\n" +
"Messages (used by unit with init)\r\n" +
"\r\n" +
"Note:\r\n" +
"Units that are marked as \"unnecessary\" in the project source\r\n" +
"are not needed in the main code block. However you would\r\n" +
"normally want to keep them listed anyway, because it tells\r\n" +
"the Delphi IDE that the unit belongs to the project.\r\n" +
"\r\n" +
"\r\n" +
"Modules that are used but not added to the Delphi project file:\r\n" +
"----------------------------------------------------------------------------\r\n" +
"\r\n" +
" (none)\r\n" +
"\r\n" +
"\r\n" +
"References:\r\n" +
"----------------------------------------------------------------------------\r\n" +
"\r\n" +
"AbsoluteIdUtils references (7):\r\n" +
"\r\n" +
"Aptio, DBStatusCodes, gdeclare, Navio, StrUtils, SysUtils, Wptio\r\n" +
"\r\n" +
"AbsoluteIdUtils is referenced by (1):\r\n" +
"\r\n" +
"PTEdits\r\n" +
"\r\n" +
"Module CommDlg uses:\r\n" +
"\r\n" +
" Units used in interface:\r\n" +
"\r\n" +
" Windows source not found\r\n" +
" Messages in interface (used by unit with init)\r\n" +
" ShlObj in interface (used by unit with init)\r\n" +
"\r\n" +
"Program COMMDRVR uses:\r\n" +
"\r\n" +
" Used units:\r\n" +
"\r\n" +
" ==> ShareMem unnecessary (has initialization)\r\n" +
" Forms in implementation (has initialization, used by unit with init)\r\n" +
" Logger in implementation (has initialization, used by unit with init)\r\n" +
" GDeclare in implementation (has initialization, used by unit with init)\r\n" +
" ==> DBUnit unnecessary (has initialization, used by unit with init)\r\n" +
" ==> oLOGDISP unnecessary\r\n" +
" oLOGCONS in implementation (used by unit with init)\r\n" +
" oCOMMLNK in implementation\r\n" +
" oCOMMCTL in implementation (used by unit with init)\r\n" +
" ==> MessageTypeRecognizer unnecessary (used by unit with init)\r\n" +
" ==> GDCL_ALL unnecessary (has initialization, used by unit with init)\r\n" +
" BasAbout in implementation\r\n" +
" ==> HelpInvoker unnecessary (used by unit with init)\r\n" +
" ==> ComCreator unnecessary\r\n" +
" ==> AppLauncherInterface unnecessary\r\n" +
" ==> AppLauncher unnecessary\r\n" +
" ==> RegSvr32Launcher unnecessary\r\n" +
" ==> ComObjectLibrary unnecessary (has initialization)\r\n" +
" ==> ComCreatorGuiInstallApproval unnecessary\r\n" +
" ==> DefaultWebBrowserLauncher unnecessary\r\n" +
" ==> UIGlobal unnecessary (has initialization)\r\n" +
" oSKEDLST in implementation\r\n" +
" oCDMet in implementation\r\n" +
" ==> oCDStart unnecessary\r\n" +
" ==> SMI unnecessary (has initialization, used by unit with init)\r\n" +
" ==> Notamio unnecessary (used by unit with init)\r\n" +
" ==> NotamBroker unnecessary (has initialization)\r\n" +
" ==> oFWAPSAlert unnecessary (has initialization)\r\n" +
" ==> OPMSGio unnecessary (used by unit with init)\r\n" +
" ==> EramMessageProcessorInterface unnecessary (used by unit with init)\r\n" +
" ==> EramRejectCNLProcessor unnecessary (used by unit with init)\r\n" +
" ==> EramFDRelFinder unnecessary\r\n" +
" ==> EramCNLAckProcessor unnecessary (used by unit with init)\r\n" +
" ==> EramMessageProcessor unnecessary (has initialization)\r\n" +
" ==> EramFPLAckProcessor unnecessary (used by unit with init)\r\n" +
" ==> EramRejectFPLProcessor unnecessary (used by unit with init)\r\n" +
" ==> EramCHGAckProcessor unnecessary (used by unit with init)\r\n" +
" ==> EramDEPAckProcessor unnecessary (used by unit with init)\r\n" +
" ==> EramDLAAckProcessor unnecessary (used by unit with init)\r\n" +
" ==> EramRejectDEPProcessor unnecessary (used by unit with init)\r\n" +
" ==> EramRejectDLAProcessor unnecessary (used by unit with init)\r\n" +
" ==> EramRejectCHGProcessor unnecessary (used by unit with init)\r\n" +
" ==> ERAMConfiguration unnecessary\r\n" +
" ==> FunctionalityProvider unnecessary (has initialization, used by unit with init)\r\n" +
" ==> FlightWxImagesFunctionality unnecessary (has initialization)\r\n" +
" ==> NOTAMContinuityAlerterTypes unnecessary\r\n" +
" ==> NOTAMserialNumberAlerterCSN unnecessary\r\n" +
" ==> NOTAMContinuityCheckRequester unnecessary\r\n" +
" ==> NOTAMContinuityLogger unnecessary\r\n" +
" ==> NOTAMCheckFacility unnecessary\r\n" +
" ==> WsiFileTypes unnecessary (used by unit with init)\r\n" +
" ==> ErrorsysExceptionHandler unnecessary\r\n" +
" ==> Nmsg_zzz unnecessary\r\n" +
" ==> BulletinProcessors unnecessary\r\n" +
" ==> NORviaNOTAMreformatter unnecessary\r\n" +
" ==> AutoCorrectList unnecessary\r\n" +
" ==> AutoCorrect unnecessary\r\n" +
" ==> IncomingOTSrollbackManager unnecessary\r\n" +
" ==> IncomingNATMessageProcessor unnecessary\r\n" +
" ==> IncomingNORMessageProcessor unnecessary\r\n" +
" ==> FLMsgQueue unnecessary\r\n" +
" ==> OMSG_ZZZ unnecessary\r\n" +
" ==> OPMSGBroker unnecessary (has initialization)\r\n" +
" OCOMDRVR in implementation\r\n" +
" ==> MQIN_ZZZ unnecessary\r\n" +
" ==> RECV_ZZZ unnecessary\r\n" +
" ==> FlightPlanReview unnecessary\r\n" +
" ==> FlightPlanReviewHandler unnecessary\r\n" +
" ==> ETAtoRESsender unnecessary\r\n" +
"\r\n" +
"Note:\r\n" +
"Units that are marked as \"unnecessary\" in the project source\r\n" +
"are not needed in the main code block. However you would\r\n" +
"normally want to keep them listed anyway, because it tells\r\n" +
"the Delphi IDE that the unit belongs to the project.\r\n" +
"\r\n" +
"Module COMMGRIB uses:\r\n" +
"\r\n" +
" Units used in interface:\r\n" +
"\r\n" +
" --> SYSUTILS in implementation (has initialization, used by unit with init)\r\n" +
" ==> MYSTD unnecessary (used by unit with init)\r\n" +
" --> GDeclare in implementation (has initialization, used by unit with init)\r\n" +
" ==> DateTime unnecessary (has initialization, used by unit with init)\r\n" +
" ==> dbunit unnecessary (has initialization, used by unit with init)\r\n" +
" --> QMSGDESK in implementation (used by unit with init)\r\n" +
" ==> DYNEXEC unnecessary (used by unit with init)\r\n" +
" --> uGRIBSIT in implementation\r\n" +
"\r\n" +
"Module COMMGRIB uses:\r\n" +
"\r\n" +
" Units used in implementation:\r\n" +
"\r\n" +
" ==> CommonConsts unnecessary (used by unit with init)\r\n" +
" ==> CommonTypes unnecessary (used by unit with init)\r\n";
#endregion
SuggestedUnitStructureList vActual = IcarusAnalyzerReportParser.Parse(cReport);
Assert.AreEqual(10, vActual.Count, "Invalid no. of unit analyzes returned");
CompareUnitCount(vActual["absoluteidutils"], 0, 7, 0, 0, "Test 1");
CompareUnitCount(vActual["abstractcachestreamerclass"], 2, 10, 2, 2, "Test 2");
CompareUnitCount(vActual["abstracttable"], 0, 2, 0, 0, "Test 3");
CompareUnitCount(vActual["activex"], 2, 0, 0, 0, "Test 4");
CompareUnitCount(vActual["actnlist"], 3, 6, 0, 2, "Test 5");
CompareUnitCount(vActual["acwgtsbroker"], 6, 11, 4, 6, "Test 6");
CompareUnitCount(vActual["winspool"], 1, 0, 0, 0, "Test 7");
CompareUnitCount(vActual["wptio"], 1, 8, 4, 1, "Test 8");
CompareUnitCount(vActual["commdlg"], 3, 0, 0, 0, "Test 9");
CompareUnitCount(vActual["commgrib"], 0, 4, 4, 6, "Test 10");
}
}
}
@@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows.Forms;
using NUnit.Framework;
using DelphiProjectHandler.LibraryPaths;
namespace DelphiProjectHandler.Tests.LibraryPaths
{
[TestFixture]
public class ClipboardLibraryPathsProviderTests
{
protected string cPaths = @"$(DELPHI)\Lib;$(DELPHI)\Bin;$(DELPHI)\Imports;$(DELPHI)\Projects\Bpl;$(DM_VIEW)\Lib;$(DM_TP)\abbrevia\source;$(DM_TP)\TGlobe\SOURCE;$(DM_TP)\AsyncPRO\source;$(DM_TP)\RegExpr\Source;$(DM_TP)\BTrieveSDK;$(DM_TP)\PxLib;$(DM_TP)\ExcMagicD6;$(DM_TP)\JWA\Win32Api;$(DM_TP)\XMLParser;$(DM_TP)\XMLPRO\source;$(DM_TP)\CalcExpress;$(DM_TP)\Indy9;$(DM_VIEW)\I;$(DM_VIEW)\Maps;$(DM_VIEW)\Forms;$(DM_VIEW)\U;$(DM_VIEW)\U\Brokers;$(DM_VIEW)\U\Eram;$(DM_VIEW)\U\FPValidators;$(BASA_DM);$(BASA_DM)\UUtils;$(BASA_DM)\UBtrieve;$(BASA_DM)\UBtrieve\UBroker;$(BASA_DM)\UFacilitator;$(BASA_DM)\USQL\UBroker;$(BASA_DM)\USQL\UOperation;$(BASA_DM)\USQL\UQueryBuilder;$(BASA_DM)\USQL\UUtil;$(BASA_DM)\USQL\UUtil\VersionInfo;$(BASA_DM)\USQLCache;$(BASA_DM)\USQLCache\UOperation;$(BASA_DM)\USQLCache\UUtil;$(BASA_DM)\UStream;$(BASA_DM)\UTransfer;$(BASA_DM)\USQL;$(DM_TP)\FCSUtils;$(DM_TP)\FCSUtils\System;$(DM_TP)\FCSUtils\DateUtils;$(DM_TP)\FCSUtils\DbUtils;$(DM_TP)\FCSUtils\Logging;$(DM_TP)\FCSUtils\Security;$(DM_TP)\FCSUtils\XMLRTTI;$(DM_TP)\ZipMaster;$(DM_TP)\KeyHelp;$(DM_TP)\DelphiKit;$(DM_VIEW)\U\EuroATCPlanValidation;$(DM_VIEW)\U\EuroATCPlanValidation\CFMU;$(DM_TP)\Guggenheim\Dcu;$(DM_TP)\JEDI\JCL\lib\d6;$(DM_TP)\JEDI\JCL\source;$(DM_TP)\JEDI\jvcl\lib\D6;$(DM_TP)\JEDI\jvcl\common;$(DM_TP)\JEDI\jvcl\Resources";
[Test]
[STAThread]
public void List()
{
ILibraryPathsProvider vProvider = new ClipboardLibraryPathsProvider();
Clipboard.SetText(cPaths);
IList<string> vPaths = vProvider.List();
Assert.AreEqual(58, vPaths.Count);
Assert.GreaterOrEqual(vPaths.IndexOf(@"$(DELPHI)\Lib"), 0, "Test 1");
Assert.GreaterOrEqual(vPaths.IndexOf(@"$(DM_TP)\JEDI\jvcl\Resources"), 0, "Test 2");
Assert.AreEqual(-1, vPaths.IndexOf(";"), "Test 3");
}
}
}
@@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using DelphiProjectHandler.LibraryPaths;
namespace DelphiProjectHandler.Tests.LibraryPaths
{
[TestFixture]
public class DelphiLibraryPathBuilderTests
{
[Test]
public void Build()
{
Dictionary<string, string> vEnvironmentStrings = new Dictionary<string, string>();
vEnvironmentStrings.Add("BASA_DM", "$(DM_TP)\\Basa");
vEnvironmentStrings.Add("DM_TP", "$(DM_VIEW)\\THIRDPARTY");
vEnvironmentStrings.Add("DM_VIEW", "d:\\DM\\sg894652_2006.2_ccrc\\dispmgr");
vEnvironmentStrings.Add("FCSUtils", "$(DM_TP)\\FcsUtils");
vEnvironmentStrings.Add("delphi", "c:\\program files\\borland\\delphi5");
List<string> vPaths = new List<string>();
vPaths.Add("$(DM_View)\\DPR");
vPaths.Add("$(DM_TP)\\BASA");
vPaths.Add("$(Delphi)\\Lib");
vPaths.Add("C:\\source\\dm\\latest");
ILibraryPathsBuilder vBuilder = new DelphiLibraryPathsBuilder();
ICollection<string> vActual = vBuilder.Build(vPaths, vEnvironmentStrings);
Assert.AreEqual(4, vActual.Count, "Invalid no. of returned paths");
Assert.IsTrue(vActual.Contains(@"d:\dm\sg894652_2006.2_ccrc\dispmgr\dpr"), "Path 0 wasn't found");
Assert.IsTrue(vActual.Contains(@"d:\dm\sg894652_2006.2_ccrc\dispmgr\thirdparty\basa"), "Path 1 wasn't found");
Assert.IsTrue(vActual.Contains(@"c:\program files\borland\delphi5\lib"), "Path 2 wasn't found");
Assert.IsTrue(vActual.Contains(@"c:\source\dm\latest"), "Path 3 wasn't found");
}
}
}
@@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using DelphiProjectHandler.LibraryPaths;
namespace DelphiProjectHandler.Tests.LibraryPaths
{
[TestFixture]
class DelphiLibraryPathProviderTests
{
[Test]
public void Delphi5Paths()
{
ILibraryPathsProvider vProvider = new DelphiLibraryPathsProvider(LibraryPathType.Delphi5);
IList<string> vLibraryPaths = vProvider.List();
Assert.GreaterOrEqual(vLibraryPaths.IndexOf("c:\\program files\\borland\\delphi5\\lib"), 0, "Test 1");
Assert.GreaterOrEqual(vLibraryPaths.IndexOf("d:\\dm\\sg894652_5.3_ccrc\\dispmgr\\u"), 0, "Test 2");
}
[Test]
public void Delphi6Paths()
{
ILibraryPathsProvider vProvider = new DelphiLibraryPathsProvider(LibraryPathType.Delphi6);
IList<string> vLibraryPaths = vProvider.List();
Assert.GreaterOrEqual(vLibraryPaths.IndexOf("c:\\program files\\borland\\delphi6\\lib\\"), 0, "Test 1");
// Assert.GreaterOrEqual(vLibraryPaths.IndexOf("d:\\dm\\sg894652_2006.2_ccrc\\dispmgr\\u"), 0, "Test 2");
}
}
}
@@ -0,0 +1,61 @@
/*
* Created by SharpDevelop.
* User: SG0894652
* Date: 8/10/2009
* Time: 11:21 PM
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using NUnit.Framework;
using DelphiProjectHandler.LibraryPaths;
namespace DelphiProjectHandler.Tests.LibraryPaths
{
[TestFixture]
public class DelphiRegistryKeysTests
{
[Test]
public void LibraryKey()
{
Assert.IsNotNull(DelphiRegistryKeys.LibraryKey(LibraryPathType.Delphi5), "Delphi5 should be created");
Assert.IsNotNull(DelphiRegistryKeys.LibraryKey(LibraryPathType.Delphi6), "Delphi5 should be created");
}
[Test]
[ExpectedException(typeof(NotSupportedException))]
public void LibraryKey_NotSupported()
{
DelphiRegistryKeys.LibraryKey(LibraryPathType.Delphi2009);
}
[Test]
public void RootDirKey()
{
Assert.IsNotNull(DelphiRegistryKeys.RootDirKey(LibraryPathType.Delphi5), "Delphi5 should be created");
Assert.IsNotNull(DelphiRegistryKeys.RootDirKey(LibraryPathType.Delphi6), "Delphi5 should be created");
}
[Test]
[ExpectedException(typeof(NotSupportedException))]
public void RootDirKey_NotSupported()
{
DelphiRegistryKeys.RootDirKey(LibraryPathType.Delphi2009);
}
[Test]
public void EnvironmentPathsKey()
{
Assert.IsNotNull(DelphiRegistryKeys.EnvironmentPathsKey(LibraryPathType.Delphi6), "Delphi6 should be created");
}
[Test]
[ExpectedException(typeof(NotSupportedException))]
public void EnvironmentPathsKey_NotSupported()
{
DelphiRegistryKeys.EnvironmentPathsKey(LibraryPathType.Delphi5);
}
}
}
@@ -0,0 +1,77 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using DelphiProjectHandler.LibraryPaths;
namespace DelphiProjectHandler.Tests.LibraryPaths
{
[TestFixture]
public class LibraryPathProviderFactoryTests
{
protected void TestCreateProvider(LibraryPathType iLibraryType, Type iExpectedType, string iErrorMsg)
{
ILibraryPathsProvider vProvider = LibraryPathsProviderFactory.CreateProvider(iLibraryType);
Assert.IsNotNull(vProvider, "Provider was not created. " + iErrorMsg);
Assert.IsInstanceOf(iExpectedType, vProvider, "Created provider is of wrong type. " + iErrorMsg);
}
[Test]
public void CreateProvider_Supported()
{
TestCreateProvider(LibraryPathType.Delphi5, typeof(DelphiLibraryPathsProvider), "Test 1");
TestCreateProvider(LibraryPathType.Delphi6, typeof(DelphiLibraryPathsProvider), "Test 2");
TestCreateProvider(LibraryPathType.Clipboard, typeof(ClipboardLibraryPathsProvider), "Test 3");
}
[Test]
[ExpectedException(typeof(NotSupportedException))]
public void CreateProvider_NotSupported_Delphi2005()
{
LibraryPathsProviderFactory.CreateProvider(LibraryPathType.Delphi2005);
}
[Test]
[ExpectedException(typeof(NotSupportedException))]
public void CreateProvider_NotSupported_Delphi2007()
{
LibraryPathsProviderFactory.CreateProvider(LibraryPathType.Delphi2007);
}
[Test]
[ExpectedException(typeof(NotSupportedException))]
public void CreateProvider_NotSupported_Delphi7()
{
LibraryPathsProviderFactory.CreateProvider(LibraryPathType.Delphi7);
}
[Test]
public void ListSupportedProviders()
{
LibraryPathType[] vSupported = LibraryPathsProviderFactory.ListSupportedProviders();
Assert.AreEqual(3, vSupported.Length, "No. of supported providers is wrong");
Assert.AreEqual(LibraryPathType.Delphi5, vSupported[0], "Item 0 is wrong");
Assert.AreEqual(LibraryPathType.Delphi6, vSupported[1], "Item 1 is wrong");
Assert.AreEqual(LibraryPathType.Clipboard, vSupported[2], "Item 2 is wrong");
}
[Test]
public void IsProviderSupported_Supported()
{
Assert.IsTrue(LibraryPathsProviderFactory.IsProviderSupported(LibraryPathType.Delphi5), "Delphi5 should be supported");
Assert.IsTrue(LibraryPathsProviderFactory.IsProviderSupported(LibraryPathType.Delphi6), "Delphi6 should be supported");
Assert.IsTrue(LibraryPathsProviderFactory.IsProviderSupported(LibraryPathType.Clipboard), "Clipboard should be supported");
}
[Test]
public void IsProviderSupported_NotSupported()
{
Assert.IsFalse(LibraryPathsProviderFactory.IsProviderSupported(LibraryPathType.Delphi7), "Delphi7 should not be supported");
Assert.IsFalse(LibraryPathsProviderFactory.IsProviderSupported(LibraryPathType.Delphi2005), "Delphi2005 should not be supported");
Assert.IsFalse(LibraryPathsProviderFactory.IsProviderSupported(LibraryPathType.Delphi2007), "Delphi2007 should not be supported");
Assert.IsFalse(LibraryPathsProviderFactory.IsProviderSupported(LibraryPathType.Delphi2009), "Delphi2009 should not be supported");
}
}
}
@@ -0,0 +1,35 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("DelphiProjectHandler.Tests")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("ProfiMile Lemańczyk sp. j.")]
[assembly: AssemblyProduct("DelphiProjectHandler.Tests")]
[assembly: AssemblyCopyright("Copyright © ProfiMile Lemańczyk sp. j. 2006")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("acbed1ed-f36b-449f-a655-f6f40da7d4d4")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
@@ -0,0 +1,198 @@
using System;
using System.IO;
using NUnit.Framework;
using DelphiProjectHandler.SourceControl;
namespace DelphiProjectHandler.Tests.SourceControl
{
[TestFixture]
public class SourceOffsiteClassTests: SourceOffsite
{
#region (Overrides)
public SourceOffsiteClassTests()
:
base("fcsweb4.dev.sabre.com", 8888, "ft-latest", "mpl", "mpl", @"d:\source\ft-latest")
{
}
protected override string RunCommand(string iFileName)
{
if (!MockRunCommand)
return base.RunCommand(iFileName);
else
if (MockSuccess)
return TestValueSuccessful;
else
return TestValueUnsuccessful;
}
protected override string GetApplicationFileName()
{
if (!MockGetApplicationFileName)
return base.GetApplicationFileName();
else
if (MockSuccess)
return @"c:\program files\SourceOffsite\soscmd.exe";
else
return @"c:\program files\SourceOffsite\soscmd_wrong.exe";
}
#endregion
#region (Properties)
protected bool MockRunCommand
{
get { return fMockRunCommand; }
set { fMockRunCommand = value; }
}
private bool fMockRunCommand = false;
protected bool MockGetApplicationFileName
{
get { return fMockGetApplicationFileName; }
set { fMockGetApplicationFileName = value; }
}
private bool fMockGetApplicationFileName;
protected bool MockSuccess
{
get { return fMockSuccess; }
set { fMockSuccess = value; }
}
private bool fMockSuccess;
protected string TestValueSuccessful
{
get { return fTestValueSuccessful; }
set { fTestValueSuccessful = value; }
}
private string fTestValueSuccessful = "";
protected string TestValueUnsuccessful
{
get { return fTestValueUnsuccessful; }
set { fTestValueUnsuccessful = value; }
}
private string fTestValueUnsuccessful = "";
#endregion
#region (Test methods)
protected void TestGetCommandParameters(string iProjectPath, string iFileName)
{
string vExpected = string.Format(
@"-command CheckoutFile -server {0}:{1} " +
@"-alias {2} -name {3} -password {4} " +
@"-project $/{5} -file {6}",
ServerName, ServerPort, Alias, UserName, Password, iProjectPath, Path.GetFileName(iFileName));
string vActual = GetCommandParameters(iFileName);
Assert.AreEqual(vExpected, vActual, "Wrong command line was returned. Project path: {0}, File name: {1}", iProjectPath, iFileName);
}
protected void TestCheckoutFile(string iFileName, bool iExpected)
{
MockRunCommand = true;
try
{
MockSuccess = iExpected;
bool vActual = CheckoutFile(iFileName);
Assert.AreEqual(iExpected, vActual, "Wrong checkout result. FileName: " + iFileName);
}
finally
{
MockRunCommand = false;
}
}
#endregion
#region (Setup/TearDown)
[SetUp]
protected virtual void Setup()
{
TestValueSuccessful = "Checked out file: ftadmin.dpr\r\n";
TestValueUnsuccessful = "Unable to lock file: ftadmin.dpr\r\n";
}
[TearDown]
protected virtual void TearDown()
{
}
#endregion
[Test]
public void CheckoutFile()
{
TestCheckoutFile(@"d:\source\ft-latest\all\dpr\ftadmin.dpr", true);
TestCheckoutFile(@"d:\source\ft-latest\all\dpr\ftadmin.dpr", false);
}
[Test]
public void WasFileCheckedOut()
{
bool vActual = WasFileCheckedOut(TestValueSuccessful);
Assert.IsTrue(vActual, "Successful checkout was not recognized");
vActual = WasFileCheckedOut(TestValueUnsuccessful);
Assert.IsFalse(vActual, "Unsuccessful checkout was not recognized");
}
[Test]
//[Ignore("Not on VPN")]
public void RunCommand()
{
TestRunCommand(false, true, @"d:\source\ft-latest\all\dpr\test_project.dpr", "Error: Server response = 401 NoSuchFileOrProject\r\nError: Server response = 401 NoSuchFileOrProject\r\n");
}
[Test]
[ExpectedException(typeof(ArgumentException))]
public void RunCommand_EmptyFileName()
{
TestRunCommand(false, true, "", "");
}
[Test]
[ExpectedException(typeof(System.ComponentModel.Win32Exception))]
public void RunCommand_WrongApplicationName()
{
TestRunCommand(true, false, "doesn't have meaning.txt", "");
}
private void TestRunCommand(bool iMockBehavior, bool iSuccessful, string iFileName, string iExpected)
{
MockGetApplicationFileName = iMockBehavior;
try
{
MockSuccess = iSuccessful;
string vActual = RunCommand(iFileName);
Assert.AreEqual(iExpected, vActual, "File Name: " + iFileName);
}
finally
{
MockGetApplicationFileName = false;
}
}
[Test]
public void TestCreate()
{
SourceOffsiteClassTests vControl = new SourceOffsiteClassTests();
Assert.AreEqual("fcsweb4.dev.sabre.com", vControl.ServerName, "ServerName is wrong");
Assert.AreEqual(8888, vControl.ServerPort, "ServerPort is wrong");
Assert.AreEqual("ft-latest", vControl.Alias, "Alias is wrong");
Assert.AreEqual("mpl", vControl.UserName, "UserName is wrong");
Assert.AreEqual("mpl", vControl.Password, "Password is wrong");
Assert.AreEqual(@"d:\source\ft-latest", vControl.BaseFolder, "BaseFolder is wrong");
}
[Test]
public void GetCommandParameters()
{
TestGetCommandParameters(@"all/dpr", @"d:\source\ft-latest\all\dpr\ftadmin.dpr");
TestGetCommandParameters(@"", @"ftadmin.dpr");
}
}
}
+14
View File
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace DelphiProjectHandler.Tests
{
class Program
{
static void Main(string[] args)
{
// Runner.Main(args);
}
}
}
@@ -0,0 +1,59 @@
using System;
using NUnit.Framework;
using DelphiProjectHandler;
namespace DelphiProjectHandler.Tests
{
[TestFixture]
public class UnitFormReaderClassTests
{
protected void TestGetBinaryFormName(string iTestValue, string iExpected, string iMessage)
{
string vActual = UnitFormReader.GetBinaryFormName(iTestValue);
Assert.AreEqual(iExpected, vActual, iMessage);
}
[Test]
public void GetBinaryFormName()
{
#region (Test values)
string vTestValue1 = @"ÿ TFRMACFTDISCREPANCIES 0É TPF0ñTfrmAcftDiscrepanciesfrmAcftDiscrepanciesLeftî TopiWidth™Height¸ CaptionAircraft DiscrepanciesVisibleOnClose FormClose OnCloseQueryFormCloseQuery";
string vTestValue2 = @"ÿ TFRMAIRCRAFTINFO 02 TPF0TfrmAircraftInfofrmAircraftInfoLeftÖ Top";
string vTestValue3 = @"ÿ TFRMBASESI 0í TPF0ñTfrmBaseSI frmBaseSILeftUTop° CaptionfrmBa";
#endregion
TestGetBinaryFormName(vTestValue1, "frmAcftDiscrepancies", "1");
TestGetBinaryFormName(vTestValue2, "frmAircraftInfo", "2");
TestGetBinaryFormName(vTestValue3, "frmBaseSI", "3");
}
[Test]
[ExpectedException(typeof(Exception))]
public void GetBinaryFormName_FormNameIsLast()
{
string vTestValue = @"ÿ TFRMBASESI 0í TPF0ñTfrmBase";
TestGetBinaryFormName(vTestValue, "", "");
}
[Test]
[ExpectedException(typeof(Exception))]
public void GetBinaryFromName_WithoutMarker()
{
string vTestValue = @"ÿ TFRMACFTDISCREPANCIES 0É ñTfrmAcftDiscrepanciesfrmAcftDiscrepanciesLeftî TopiWidth™Height¸ CaptionAircraft DiscrepanciesVisibleOnClose FormClose OnCloseQueryFormCloseQuery";
TestGetBinaryFormName(vTestValue, "", "");
}
[Test]
[ExpectedException(typeof(Exception))]
public void GetBinaryFormName_WithoutFormName()
{
string vTestValue = @"ÿ TFRMACFTDISCREPANCIES 0É TPF0ñ";
TestGetBinaryFormName(vTestValue, "", "");
}
}
}
@@ -0,0 +1,308 @@
using System;
using NUnit.Framework;
using DelphiProjectHandler;
namespace DelphiProjectHandler.Tests
{
[TestFixture]
public class UnitItemClassTests
{
protected void DoTestCreate_Name(string iExpectedName)
{
UnitItem vUnit = new UnitItem(iExpectedName);
Assert.AreEqual(iExpectedName, vUnit.Name, "Name wasn't set properly");
Assert.AreEqual("", vUnit.Path, "Path wasn't set to empty string");
}
protected void DoTestNameChange(string iInitialName, string iNewName)
{
UnitItem vUnit = new UnitItem(iInitialName);
DoTestNameChange(vUnit, iInitialName, iNewName);
}
protected void DoTestNameChange(UnitItem iUnitItem, string iInitialName, string iNewName)
{
Assert.AreEqual(iInitialName, iUnitItem.Name, "Name wasn't set properly.");
iUnitItem.Name = iNewName;
Assert.AreEqual(iNewName, iUnitItem.Name, "Name wasn't changed correctly.");
}
protected void DoTestPathChange(UnitItem iUnitItem, string iInitialPath, string iNewPath, string iMessage)
{
Assert.AreEqual(iInitialPath, iUnitItem.Path, "Path wasn't set properly. " + iMessage);
iUnitItem.Path = iNewPath;
Assert.AreEqual(iNewPath, iUnitItem.Path, "Path wasn't changed correctly. " + iMessage);
}
protected void DoTestPathChange(string iInitialPath, string iNewPath)
{
UnitItem vUnit = new UnitItem("unit_name", iInitialPath, true, "");
DoTestPathChange(vUnit, iInitialPath, iNewPath, "");
vUnit = new UnitItem("", iInitialPath, true, "");
DoTestPathChange(vUnit, iInitialPath, iNewPath, "Created with empty name.");
}
protected void DoTestToString_WithConditions(bool iAddConditions, string iSeparator, bool iSeparatorLast, string iExpected)
{
UnitItem vUnit = new UnitItem("unit_name", "unit_path", true, "");
if (iAddConditions)
{
vUnit.StartingConditions = "{$condition1}";
vUnit.EndingConditions = "{$condition2}";
}
string vActual = vUnit.ToString(" ", iSeparator, iSeparatorLast);
Assert.AreEqual(iExpected, vActual);
}
protected void DoTestHasConditions(bool iExpected, bool iActualHasConditions, string iExpectedConditions, string iActualConditions, string iMessage)
{
Assert.AreEqual(iExpected, iActualHasConditions, "HasConditions value is wrong: " + iMessage);
Assert.AreEqual(iExpectedConditions, iActualConditions, "Conditions value is wrong: " + iMessage);
}
protected void DoTestHasStartingConditions(string iConditions, bool iExpected)
{
UnitItem vUnit = new UnitItem("unit_name");
vUnit.StartingConditions = iConditions;
DoTestHasConditions(iExpected, vUnit.HasStartingConditions, iConditions, vUnit.StartingConditions, "Starting");
}
protected void DoTestHasEndingConditions(string iConditions, bool iExpected)
{
UnitItem vUnit = new UnitItem("unit_name");
vUnit.EndingConditions = iConditions;
DoTestHasConditions(iExpected, vUnit.HasEndingConditions, iConditions, vUnit.EndingConditions, "Ending");
}
protected void DoTestHasForm(string iForm, bool iExpected)
{
UnitItem vUnit = new UnitItem("Created with unit name only");
vUnit.Form = iForm;
DoTestHasForm(vUnit, iForm, iExpected);
vUnit = new UnitItem("Created with empty path and form", "", false, iForm);
DoTestHasForm(vUnit, iForm, iExpected);
}
protected void DoTestHasForm(UnitItem iUnitItem, string iExpectedFormName, bool iExpectedHasForm)
{
Assert.AreEqual(iExpectedHasForm, iUnitItem.HasForm, "HasForm value is wrong. " + iUnitItem.Name);
Assert.AreEqual(iExpectedFormName, iUnitItem.Form, "Form value is wrong. " + iUnitItem.Name);
}
[Test]
public void Create_NameAndPath()
{
UnitItem vUnit = new UnitItem("unit_name", "unit_path", true, "");
Assert.AreEqual("unit_name", vUnit.Name, "Name wasn't set properly");
Assert.AreEqual("unit_path", vUnit.Path, "Path wasn't set properly");
}
[Test]
public void Create_Name()
{
DoTestCreate_Name("unit_name");
}
[Test]
public void Create_EmptyName()
{
DoTestCreate_Name("");
}
[Test]
public void NameChange()
{
DoTestNameChange("unit_name", "new_unit_name");
DoTestNameChange("unit_name", "");
DoTestNameChange("", "new_unit_name");
}
[Test]
public void PathChange()
{
DoTestPathChange("unit_path", "new_unit_path");
}
[Test]
public void HasStartingConditions()
{
DoTestHasStartingConditions("", false);
DoTestHasStartingConditions("{$IFDEF test_condition}", true);
}
[Test]
public void HasEndingConditions()
{
DoTestHasEndingConditions("", false);
DoTestHasEndingConditions("{$ENDIF}", true);
}
[Test]
public void HasForm()
{
DoTestHasForm("form1", true);
DoTestHasForm("", false);
}
[Test]
public void PathChange_ToEmpty()
{
DoTestPathChange("unit_path", "");
}
[Test]
public void PathChange_FromEmpty()
{
DoTestPathChange("", "new_unit_path");
}
[Test]
public void PathChange_ToSamePath()
{
DoTestPathChange("same_path", "same_path");
}
[Test]
public void ToString_WithoutPath()
{
UnitItem vUnit = new UnitItem("unit_name");
Assert.AreEqual("unit_name", vUnit.ToString("", "", false));
}
[Test]
public void ToString_WithPath_WithoutBacklash()
{
UnitItem vUnit = new UnitItem("unit_name", @"c:\temp", true, "");
string vExpected = "unit_name in 'c:\\temp\\unit_name.pas'";
string vActual = vUnit.ToString("", "", false);
Assert.AreEqual(vExpected, vActual);
}
[Test]
public void ToString_WithPath_WithBackslash()
{
UnitItem vUnit = new UnitItem("unit_name", @"c:\temp\", true, "");
string vExpected = "unit_name in 'c:\\temp\\unit_name.pas'";
string vActual = vUnit.ToString("", "", false);
Assert.AreEqual(vExpected, vActual);
}
[Test]
public void ToString_RelativePath_WithBackslash()
{
UnitItem vUnit = new UnitItem("unit_name", @"..\..\", true, "");
string vExpected = "unit_name in '..\\..\\unit_name.pas'";
string vActual = vUnit.ToString("", "", false);
Assert.AreEqual(vExpected, vActual);
}
[Test]
public void ToString_RelativePath_WithoutBackslash()
{
UnitItem vUnit = new UnitItem("unit_name", @"..\..", true, "");
string vExpected = "unit_name in '..\\..\\unit_name.pas'";
string vActual = vUnit.ToString("", "", false);
Assert.AreEqual(vExpected, vActual);
}
[Test]
public void ToString_RelativePath_BlankPath()
{
UnitItem vUnit = new UnitItem("unit_name", "", true, "");
string vExpected = "unit_name in 'unit_name.pas'";
string vActual = vUnit.ToString("", "", false);
Assert.AreEqual(vExpected, vActual);
}
[Test]
public void ToString_WithConditions()
{
string vExpected =
" {$condition1}\n" +
" unit_name in 'unit_path\\unit_name.pas'\n" +
" {$condition2}";
DoTestToString_WithConditions(true, "", false, vExpected);
}
[Test]
public void ToString_WithSeparator_First()
{
string vExpected =
" {$condition1}\n" +
" unit_name in 'unit_path\\unit_name.pas',\n" +
" {$condition2}";
DoTestToString_WithConditions(true, ",", false, vExpected);
}
[Test]
public void ToString_WithSeparator_Last()
{
string vExpected =
" {$condition1}\n" +
" unit_name in 'unit_path\\unit_name.pas'\n" +
" {$condition2};";
DoTestToString_WithConditions(true, ";", true, vExpected);
}
[Test]
public void ToString_WithSeparator_WithoutConditions_First()
{
string vExpected = " unit_name in 'unit_path\\unit_name.pas',";
DoTestToString_WithConditions(false, ",", false, vExpected);
}
[Test]
public void ToString_WithSeparator_WithoutConditions_Last()
{
string vExpected = " unit_name in 'unit_path\\unit_name.pas';";
DoTestToString_WithConditions(false, ";", true, vExpected);
}
[Test]
public void ToString_StartingConditionOnly()
{
string vExpected =
" {$begin}\n" +
" unit_name;";
UnitItem vUnit = new UnitItem("unit_name");
vUnit.StartingConditions = "{$begin}";
string vActual = vUnit.ToString(" ", ";", false);
Assert.AreEqual(vExpected, vActual);
}
[Test]
public void ToString_EndingConditionOnly()
{
string vExpected =
" unit_name,\n" +
" {$end}";
UnitItem vUnit = new UnitItem("unit_name");
vUnit.EndingConditions = "{$end}";
string vActual = vUnit.ToString(" ", ",", false);
Assert.AreEqual(vExpected, vActual);
}
[Test]
public void ToString_WithForm()
{
string vExpected =
" unit_name {unit_name};";
UnitItem vUnit = new UnitItem("unit_name", "", false, "unit_name");
string vActual = vUnit.ToString(" ", ";", true);
Assert.AreEqual(vExpected, vActual);
}
}
}
@@ -0,0 +1,433 @@
using System;
using NUnit.Framework;
using DelphiProjectHandler;
namespace DelphiProjectHandler.Tests
{
[TestFixture]
public class UnitListClassTests
{
#region (Properties)
protected UnitList TestList
{
get { return fTestList; }
}
private UnitList fTestList;
#endregion
#region (Helper methods)
protected UnitList CreateList()
{
return new UnitList();
}
protected UnitList CreateDefaultList(int iCount, bool iWithPath, bool iWithConditions)
{
UnitList vList = CreateList();
for (int vItemIdx = 0; vItemIdx < iCount; vItemIdx++)
{
UnitItem vUnit = CreateItem("DefaultName" + vItemIdx.ToString(), "DefaultPath" + vItemIdx.ToString(), iWithPath);
if (iWithConditions)
{
vUnit.StartingConditions = "{$starting_condition}";
vUnit.EndingConditions = "{$ending_condition}";
}
vList.Add(vUnit);
}
return vList;
}
protected UnitItem CreateItem(string iName, string iPath, bool iWithPath)
{
return new UnitItem(iName, iPath, iWithPath, "");
}
protected UnitItem CreateItem(string iPrefix, int iIndex, bool iWithPath)
{
return CreateItem(iPrefix + "Name" + iIndex.ToString(), iPrefix + "Path" + iIndex.ToString(), iWithPath);
}
#endregion
#region (Test methods)
protected void DoTestInsert(UnitList iList, UnitItem iUnitItem, int iIndex)
{
int vOldCount = iList.Count;
iList.Insert(iIndex, iUnitItem);
Assert.AreEqual(vOldCount + 1, iList.Count, "Item wasn't inserted properly");
Assert.AreEqual(iUnitItem, iList[iIndex], "Item wasn't assigned correctly");
}
protected void DoTestContains_NotExisting(UnitList iList, string iUnitPrefix, int iUnitIdx)
{
UnitItem vNotExisting = CreateItem(iUnitPrefix, iUnitIdx, true);
Assert.IsFalse(iList.Contains(vNotExisting.Name), "Wrong Contains result. Item shouldn't be on the list: " + vNotExisting.Name);
}
protected void DoTestToString_MultipleUnitsInConditionals(UnitList iList, int iStartingItemIdx, int iEndingItemIdx, string iExpected)
{
iList[iStartingItemIdx].StartingConditions = "{$starting_condition}";
iList[iEndingItemIdx].EndingConditions = "{$ending_condition}";
string vActual = iList.ToString();
Assert.AreEqual(iExpected, vActual);
}
#endregion
#region (Setup)
[SetUp]
protected void SetUp()
{
fTestList = CreateDefaultList(10, true, false);
}
[TearDown]
protected void TearDown()
{
fTestList = null;
}
#endregion
[Test]
public void Create()
{
UnitList vList = CreateList();
Assert.AreEqual(0, vList.Count, "List after creation is not empty");
}
[Test]
public void Add()
{
UnitList vList = CreateList();
for (int vItemIdx = 0; vItemIdx < 10; vItemIdx++)
{
UnitItem vExpected = CreateItem("unit ", vItemIdx, true);
vList.Add(vExpected);
Assert.AreEqual(vItemIdx + 1, vList.Count, "Unit item wasn't added to the list");
Assert.AreEqual(vExpected, vList[vItemIdx], "Unit item wasn't set properly");
}
}
[Test]
[ExpectedException(typeof(ArgumentException))]
public void Add_Duplicates()
{
UnitList vList = CreateList();
UnitItem vItem = CreateItem("duplicated", 0, true);
vList.Add(vItem);
vList.Add(vItem);
}
[Test]
public void Insert_AtTheBeginning()
{
for (int vItemIdx = 0; vItemIdx < 5; vItemIdx++)
{
UnitItem vExpected = CreateItem("unit ", vItemIdx, true);
DoTestInsert(TestList, vExpected, 0);
}
}
[Test]
public void Insert_AtTheEnd()
{
for (int vItemIdx = 0; vItemIdx < 5; vItemIdx++)
{
UnitItem vExpected = CreateItem("unit ", vItemIdx, true);
DoTestInsert(TestList, vExpected, TestList.Count);
}
}
[Test]
public void Remove_ByItem()
{
while (TestList.Count > 0)
{
UnitItem vToDelete = TestList[0];
int vOldCount = TestList.Count;
TestList.Remove(vToDelete);
Assert.AreEqual(vOldCount - 1, TestList.Count, "Item wasn't deleted from the list");
Assert.IsFalse(TestList.Contains(vToDelete), "Item wasn't deleted. Still exists on the list");
}
}
[Test]
public void Remove_ByName()
{
while (TestList.Count > 0)
{
UnitItem vToDelete = TestList[0];
int vOldCount = TestList.Count;
TestList.Remove(vToDelete.Name);
Assert.AreEqual(vOldCount - 1, TestList.Count, "Item wasn't deleted from the list");
Assert.IsFalse(TestList.Contains(vToDelete), "Item wasn't deleted. Still exists on the list");
}
}
[Test]
public void Set()
{
for (int vUnitIdx = 0; vUnitIdx < TestList.Count; vUnitIdx++)
{
UnitItem vExpected = CreateItem("NewItem", vUnitIdx, true);
TestList[vUnitIdx] = vExpected;
Assert.AreEqual(vExpected, TestList[vUnitIdx], "Item wasn't set properly");
}
}
[Test]
[ExpectedException(typeof(ArgumentException))]
public void Set_Duplicated()
{
UnitList vList = CreateDefaultList(2, true, false);
UnitItem vItem = CreateItem("duplicated", 0, true);
vList[0] = vItem;
vList[1] = vItem;
}
[Test]
public void Contains_Existing()
{
for (int vUnitIdx = 0; vUnitIdx < TestList.Count; vUnitIdx++)
{
UnitItem vExpected = TestList[vUnitIdx];
Assert.IsTrue(TestList.Contains(vExpected.Name), "Wrong Contains result. Item should be on the list");
}
}
[Test]
public void Contains_NonExisting()
{
for (int vUnitIdx = 0; vUnitIdx < TestList.Count; vUnitIdx++)
{
DoTestContains_NotExisting(TestList, "DiffDefault", vUnitIdx);
DoTestContains_NotExisting(TestList, "Default", vUnitIdx + TestList.Count + 1);
}
}
[Test]
public void IndexOf_Name_Existing()
{
for (int vUnitIdx = 0; vUnitIdx < TestList.Count; vUnitIdx++)
{
UnitItem vExpected = TestList[vUnitIdx];
Assert.AreEqual(vUnitIdx, TestList.IndexOf(vExpected.Name), "Wrong IndexOf by name result. Item should be found");
}
}
[Test]
public void IndexOf_Name_NonExisting()
{
for (int vUnitIdx = 0; vUnitIdx < TestList.Count; vUnitIdx++)
{
UnitItem vExpected = CreateItem("NotExisting", vUnitIdx, true);
Assert.AreEqual(-1, TestList.IndexOf(vExpected.Name), "Wrong IndexOf by name result. Item shouldn't be on the list");
}
}
[Test]
public void IndexOf_NameStart_Existing()
{
for (int vUnitIdx = 0; vUnitIdx < TestList.Count; vUnitIdx++)
{
UnitItem vExpected = TestList[vUnitIdx];
Assert.AreEqual(vUnitIdx, TestList.IndexOf(vExpected.Name, vUnitIdx), "Wrong IndexOf by name result. Item should be found");
Assert.AreEqual(-1, TestList.IndexOf(vExpected.Name, vUnitIdx + 1), "Wrong IndexOf by name result. Item shouldn't be found");
}
}
[Test]
public void IndexOf_NameStart_NonExisting()
{
for (int vUnitIdx = 0; vUnitIdx < TestList.Count; vUnitIdx++)
{
UnitItem vExpected = CreateItem("NotExisting", vUnitIdx, true);
Assert.AreEqual(-1, TestList.IndexOf(vExpected.Name, vUnitIdx), "Wrong IndexOf by name result. Item shouldn't be on the list");
}
}
[Test]
public void IndexOf_NameStartCount_Existing()
{
for (int vUnitIdx = 0; vUnitIdx < TestList.Count; vUnitIdx++)
{
UnitItem vExpected = TestList[vUnitIdx];
Assert.AreEqual(vUnitIdx, TestList.IndexOf(vExpected.Name, vUnitIdx, 1), "Wrong IndexOf by name result");
Assert.AreEqual(-1, TestList.IndexOf(vExpected.Name, vUnitIdx + 1, 1), "Wrong IndexOf by name result. Item shouldn't be found. vUnitIdx + 1");
Assert.AreEqual(-1, TestList.IndexOf(vExpected.Name, vUnitIdx, 0), "Wrong IndexOf by name result. Item shouldn't be found. Count = 0");
}
}
[Test]
public void IndexOf_NameStartCount_NonExisting()
{
for (int vUnitIdx = 0; vUnitIdx < TestList.Count; vUnitIdx++)
{
UnitItem vExpected = CreateItem("NotExisting", vUnitIdx, true);
Assert.AreEqual(-1, TestList.IndexOf(vExpected.Name, vUnitIdx, 1), "Wrong IndexOf by name result. Item shouldn't be on the list");
}
}
[Test]
public void LastIndexOf_Name_Existing()
{
for (int vUnitIdx = 0; vUnitIdx < TestList.Count; vUnitIdx++)
{
UnitItem vExpected = TestList[vUnitIdx];
Assert.AreEqual(vUnitIdx, TestList.LastIndexOf(vExpected.Name), "Wrong IndexOf by name result. Item should be found");
}
}
[Test]
public void LastIndexOf_Name_NonExisting()
{
for (int vUnitIdx = 0; vUnitIdx < TestList.Count; vUnitIdx++)
{
UnitItem vExpected = CreateItem("NotExisting", vUnitIdx, true);
Assert.AreEqual(-1, TestList.LastIndexOf(vExpected.Name), "Wrong IndexOf by name result. Item shouldn't be on the list");
}
}
[Test]
public void LastIndexOf_NameStart_Existing()
{
for (int vUnitIdx = 0; vUnitIdx < TestList.Count; vUnitIdx++)
{
UnitItem vExpected = TestList[vUnitIdx];
Assert.AreEqual(vUnitIdx, TestList.LastIndexOf(vExpected.Name, vUnitIdx), "Wrong IndexOf by name result. Item should be found");
Assert.AreEqual(-1, TestList.LastIndexOf(vExpected.Name, vUnitIdx - 1), "Wrong IndexOf by name result. Item shouldn't be found");
}
}
[Test]
public void LastIndexOf_NameStart_NonExisting()
{
for (int vUnitIdx = 0; vUnitIdx < TestList.Count; vUnitIdx++)
{
UnitItem vExpected = CreateItem("NotExisting", vUnitIdx, true);
Assert.AreEqual(-1, TestList.LastIndexOf(vExpected.Name, vUnitIdx), "Wrong IndexOf by name result. Item shouldn't be on the list");
}
}
[Test]
public void LastIndexOf_NameStartCount_Existing()
{
for (int vUnitIdx = 0; vUnitIdx < TestList.Count; vUnitIdx++)
{
UnitItem vExpected = TestList[vUnitIdx];
Assert.AreEqual(vUnitIdx, TestList.LastIndexOf(vExpected.Name, vUnitIdx, 1), "Wrong IndexOf by name result");
Assert.AreEqual(-1, TestList.LastIndexOf(vExpected.Name, vUnitIdx - 1, 1), "Wrong IndexOf by name result. Item shouldn't be found. vUnitIdx + 1");
Assert.AreEqual(-1, TestList.LastIndexOf(vExpected.Name, vUnitIdx, 0), "Wrong IndexOf by name result. Item shouldn't be found. Count = 0");
}
}
[Test]
public void LastIndexOf_NameStartCount_NonExisting()
{
for (int vUnitIdx = 0; vUnitIdx < TestList.Count; vUnitIdx++)
{
UnitItem vExpected = CreateItem("NotExisting", vUnitIdx, true);
Assert.AreEqual(-1, TestList.LastIndexOf(vExpected.Name, vUnitIdx, 1), "Wrong IndexOf by name result. Item shouldn't be on the list");
}
}
[Test]
public void ToString_WithPaths()
{
string vExpected =
"uses\n" +
" DefaultName0 in 'DefaultPath0\\DefaultName0.pas',\n" +
" DefaultName1 in 'DefaultPath1\\DefaultName1.pas';";
UnitList vList = CreateDefaultList(2, true, false);
string vActual = vList.ToString();
Assert.AreEqual(vExpected, vActual);
}
[Test]
public void ToString_WithoutPaths()
{
string vExpected =
"uses\n" +
" DefaultName0,\n" +
" DefaultName1;";
UnitList vList = CreateDefaultList(2, false, false);
string vActual = vList.ToString();
Assert.AreEqual(vExpected, vActual);
}
[Test]
public void ToString_WithPaths_WithConditions()
{
string vExpected =
"uses\n" +
" {$starting_condition}\n" +
" DefaultName0 in 'DefaultPath0\\DefaultName0.pas',\n" +
" {$ending_condition}\n" +
" {$starting_condition}\n" +
" DefaultName1 in 'DefaultPath1\\DefaultName1.pas'\n" +
" {$ending_condition};";
UnitList vList = CreateDefaultList(2, true, true);
string vActual = vList.ToString();
Assert.AreEqual(vExpected, vActual);
}
[Test]
public void ToString_WithoutPaths_WithConditions()
{
string vExpected =
"uses\n" +
" {$starting_condition}\n" +
" DefaultName0,\n" +
" {$ending_condition}\n" +
" {$starting_condition}\n" +
" DefaultName1\n" +
" {$ending_condition};";
UnitList vList = CreateDefaultList(2, false, true);
string vActual = vList.ToString();
Assert.AreEqual(vExpected, vActual);
}
[Test]
public void ToString_MultipleUnitsInConditionals_AtEnd()
{
string vExpected =
"uses\n" +
" DefaultName0,\n" +
" {$starting_condition}\n" +
" DefaultName1,\n" +
" DefaultName2\n" +
" {$ending_condition};";
UnitList vList = CreateDefaultList(3, false, false);
DoTestToString_MultipleUnitsInConditionals(vList, 1, 2, vExpected);
}
[Test]
public void ToString_MultipleUnitsInConditionals_AtBeginning()
{
string vExpected =
"uses\n" +
" {$starting_condition}\n" +
" DefaultName0,\n" +
" DefaultName1,\n" +
" {$ending_condition}\n" +
" DefaultName2;";
UnitList vList = CreateDefaultList(3, false, false);
DoTestToString_MultipleUnitsInConditionals(vList, 0, 1, vExpected);
}
}
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,58 @@
using System;
using System.Reflection;
namespace DelphiProjectHandler.Tests.Utilities
{
/// <summary>
/// Runs static and non-static private methods.
/// </summary>
public class MethodRunner
{
/// <summary>
/// Runs a private method of an object instance.
/// </summary>
/// <param name="iObject">Existing object instance.</param>
/// <param name="iMethodName">Method to run.</param>
/// <param name="iParams">Parameters for the method.</param>
/// <returns>Result of running the method.</returns>
public static object RunInstance(object iObject, string iMethodName, object[] iParams)
{
BindingFlags vFlags = BindingFlags.Instance;
return RunMethod(iObject.GetType(), iObject, vFlags, iMethodName, iParams);
}
/// <summary>
/// Runs a private static method of a class.
/// </summary>
/// <param name="iType">Class type.</param>
/// <param name="iMethodName">Method to run.</param>
/// <param name="iParams">Parameters for the method.</param>
/// <returns>Result of running the method.</returns>
public static object RunStatic(Type iType, string iMethodName, object[] iParams)
{
BindingFlags vFlags = BindingFlags.Static;
return RunMethod(iType, null, vFlags, iMethodName, iParams);
}
/// <summary>
/// Runs a private static or non-static method of a class or existing object instance.
/// </summary>
/// <param name="iType">Class type.</param>
/// <param name="iObject">Existing object instance.</param>
/// <param name="iBindingFlags">Flags used when searching for the method.
/// By default BindingFlags.NonPublic and BindingFlags.Public will be
/// added.</param>
/// <param name="iMethodName">Method to run.</param>
/// <param name="iParams">Parameters for the method.</param>
/// <returns>Result of running the method.</returns>
protected static object RunMethod(Type iType, object iObject, BindingFlags iBindingFlags, string iMethodName, params object[] iParams)
{
iBindingFlags = iBindingFlags | BindingFlags.NonPublic | BindingFlags.Public;
MethodInfo vMethodInfo = iType.GetMethod(iMethodName, iBindingFlags);
if (vMethodInfo == null)
throw new ArgumentException("Private method " + iMethodName + " was not found in type " + iType.ToString());
return vMethodInfo.Invoke(iObject, iParams);
}
}
}
@@ -0,0 +1,93 @@
using System;
using NUnit.Framework;
namespace DelphiProjectHandler.Tests.Utilities
{
[TestFixture]
public class MethodRunnerClassTests
{
protected class MethodRunnerTester
{
protected static int Calculate(int iLeft, int iRight, int iMultiplier)
{
return (iLeft + iRight) * iMultiplier;
}
public MethodRunnerTester(int iOffset)
{
Offset = iOffset;
}
public int Offset;
public void VoidFunction(int iLeft, int iRight, ref int ivTotal)
{
ivTotal = Calculate(iLeft, iRight, 2) + Offset;
}
public int Function(int iLeft, int iRight)
{
return Calculate(iLeft, iRight, 3) + Offset;
}
public static void StaticVoidFunction(int iLeft, int iRight, ref int ivTotal)
{
ivTotal = Calculate(iLeft, iRight, 4);
}
public static int StaticFunction(int iLeft, int iRight)
{
return Calculate(iLeft, iRight, 5);
}
}
[Test]
public void RunInstanceFunction()
{
MethodRunnerTester vTester = new MethodRunnerTester(1);
int vActual = (int)MethodRunner.RunInstance(vTester, "Function", new object[] { 2, 3 });
Assert.AreEqual(16, vActual, "Wrong result for instance function");
}
[Test]
public void RunInstanceVoidFunction()
{
MethodRunnerTester vTester = new MethodRunnerTester(2);
int vActual = 0;
object[] vParams = new object[] { 2, 3, vActual };
MethodRunner.RunInstance(vTester, "VoidFunction", vParams);
Assert.AreEqual(12, vParams[2], "Wrong result for void instance function");
}
[Test]
public void RunStaticFunction()
{
int vActual = (int)MethodRunner.RunStatic(typeof(MethodRunnerTester), "StaticFunction", new object[] { 2, 3 });
Assert.AreEqual(25, vActual, "Wrong result for instance function");
}
[Test]
public void RunStaticVoidFunction()
{
int vActual = 0;
object[] vParams = new object[] { 2, 3, vActual };
MethodRunner.RunStatic(typeof(MethodRunnerTester), "StaticVoidFunction", vParams);
Assert.AreEqual(20, vParams[2], "Wrong result for instance function");
}
[Test]
[ExpectedException(typeof(ArgumentException))]
public void RunNonExistingMethod()
{
MethodRunnerTester vTester = new MethodRunnerTester(1);
MethodRunner.RunInstance(vTester, "NonExistingMethod", null);
}
[Test]
[ExpectedException(typeof(ArgumentException))]
public void RunNonExistingStaticMethod()
{
MethodRunner.RunStatic(typeof(MethodRunnerTester), "NonExistingMethod", null);
}
}
}
@@ -0,0 +1,67 @@
/*
* Created by SharpDevelop.
* User: SG0894652
* Date: 8/10/2009
* Time: 9:01 PM
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Collections.Generic;
using NUnit.Framework;
using DelphiProjectHandler.Dialogs;
namespace DelphiProjectHandler.Tests.Utils
{
[TestFixture]
public class ListUtilsTests
{
#region (Test methods)
protected void CompareLists<T>(IList<T> iActual, IList<T> iExpected, string iErrorMsg)
{
Assert.AreEqual(iExpected.Count, iActual.Count, "Different no. of items returned.");
for (int vItemIdx = 0; vItemIdx < iActual.Count; vItemIdx++)
Assert.AreEqual(iExpected[vItemIdx], iActual[vItemIdx], "Different items found. Item: " + vItemIdx.ToString() + ". " + iErrorMsg);
}
protected void TestRemoveDuplicates<T>(T[] iValues, T[] iExpected, string iErrorMsg)
{
IList<T> vActual = ListUtils.RemoveDuplicates<T>(iValues);
CompareLists(vActual, iExpected, iErrorMsg);
}
protected void TestNormalize<T>(T[] iValues, T[] iExpected, string iErrorMsg)
{
IList<T> vActual = ListUtils.Normalize<T>(iValues);
CompareLists(vActual, iExpected, iErrorMsg);
}
#endregion
[Test]
public void RemoveDuplicates()
{
TestRemoveDuplicates<int>(
new int[] {123, 234, 345, 456, 123, 123, 234, 234, 345, 345, 456, 456},
new int[] {123, 234, 345, 456}, "Test 1"
);
TestRemoveDuplicates<string>(
new string[] {"123", "234", "345", "abc", "def", "ghi", "123", "234", "345", "abc", "def", "ghi", "123", "234", "345", "abc", "def", "ghi", null, null},
new string[] {"123", "234", "345", "abc", "def", "ghi", null}, "Test 2");
}
[Test]
public void Normalize()
{
TestNormalize<int>(
new int[] {123, 234, 345, 456, 123, 123, 234, 234, 345, 345, 456, 456},
new int[] {123, 234, 345, 456}, "Test 1"
);
TestNormalize<string>(
new string[] {"123", "234", "345", "abc", "def", "ghi", "123", "234", "345", "abc", "def", "ghi", "123", "234", "345", "abc", "def", "ghi", null, null},
new string[] {"123", "234", "345", "abc", "def", "ghi", null}, "Test 2");
}
}
}
@@ -0,0 +1,352 @@
using System;
using System.Collections.Generic;
using System.IO;
using NUnit.Framework;
using DelphiProjectHandler.Dialogs;
namespace DelphiProjectHandler.Tests.Utils
{
[TestFixture]
public class PathUtilsClassTests
{
#region (Helper methods)
protected void CompareLists(IList<string> iActual, IList<string> iExpected, string iErrorMsg)
{
Assert.AreEqual(iExpected.Count, iActual.Count, "Different no. of items returned.");
for (int vItemIdx = 0; vItemIdx < iActual.Count; vItemIdx++)
Assert.AreEqual(iExpected[vItemIdx], iActual[vItemIdx], "Different items found. Item: " + vItemIdx.ToString() + ". " + iErrorMsg);
}
protected void DoFail(string iMessage, string iCorrectPath, string iPathToFix)
{
Assert.Fail(iMessage + "; " + GetPathsMessage(iCorrectPath, iPathToFix));
}
protected string GetPathsMessage(string iBasePath, string iPath)
{
return string.Format("Base path: {0}; Path: {1}", iBasePath, iPath);
}
#endregion
#region (Test methods)
protected void TestConcatFolders(int iStartIndex, string[] iFolders, string iExpected)
{
string vActual = PathUtils.ConcatFolders(iStartIndex, iFolders);
Assert.AreEqual(iExpected, vActual);
}
protected void TestBuildGoUpPath(int iCount, string iExpected)
{
string vActual = PathUtils.BuildGoUpPath(iCount);
Assert.AreEqual(iExpected, vActual, "Number of levels: " + iCount.ToString());
}
protected void TestSplitPaths(string iPath, string[] iExpected)
{
string[] vActual = PathUtils.SplitPath(iPath);
Assert.AreEqual(iExpected.Length, vActual.Length, "Different number of folders returned. Path: " + iPath);
for (int vFolderIdx = 0; vFolderIdx < vActual.Length; vFolderIdx++)
Assert.AreEqual(iExpected[vFolderIdx], vActual[vFolderIdx], string.Format("Wrong folder. Path: {0}, Index: {1}", iPath, vFolderIdx.ToString()));
}
protected void TestFixRootPath(string iCorrectPath, string iPathToFix, string iExpected)
{
try
{
string vActual = PathUtils.FixRootPath(iCorrectPath, iPathToFix);
Assert.AreEqual(iExpected, vActual, GetPathsMessage(iCorrectPath, iPathToFix));
}
catch (Exception e)
{
DoFail(e.Message, iCorrectPath, iPathToFix);
}
}
protected void TestFixRootPath(string iBasePath)
{
try
{
string vRootPath = "";
if (iBasePath != "")
vRootPath = Path.GetPathRoot(iBasePath).TrimEnd(Path.DirectorySeparatorChar);
TestFixRootPath(iBasePath, @"\temp2", vRootPath + @"\temp2");
TestFixRootPath(iBasePath, @"d:\temp2", @"d:\temp2");
TestFixRootPath(iBasePath, @"temp2", @"temp2");
TestFixRootPath(iBasePath, @"", @"");
}
catch (Exception e)
{
DoFail(e.Message, iBasePath, "<unknown>");
}
}
protected void TestCombine(string iBasePath, string iAddedPath, string iExpected, bool iShouldFail)
{
string vActual = "";
try
{
vActual = PathUtils.Combine(iBasePath, iAddedPath);
if (iShouldFail)
DoFail("Exception should be raised, while it wasn't", iBasePath, iAddedPath);
}
catch (ArgumentException e)
{
if (!iShouldFail)
DoFail("Exception was raised while it shouldn't. " + e.Message, iBasePath, iAddedPath);
else
return;
}
Assert.AreEqual(iExpected, vActual, GetPathsMessage(iBasePath, iAddedPath));
}
protected void TestCombine(string iBasePath)
{
try
{
string vBasePath = PathUtils.AddEndingDirectorySeparator(iBasePath);
TestCombine(iBasePath, @"c:\", @"c:\", iBasePath != "");
TestCombine(iBasePath, @"c:\temp", @"c:\temp", iBasePath != "");
TestCombine(iBasePath, @"c:", @"c:", iBasePath != "");
TestCombine(iBasePath, @"\temp", vBasePath + @"temp", false);
TestCombine(iBasePath, @"temp", vBasePath + @"temp", false);
TestCombine(iBasePath, @"\", vBasePath, false);
TestCombine(iBasePath, @"", vBasePath, false);
}
catch (Exception e)
{
DoFail(e.Message, iBasePath, "");
}
}
protected void TestRemoveEndingDirectorySeparator(string iPath, string iExpected)
{
string vActual = PathUtils.RemoveEndingDirectorySeparator(iPath);
Assert.AreEqual(iExpected, vActual, "Test value: " + iPath);
}
protected void TestAddEndingDirectorySeparator(string iPath, string iExpected)
{
string vActual = PathUtils.AddEndingDirectorySeparator(iPath);
Assert.AreEqual(iExpected, vActual, "Test value: " + iPath);
}
protected void TestAddEndingDirectorySeparator_List(IList<string> iPaths, IList<string> iExpected)
{
IList<string> vActual = PathUtils.AddEndingDirectorySeparator(iPaths);
CompareLists(vActual, iExpected, "");
}
protected void TestHaveSameRoots(string iLeftPath, string iRightPath, bool iExpected)
{
bool vActual = PathUtils.HaveSameRoots(iLeftPath, iRightPath);
Assert.AreEqual(iExpected, vActual, "Left path: " + iLeftPath + "; Right path: " + iRightPath);
}
protected void TestGetFirstDifferentFolderIdx(string[] iLeftFolders, string[] iRightFolders, int iExpected)
{
int vActual = PathUtils.GetFirstDifferentFolderIdx(iLeftFolders, iRightFolders);
Assert.AreEqual(iExpected, vActual);
}
protected void TestIsValidPath(string iPath, bool iExpected, string iErrorMsg)
{
bool vActual = PathUtils.IsValidPath(iPath);
Assert.AreEqual(iExpected, vActual, "Path was recognized incorrectly. " + iErrorMsg);
}
protected void TestRemoveInvalidPaths(IList<string> iPaths, IList<string> iExpected)
{
IList<string> vActual = PathUtils.RemoveInvalidPaths(iPaths);
Assert.AreEqual(iExpected.Count, vActual.Count, "Wrong no. of items was returned");
for (int vItemIdx = 0; vItemIdx < vActual.Count; vItemIdx++)
Assert.AreEqual(iExpected[vItemIdx], vActual[vItemIdx], "Paths are different. Index: " + vItemIdx.ToString());
}
protected void TestNormalize(IList<string> iPaths, IList<string> iExpected)
{
IList<string> vActual = PathUtils.Normalize(iPaths);
CompareLists(vActual, iExpected, "");
}
#endregion
[Test]
public void ConcatFolders_StartOn1st()
{
TestConcatFolders(0, new string[] { "folder1" }, @"folder1\");
TestConcatFolders(0, new string[] { "folder1", "folder2" }, @"folder1\folder2\");
TestConcatFolders(0, new string[] { "folder1", "folder2", @"folder3\" }, @"folder1\folder2\folder3\");
}
[Test]
public void ConcatFolders_StartOn2nd()
{
TestConcatFolders(1, new string[] { "folder1" }, @"");
TestConcatFolders(1, new string[] { "folder1", "folder2" }, @"folder2\");
TestConcatFolders(1, new string[] { "folder1", "folder2", @"folder3\" }, @"folder2\folder3\");
}
[Test]
public void ConcatFolders_StartOn3rd()
{
TestConcatFolders(2, new string[] { "folder1" }, @"");
TestConcatFolders(2, new string[] { "folder1", "folder2" }, @"");
TestConcatFolders(2, new string[] { "folder1", "folder2", @"folder3\" }, @"folder3\");
}
[Test]
public void ConcatFolders_InvalidIndex()
{
TestConcatFolders(-1, new string[] { "folder1", "folder2" }, @"");
}
[Test]
public void BuildGoUpPath()
{
TestBuildGoUpPath(-1, @"");
TestBuildGoUpPath(0, @"");
TestBuildGoUpPath(1, @"..\");
TestBuildGoUpPath(2, @"..\..\");
TestBuildGoUpPath(3, @"..\..\..\");
}
[Test]
public void SplitPaths()
{
TestSplitPaths(@"temp1", new string[] { "temp1" });
TestSplitPaths(@"temp1\temp2", new string[] { "temp1", "temp2" });
TestSplitPaths(@"c:\temp1\temp2", new string[] { "c:", "temp1", "temp2" });
TestSplitPaths(@"c:\temp1\temp2\", new string[] { "c:", "temp1", "temp2", "" });
TestSplitPaths(@"\temp1\temp2\", new string[] { "", "temp1", "temp2", "" });
TestSplitPaths(@"\temp1\temp2", new string[] { "", "temp1", "temp2" });
TestSplitPaths(@"", new string[] { });
}
[Test]
public void FixRootPath()
{
TestFixRootPath(@"c:\");
TestFixRootPath(@"temp1");
TestFixRootPath(@"\temp1");
TestFixRootPath(@"");
}
[Test]
public void Combine()
{
TestCombine(@"c:\");
TestCombine(@"c:\temp1");
TestCombine(@"c:");
TestCombine(@"\temp1");
TestCombine(@"temp1");
TestCombine(@"\");
TestCombine(@"");
}
[Test]
public void RemoveEndingDirectorySeparator()
{
TestRemoveEndingDirectorySeparator(@"c:\", @"c:\");
TestRemoveEndingDirectorySeparator(@"c:\temp", @"c:\temp");
TestRemoveEndingDirectorySeparator(@"c:\temp\", @"c:\temp");
TestRemoveEndingDirectorySeparator(@"\", @"\");
TestRemoveEndingDirectorySeparator(@"", @"");
TestRemoveEndingDirectorySeparator(@"\temp\", @"\temp");
}
[Test]
public void AddEndingDirectorySeparator()
{
TestAddEndingDirectorySeparator(@"c:\temp", @"c:\temp\");
TestAddEndingDirectorySeparator(@"c:\", @"c:\");
TestAddEndingDirectorySeparator(@"c:\temp\", @"c:\temp\");
TestAddEndingDirectorySeparator(@"\", @"\");
TestAddEndingDirectorySeparator(@"", @"");
TestAddEndingDirectorySeparator(@"c:", @"c:\");
}
[Test]
public void AddEndingDirectorySeparator_List()
{
TestAddEndingDirectorySeparator_List(
new string[] {@"c:\temp", @"c:\", @"c:\temp\", @"\", "", "c:"},
new string[] {@"c:\temp\", @"c:\", @"c:\temp\", @"\", "", @"c:\"});
}
[Test]
public void HaveSameRoots()
{
TestHaveSameRoots(@"c:\", @"c:\temp", true);
TestHaveSameRoots(@"c:\", @"c:\", true);
TestHaveSameRoots(@"c:\Temp\", @"c:\temp", true);
TestHaveSameRoots(@"\temp", @"\temp2", true);
TestHaveSameRoots(@"\", @"\", true);
TestHaveSameRoots(@"c:\", @"d:\", false);
TestHaveSameRoots(@"c:\temp", @"d:\temp", false);
TestHaveSameRoots(@"\temp", @"c:\temp", false);
}
[Test]
public void GetFirstDifferentFolderIdx()
{
TestGetFirstDifferentFolderIdx(
new string[] {"folder1", "folder2", "folder3"},
new string[] {"folder1", "folder2", "folder5"},
2);
TestGetFirstDifferentFolderIdx(
new string[] { "folder1" },
new string[] { "folder2" },
0);
TestGetFirstDifferentFolderIdx(
new string[] { "folder1", "folder2" },
new string[] { "folder1", "folder2", "folder3", "folder4" },
2);
TestGetFirstDifferentFolderIdx(
new string[] { "folder1", "folder2", "folder3", "folder4" },
new string[] { "folder1", "folder2" },
2);
TestGetFirstDifferentFolderIdx(
new string[] { "folder1", "folder2" },
new string[] { "folder1", "folder2" },
2);
TestGetFirstDifferentFolderIdx(
new string[] { "folder1" },
new string[] { "folder1" },
1);
TestGetFirstDifferentFolderIdx(
new string[] { },
new string[] { },
0);
}
[Test]
public void IsValidPath()
{
TestIsValidPath(@"C:\", true, "Test 1");
TestIsValidPath(@"C:\Windows", true, "Test 2");
TestIsValidPath(@"C:\Windows\", true, "Test 3");
TestIsValidPath(@"C:\1234", false, "Test 4");
TestIsValidPath(@"C:\Windows\abc123", false, "Test 5");
}
[Test]
public void RemoveInvalidPaths()
{
TestRemoveInvalidPaths(
new string[] {@"C:\", @"c:\12345", @"C:\windows", @"c:\windows\abc123", @"C:\windows\", @"c:\1234\abc"},
new string[] {@"C:\", @"C:\windows", @"C:\windows\"});
}
[Test]
public void Normalize()
{
TestNormalize(
new string[] {@"C:\WINDOWS", null, @"C:\", @"", @"C:\123abc", @"C:\windows", @"c:\windows\", @"", @"c:\windows\123abc\", null},
new string[] {@"c:\", @"c:\windows\"}
);
}
}
}
@@ -0,0 +1,192 @@
using System;
using System.IO;
using NUnit.Framework;
using DelphiProjectHandler.Dialogs;
namespace DelphiProjectHandler.Tests.Utils
{
[TestFixture]
public class RelativePathClassTests
{
#region (Test methods)
protected string GetTestFailMessage(string iBasePath, string iPath)
{
return string.Format("Base path: {0}, Destination path: {1}", iBasePath, iPath);
}
protected void DoGetRelativePath(string iBasePath, string iPath, string iExpected)
{
try
{
string vActual = RelativePath.GetRelativePath(iBasePath, iPath);
Assert.AreEqual(iExpected, vActual, GetTestFailMessage(iBasePath, iPath));
}
catch (Exception e)
{
Assert.Fail(e.Message + "; " + GetTestFailMessage(iBasePath, iPath));
}
}
protected void DoGetRelativePath(string iBasePath, string iPath)
{
DoGetRelativePath(iBasePath, iPath, iPath);
}
protected void DoGetRelativeFileName(bool iRelativeToPath, string iBaseFileName, string iFileName, string iExpected)
{
try
{
if (iRelativeToPath)
iBaseFileName = PathUtils.AddEndingDirectorySeparator(Path.GetDirectoryName(iBaseFileName));
string vActual = RelativePath.GetRelativeFileName(iBaseFileName, iFileName);
Assert.AreEqual(iExpected, vActual, GetTestFailMessage(iBaseFileName, iFileName));
}
catch (Exception e)
{
Assert.Fail(e.Message + "; " + GetTestFailMessage(iBaseFileName, iFileName));
}
}
protected void DoGetRelativeFileName(bool iToBasePath, string iBaseFileName, string iFileName)
{
DoGetRelativeFileName(iToBasePath, iBaseFileName, iFileName, iFileName);
}
protected void DoGetRelativeFileNameByFolder(string iBaseFolder, string iFileName, string iExpected)
{
string vActual = RelativePath.GetRelativeFilenameByFolder(iBaseFolder, iFileName);
Assert.AreEqual(iExpected, vActual, GetTestFailMessage(iBaseFolder, iFileName));
}
protected void DoGetRelativeFileNameByFolder(string iBaseFolder, string iFileName)
{
DoGetRelativeFileNameByFolder(iBaseFolder, iFileName, iFileName);
}
#endregion
[Test]
public void GetRelativePath_DifferentRoots()
{
DoGetRelativePath(@"c:\windows\temp", @"d:\windows\temp\");
}
[Test]
public void GetRelativePath_Rooted_NotRooted()
{
DoGetRelativePath(@"c:\windows\temp", @"windows\temp\");
}
[Test]
public void GetRelativePath_Rooted()
{
DoGetRelativePath(@"c:\Windows\temp", @"c:\windows\temp\folder1\folder2", @"folder1\folder2\");
DoGetRelativePath(@"c:\windows\temp\folder1\folder2", @"c:\windows\temp\", @"..\..\");
DoGetRelativePath(@"c:\windows\temp\folder1\folder2", @"c:\windows\temp\folder3\folder4", @"..\..\folder3\folder4\");
DoGetRelativePath(@"c:\windows\temp\", "", @"c:\windows\temp\");
DoGetRelativePath(@"c:\windows\temp", @"c:\windows\temp", "");
}
[Test]
public void GetRelativePath_Rooted_RootFolder()
{
DoGetRelativePath(@"c:\windows\temp", @"\windows\temp\folder1\folder2", @"folder1\folder2\");
DoGetRelativePath(@"c:\windows\temp\folder1\folder2", @"\windows\temp\", @"..\..\");
DoGetRelativePath(@"c:\windows\temp\folder1\folder2", @"\windows\temp\folder3\folder4", @"..\..\folder3\folder4\");
DoGetRelativePath(@"c:\windows\temp\", @"\", @"..\..\");
}
[Test]
public void GetRelativePath_NotRooted()
{
DoGetRelativePath(@"Windows\temp", @"windows\temp\folder1\folder2", @"folder1\folder2\");
DoGetRelativePath(@"windows\temp\folder1\folder2", @"windows\temp\", @"..\..\");
DoGetRelativePath(@"windows\temp\folder1\folder2", @"windows\temp\folder3\folder4", @"..\..\folder3\folder4\");
DoGetRelativePath(@"windows\temp\", "", @"windows\temp\");
DoGetRelativePath(@"windows\temp", @"windows\temp", "");
DoGetRelativePath(@"\windows\temp", @"c:\windows\temp\folder1\folder2", @"folder1\folder2\");
DoGetRelativePath(@"\windows\temp\folder1\folder2", @"c:\windows\temp\", @"..\..\");
DoGetRelativePath(@"\windows\temp\folder1\folder2", @"c:\windows\temp\folder3\folder4", @"..\..\folder3\folder4\");
DoGetRelativePath(@"\windows\temp\", "", @"\windows\temp\");
DoGetRelativePath(@"\windows\temp", @"c:\windows\temp", "");
}
[Test]
public void GetRelativePath_NotRooted_Rooted()
{
DoGetRelativePath(@"windows\temp", @"c:\windows\temp\folder1\folder2\");
DoGetRelativePath(@"windows\temp\folder1\folder2", @"c:\windows\temp\");
DoGetRelativePath(@"windows\temp\folder1\folder2", @"c:\windows\temp\folder3\folder4\");
DoGetRelativePath(@"windows\temp\", "", @"windows\temp\");
DoGetRelativePath(@"windows\temp", @"c:\windows\temp\");
}
[Test]
public void GetRelativeFileName_DifferentRoots()
{
for (int vIdx = 0; vIdx <= 1; vIdx++)
{
bool vToBasePath = Convert.ToBoolean(vIdx);
DoGetRelativeFileName(vToBasePath, @"c:\windows\temp\file1.txt", @"d:\windows\temp\file2.txt");
DoGetRelativeFileName(vToBasePath, @"c:\windows\temp\file1.txt", @"windows\temp\file2.txt");
DoGetRelativeFileName(vToBasePath, @"c:\windows\temp\file1.txt", @"c:\windows\temp\folder1\folder2\file2.txt", @"folder1\folder2\file2.txt");
DoGetRelativeFileName(vToBasePath, @"c:\windows\temp\folder1\folder2\file1.txt", @"c:\windows\temp\file2.txt", @"..\..\file2.txt");
DoGetRelativeFileName(vToBasePath, @"c:\windows\temp\folder1\folder2\file1.txt", @"c:\windows\temp\folder3\folder4\file2.txt", @"..\..\folder3\folder4\file2.txt");
DoGetRelativeFileName(vToBasePath, @"c:\windows\temp\file1.txt", "file2.txt", @"c:\windows\temp\file2.txt");
DoGetRelativeFileName(vToBasePath, @"c:\windows\temp\file1.txt", @"c:\windows\temp\file2.txt", "file2.txt");
DoGetRelativeFileName(vToBasePath, @"c:\windows\temp\file1.txt", @"\windows\temp\folder1\folder2\file2.txt", @"folder1\folder2\file2.txt");
DoGetRelativeFileName(vToBasePath, @"c:\windows\temp\folder1\folder2\file1.txt", @"\windows\temp\file2.txt", @"..\..\file2.txt");
DoGetRelativeFileName(vToBasePath, @"c:\windows\temp\folder1\folder2\file1.txt", @"\windows\temp\folder3\folder4\file2.txt", @"..\..\folder3\folder4\file2.txt");
DoGetRelativeFileName(vToBasePath, @"c:\windows\temp\file1.txt", @"\file2.txt", @"..\..\file2.txt");
DoGetRelativeFileName(vToBasePath, @"\windows\temp\file1.txt", @"c:\windows\temp\folder1\folder2\file2.txt", @"folder1\folder2\file2.txt");
DoGetRelativeFileName(vToBasePath, @"\windows\temp\folder1\folder2\file1.txt", @"c:\windows\temp\file2.txt", @"..\..\file2.txt");
DoGetRelativeFileName(vToBasePath, @"\windows\temp\folder1\folder2\file1.txt", @"c:\windows\temp\folder3\folder4\file2.txt", @"..\..\folder3\folder4\file2.txt");
DoGetRelativeFileName(vToBasePath, @"\windows\temp\file1.txt", @"c:\windows\temp\file2.txt", "file2.txt");
DoGetRelativeFileName(vToBasePath, @"\windows\temp\file1.txt", "file2.txt", @"\windows\temp\file2.txt");
DoGetRelativeFileName(vToBasePath, @"windows\temp\file1.txt", @"windows\temp\folder1\folder2\file2.txt", @"folder1\folder2\file2.txt");
DoGetRelativeFileName(vToBasePath, @"windows\temp\folder1\folder2\file1.txt", @"windows\temp\file2.txt", @"..\..\file2.txt");
DoGetRelativeFileName(vToBasePath, @"windows\temp\folder1\folder2\file1.txt", @"windows\temp\folder3\folder4\file2.txt", @"..\..\folder3\folder4\file2.txt");
DoGetRelativeFileName(vToBasePath, @"windows\temp\file1.txt", "file2.txt", @"windows\temp\file2.txt");
DoGetRelativeFileName(vToBasePath, @"windows\temp\file1.txt", @"windows\temp\file2.txt", "file2.txt");
DoGetRelativeFileName(vToBasePath, @"windows\temp\file1.txt", @"c:\windows\temp\folder1\folder2\file2.txt");
DoGetRelativeFileName(vToBasePath, @"windows\temp\folder1\folder2\file1.txt", @"c:\windows\temp\file2.txt");
DoGetRelativeFileName(vToBasePath, @"windows\temp\folder1\folder2\file1.txt", @"c:\windows\temp\folder3\folder4\file2.txt");
DoGetRelativeFileName(vToBasePath, @"windows\temp\file1.txt", "file2.txt", @"windows\temp\file2.txt");
DoGetRelativeFileName(vToBasePath, @"windows\temp\file1.txt", @"c:\windows\temp\file2.txt");
}
}
[Test]
public void IsPathRooted()
{
Assert.IsTrue(Path.IsPathRooted(@"c:\temp"), @"c:\temp");
Assert.IsTrue(Path.IsPathRooted(@"c:\"), @"c:\");
Assert.IsTrue(Path.IsPathRooted(@"c:"), @"c:");
Assert.IsTrue(Path.IsPathRooted(@"\temp"), @"\temp");
Assert.IsFalse(Path.IsPathRooted(@"temp"), @"temp");
}
[Test]
public void GetRelativeFileName()
{
DoGetRelativeFileName(false, @"c:\Temp\folder1\folder2\filename1.txt", @"c:\temp\folder1\filename2.txt", @"..\filename2.txt");
}
[Test]
public void GetRelativeFileNameByFolder()
{
DoGetRelativeFileNameByFolder(@"c:\Temp\folder1\folder2", @"c:\temp\filename1.txt", @"..\..\filename1.txt");
DoGetRelativeFileNameByFolder(@"", @"c:\temp\filename1.txt");
}
}
}
@@ -0,0 +1,140 @@
/*
* Created by SharpDevelop.
* User: SG0894652
* Date: 8/10/2009
* Time: 9:20 PM
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Collections.Generic;
using NUnit.Framework;
using DelphiProjectHandler.Dialogs;
namespace DelphiProjectHandler.Tests.Utils
{
[TestFixture]
public class StringListUtilsTests
{
#region (Test methods)
protected void CompareLists(IList<string> iActual, IList<string> iExpected, string iErrorMsg)
{
Assert.AreEqual(iExpected.Count, iActual.Count, "Different no. of items returned.");
for (int vItemIdx = 0; vItemIdx < iActual.Count; vItemIdx++)
Assert.AreEqual(iExpected[vItemIdx], iActual[vItemIdx], "Different items found. Item: " + vItemIdx.ToString() + ". " + iErrorMsg);
}
protected void TestRemoveEmpty(IList<string> iStrings, IList<string> iExpected, string iErrorMsg)
{
IList<string> vActual = StringListUtils.RemoveEmpty(iStrings);
CompareLists(vActual, iExpected, iErrorMsg);
}
protected void TestToLower(IList<string> iStrings, IList<string> iExpected, string iErrorMsg)
{
IList<string> vActual = StringListUtils.ToLower(iStrings);
CompareLists(vActual, iExpected, iErrorMsg);
}
protected void TestToUpper(IList<string> iStrings, IList<string> iExpected, string iErrorMsg)
{
IList<string> vActual = StringListUtils.ToUpper(iStrings);
CompareLists(vActual, iExpected, iErrorMsg);
}
protected void TestRemoveDuplicates(IList<string> iStrings, IList<string> iExpected, string iErrorMsg)
{
IList<string> vActual = StringListUtils.RemoveDuplicates(iStrings);
CompareLists(vActual, iExpected, iErrorMsg);
}
protected void TestNormalize(IList<string> iStrings, IList<string> iExpected, string iErrorMsg)
{
IList<string> vActual = StringListUtils.Normalize(iStrings);
CompareLists(vActual, iExpected, iErrorMsg);
}
protected void TestSort(IList<string> iStrings, IList<string> iExpected, bool iAscending, bool iIgnoreCase, string iErrorMsg)
{
IList<string> vActual = StringListUtils.Sort(iStrings, iAscending, iIgnoreCase);
CompareLists(vActual, iExpected, iErrorMsg);
}
#endregion
[Test]
public void RemoveEmpty()
{
TestRemoveEmpty(
new string[] {"", "1", " ", "2", " ", "3 ", null, "4", null, "5"},
new string[] {"1", "2", "3 ", "4", "5"}, "Test 1"
);
}
[Test]
public void ToLower()
{
TestToLower(
new string[] {"ABC", null, "DeF", "", "ghi"},
new string[] {"abc", null, "def", "", "ghi"}, "Test 1"
);
}
[Test]
public void ToUpper()
{
TestToUpper(
new string[] {"ABC", null, "DeF", "", "ghi"},
new string[] {"ABC", null, "DEF", "", "GHI"}, "Test 1"
);
}
[Test]
public void Normalize()
{
TestNormalize(
new string[] {"ABC", null, "DeF", "", "ghi", "abc", "def", "", "ghi", null},
new string[] {"abc", "def", "ghi"}, "Test 1"
);
}
[Test]
public void RemoveDuplicates()
{
TestRemoveDuplicates(
new string[] {"123", "234", "345", "abc", "def", "ghi", "123", "234", "345", "abc", "def", "ghi", "123", "234", "345", "abc", "def", "ghi", null, null},
new string[] {"123", "234", "345", "abc", "def", "ghi", null}, "Test 2");
}
[Test]
public void Sort()
{
TestSort(
new string[] {"g", "f", "e", "d", "c", "b", "a", "G", "F", "E", "D", "C", "B", "A"},
new string[] {"A", "a", "b", "B", "C", "c", "D", "d", "E", "e", "f", "F", "g", "G"},
true, true, "Test 1"
);
TestSort(
new string[] {"A", "a", "B", "b", "C", "c", "D", "d", "E", "e", "F", "f", "G", "g"},
new string[] {"G", "g", "F", "f", "E", "e", "d", "D", "C", "c", "B", "b", "A", "a"},
false, true, "Test 2"
);
TestSort(
new string[] {"g", "f", "e", "d", "c", "b", "a", "G", "F", "E", "D", "C", "B", "A"},
new string[] {"a", "A", "b", "B", "c", "C", "d", "D", "e", "E", "f", "F", "g", "G"},
true, false, "Test 3"
);
TestSort(
new string[] {"A", "a", "B", "b", "C", "c", "D", "d", "E", "e", "F", "f", "G", "g"},
new string[] {"G", "g", "F", "f", "E", "e", "D", "d", "C", "c", "B", "b", "A", "a"},
false, false, "Test 4"
);
}
}
}
+54
View File
@@ -0,0 +1,54 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual C# Express 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DelphiProjectHandler", "DelphiProjectHandler\DelphiProjectHandler.csproj", "{5C84FFF1-2B72-440F-A36D-7D411CF7AE61}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DelphiProjectHandler.Tests", "DelphiProjectHandler.Tests\DelphiProjectHandler.Tests.csproj", "{C5750BD9-B5F5-49D4-BE26-5883BFA2894F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DelphiProjectManager", "..\DelphiProjectHandler\DelphiProjectManager\DelphiProjectManager.csproj", "{2517AB5F-FBA4-40A4-AE1E-F2CB619E5CBA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|Mixed Platforms = Debug|Mixed Platforms
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|Mixed Platforms = Release|Mixed Platforms
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{5C84FFF1-2B72-440F-A36D-7D411CF7AE61}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5C84FFF1-2B72-440F-A36D-7D411CF7AE61}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5C84FFF1-2B72-440F-A36D-7D411CF7AE61}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{5C84FFF1-2B72-440F-A36D-7D411CF7AE61}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{5C84FFF1-2B72-440F-A36D-7D411CF7AE61}.Debug|x86.ActiveCfg = Debug|Any CPU
{5C84FFF1-2B72-440F-A36D-7D411CF7AE61}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5C84FFF1-2B72-440F-A36D-7D411CF7AE61}.Release|Any CPU.Build.0 = Release|Any CPU
{5C84FFF1-2B72-440F-A36D-7D411CF7AE61}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{5C84FFF1-2B72-440F-A36D-7D411CF7AE61}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{5C84FFF1-2B72-440F-A36D-7D411CF7AE61}.Release|x86.ActiveCfg = Release|Any CPU
{C5750BD9-B5F5-49D4-BE26-5883BFA2894F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C5750BD9-B5F5-49D4-BE26-5883BFA2894F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C5750BD9-B5F5-49D4-BE26-5883BFA2894F}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{C5750BD9-B5F5-49D4-BE26-5883BFA2894F}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{C5750BD9-B5F5-49D4-BE26-5883BFA2894F}.Debug|x86.ActiveCfg = Debug|Any CPU
{C5750BD9-B5F5-49D4-BE26-5883BFA2894F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C5750BD9-B5F5-49D4-BE26-5883BFA2894F}.Release|Any CPU.Build.0 = Release|Any CPU
{C5750BD9-B5F5-49D4-BE26-5883BFA2894F}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{C5750BD9-B5F5-49D4-BE26-5883BFA2894F}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{C5750BD9-B5F5-49D4-BE26-5883BFA2894F}.Release|x86.ActiveCfg = Release|Any CPU
{2517AB5F-FBA4-40A4-AE1E-F2CB619E5CBA}.Debug|Any CPU.ActiveCfg = Debug|x86
{2517AB5F-FBA4-40A4-AE1E-F2CB619E5CBA}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
{2517AB5F-FBA4-40A4-AE1E-F2CB619E5CBA}.Debug|Mixed Platforms.Build.0 = Debug|x86
{2517AB5F-FBA4-40A4-AE1E-F2CB619E5CBA}.Debug|x86.ActiveCfg = Debug|x86
{2517AB5F-FBA4-40A4-AE1E-F2CB619E5CBA}.Debug|x86.Build.0 = Debug|x86
{2517AB5F-FBA4-40A4-AE1E-F2CB619E5CBA}.Release|Any CPU.ActiveCfg = Release|x86
{2517AB5F-FBA4-40A4-AE1E-F2CB619E5CBA}.Release|Mixed Platforms.ActiveCfg = Release|x86
{2517AB5F-FBA4-40A4-AE1E-F2CB619E5CBA}.Release|Mixed Platforms.Build.0 = Release|x86
{2517AB5F-FBA4-40A4-AE1E-F2CB619E5CBA}.Release|x86.ActiveCfg = Release|x86
{2517AB5F-FBA4-40A4-AE1E-F2CB619E5CBA}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
@@ -0,0 +1,241 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{5C84FFF1-2B72-440F-A36D-7D411CF7AE61}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>DelphiProjectHandler</RootNamespace>
<AssemblyName>DelphiProjectHandler</AssemblyName>
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>3.5</OldToolsVersion>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Data.DataSetExtensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="src\Controller\FixProjectSettingsController.cs" />
<Compile Include="src\Controller\FixUnitActionsController.cs" />
<Compile Include="src\Controller\FixUnitSettingsController.cs" />
<Compile Include="src\Controller\IFixProjectSettingsController.cs" />
<Compile Include="src\Controller\IFixProjectActionsController.cs" />
<Compile Include="src\Controller\FixProjectActionsController.cs" />
<Compile Include="src\Controller\IFixUnitActionsController.cs" />
<Compile Include="src\Controller\IFixUnitSettingsController.cs" />
<Compile Include="src\Controller\IProjectBulkOperationController.cs" />
<Compile Include="src\Controller\IUnitCleanupActionsController.cs" />
<Compile Include="src\Controller\ILibraryPathSettingsController.cs" />
<Compile Include="src\Controller\IUnitCleanupSettingsController.cs" />
<Compile Include="src\Controller\LibraryPathSettingsController.cs" />
<Compile Include="src\Controller\ProjectBulkOperationController.cs" />
<Compile Include="src\Controller\UnitCleanupActionsController.cs" />
<Compile Include="src\Controller\UnitCleanupSettingsController.cs" />
<Compile Include="src\Dialogs\FileSelectors\Specialized\DprFilesSelector.cs" />
<Compile Include="src\Dialogs\FileSelectors\Specialized\XmlFileSelector.cs" />
<Compile Include="src\IcarusAnalyzerReportParser.cs" />
<Compile Include="src\Model\ProjectBulkOperations.cs" />
<Compile Include="src\Model\FixProjectSettings.cs" />
<Compile Include="src\Model\FixUnitSettings.cs" />
<Compile Include="src\Model\IFixProjectSettings.cs" />
<Compile Include="src\Model\IFixUnitSettings.cs" />
<Compile Include="src\Model\ILibraryPathSettings.cs" />
<Compile Include="src\Model\IUnitCleanupSettings.cs" />
<Compile Include="src\Model\LibraryPathSettings.cs" />
<Compile Include="src\Model\UnitCleanupSettings.cs" />
<Compile Include="src\Operations\ProjectBulkOperationLoader.cs" />
<Compile Include="src\Operations\DelphiFileAgent.cs" />
<Compile Include="src\Operations\IDelphiFileAgent.cs" />
<Compile Include="src\Operations\IDelphiFileOperation.cs" />
<Compile Include="src\Operations\IOperationState.cs" />
<Compile Include="src\Operations\IUnitItemBuilder.cs" />
<Compile Include="src\Operations\Projects\AbstractDelphiProjectOperation.cs" />
<Compile Include="src\Operations\Projects\IProjectOperationSettings.cs" />
<Compile Include="src\Operations\Projects\IProjectOperationState.cs" />
<Compile Include="src\Operations\Projects\ProjectOperationSettings.cs" />
<Compile Include="src\Operations\Projects\ProjectOperationState.cs" />
<Compile Include="src\Operations\Projects\ProjectUnitItemBuilder.cs" />
<Compile Include="src\Operations\Units\AbstractDelphiUnitOperation.cs" />
<Compile Include="src\Operations\Units\DelphiUnitAddOperation.cs" />
<Compile Include="src\Operations\Units\DelphiUnitCleanerOperation.cs" />
<Compile Include="src\Operations\Units\DelphiUnitItemBuilder.cs" />
<Compile Include="src\Operations\Units\DelphiUnitOperationSettings.cs" />
<Compile Include="src\Operations\Units\DelphiUnitOperationState.cs" />
<Compile Include="src\Operations\Units\DelphiUnitUsesOperation.cs" />
<Compile Include="src\Operations\Units\IDelphiUnitOperation.cs" />
<Compile Include="src\Operations\DelphiUnitAgent.cs" />
<Compile Include="src\Operations\FileModifierAgent.cs" />
<Compile Include="src\Operations\Units\IDelphiUnitOperationSettings.cs" />
<Compile Include="src\Operations\Units\IDelphiUnitOperationState.cs" />
<Compile Include="src\Operations\Uses\AbstractUsesListOperation.cs" />
<Compile Include="src\Operations\Uses\IUsesListOperation.cs" />
<Compile Include="src\Operations\Uses\IUsesListOperationSettings.cs" />
<Compile Include="src\Operations\Uses\IUsesListOperationState.cs" />
<Compile Include="src\Operations\Uses\UsesListAddOperation.cs" />
<Compile Include="src\Operations\Uses\UsesListDeleteOperation.cs" />
<Compile Include="src\Operations\Uses\UsesListFixFormOperation.cs" />
<Compile Include="src\Operations\Uses\UsesListFixPathOperation.cs" />
<Compile Include="src\Operations\Uses\UsesListOperationSettings.cs" />
<Compile Include="src\Operations\Uses\UsesListOperationState.cs" />
<Compile Include="src\SuggestedUnitStructure.cs" />
<Compile Include="src\UnitStructure.cs" />
<Compile Include="src\SuggestedUnitStructureList.cs" />
<Compile Include="src\Dialogs\FileSelectors\FilesSelector.cs" />
<Compile Include="src\Dialogs\FileSelectors\FilesSelectorOptions.cs" />
<Compile Include="src\Dialogs\FileSelectors\FolderFilesImporter.cs" />
<Compile Include="src\Dialogs\FileSelectors\IFilesSelector.cs" />
<Compile Include="src\Dialogs\FileSelectors\IFolderFilesImporter.cs" />
<Compile Include="src\Utils\ICollectionUtils.cs" />
<Compile Include="src\Utils\ListUtils.cs" />
<Compile Include="src\Dialogs\FileSelectors\Specialized\PasFilesSelector.cs" />
<Compile Include="src\Utils\PathUtilsClass.cs" />
<Compile Include="src\Utils\StringListUtils.cs" />
<Compile Include="src\LibraryPaths\ClipboardLibraryPathsProvider.cs" />
<Compile Include="src\LibraryPaths\DelphiLibraryPathsProvider.cs" />
<Compile Include="src\LibraryPaths\DelphiLibraryPathsBuilder.cs" />
<Compile Include="src\LibraryPaths\DelphiRegistryKeys.cs" />
<Compile Include="src\LibraryPaths\LibraryPathsProviderFactory.cs" />
<Compile Include="src\LibraryPaths\LibraryPathsBuilderInterface.cs" />
<Compile Include="src\LibraryPaths\LibraryPathsProviderInterface.cs" />
<Compile Include="src\Operations\Projects\DelphiProjectFixFormsOperation.cs" />
<Compile Include="src\Operations\Projects\DelphiProjectFixPathsOperation.cs" />
<Compile Include="src\Operations\DelphiOperation.cs" />
<Compile Include="src\Operations\Projects\DelphiProjectRemoveUnitsOperation.cs" />
<Compile Include="src\Utils\TextBoxUtils.cs" />
<Compile Include="src\View\FormDelphiProjectManager.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="src\View\FormDelphiProjectManager.Designer.cs">
<DependentUpon>FormDelphiProjectManager.cs</DependentUpon>
</Compile>
<Compile Include="src\Operations\Projects\DelphiProjectAddUnitOperation.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="src\View\IFixProjectSettingsView.cs" />
<Compile Include="src\View\IFixUnitSettingsView.cs" />
<Compile Include="src\View\ILibraryPathSettingsView.cs" />
<Compile Include="src\View\IUnitCleanupSettingsView.cs" />
<EmbeddedResource Include="src\View\FormDelphiProjectManager.resx">
<SubType>Designer</SubType>
<DependentUpon>FormDelphiProjectManager.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<Compile Include="src\Utils\RelativePathClass.cs" />
<Compile Include="src\SourceControl\SourceOffsiteClass.cs" />
<Compile Include="src\UnitFormReaderClass.cs" />
<Compile Include="src\UnitListClass.cs" />
<Compile Include="src\UsesClauseReaderClass.cs" />
<Compile Include="src\UnitItemClass.cs" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.2.0">
<Visible>False</Visible>
<ProductName>.NET Framework 2.0 %28x86%29</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.0">
<Visible>False</Visible>
<ProductName>.NET Framework 3.0 %28x86%29</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
<Visible>False</Visible>
<ProductName>Windows Installer 3.1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
+22
View File
@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using DelphiProjectHandler.View;
namespace DelphiProjectHandler
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new FormDelphiProjectManager());
}
}
}
@@ -0,0 +1,33 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("DelphiProjectHandler")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("ProfiMile Lemańczyk sp. j.")]
[assembly: AssemblyProduct("DelphiProjectHandler")]
[assembly: AssemblyCopyright("Copyright © ProfiMile Lemańczyk sp. j. 2006")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("664d3bb0-413b-43a3-a175-26af528fb88b")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
+63
View File
@@ -0,0 +1,63 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.1
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace DelphiProjectHandler.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("DelphiProjectHandler.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}
@@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<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="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</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="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<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" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</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>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
+26
View File
@@ -0,0 +1,26 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.1
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace DelphiProjectHandler.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
}
}
@@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>
@@ -0,0 +1,81 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DelphiProjectHandler.Model;
using DelphiProjectHandler.Operations;
using DelphiProjectHandler.Operations.Projects;
namespace DelphiProjectHandler.Controller
{
public class FixProjectActionsController: IFixProjectActionsController
{
#region Private
private IFixProjectSettings fModel;
private IDelphiFileAgent fDelphiFileAgent;
#endregion
#region Protected
protected void ExecuteOperation(IDelphiFileOperation aOperation)
{
foreach (string vProjectName in Model.Projects)
{
if (vProjectName == "")
continue;
fDelphiFileAgent.Execute(vProjectName, aOperation);
}
}
#endregion
#region Public
public FixProjectActionsController()
{
fDelphiFileAgent = new DelphiFileAgent();
}
#endregion
#region IProjectManipulator Implementation
public void AddUnits()
{
IDelphiFileOperation vOperation = new DelphiProjectAddUnitOperation(Model.UnitConstraints, Model.UnitsToManipulate, Model.AddUnitPathsToDPRs);
ExecuteOperation(vOperation);
}
public void RemoveUnits()
{
IDelphiFileOperation vOperation = new DelphiProjectRemoveUnitOperation(Model.UnitConstraints, Model.UnitsToManipulate, Model.AddUnitPathsToDPRs);
ExecuteOperation(vOperation);
}
public void FixPaths()
{
IDelphiFileOperation vOperation = new DelphiProjectFixPathsOperation(Model.UnitConstraints, Model.UnitsToManipulate, Model.AddUnitPathsToDPRs);
ExecuteOperation(vOperation);
}
public void FixForms()
{
IDelphiFileOperation vOperation = new DelphiProjectFixFormsOperation(Model.UnitConstraints, Model.UnitsToManipulate, Model.AddUnitPathsToDPRs);
ExecuteOperation(vOperation);
}
public IFixProjectSettings Model
{
get { return fModel; }
set
{
if (value == null)
throw new ArgumentNullException("Model");
fModel = value;
}
}
#endregion
}
}
@@ -0,0 +1,144 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DelphiProjectHandler.Model;
using DelphiProjectHandler.Dialogs.FileSelectors;
using DelphiProjectHandler.Dialogs.FileSelectors.Specialized;
using DelphiProjectHandler.Utils;
namespace DelphiProjectHandler.Controller
{
public class FixProjectSettingsController: IFixProjectSettingsController
{
#region Private
private IFixProjectSettings fModel;
private IFilesSelector fDprFilesSelector;
private IFilesSelector fPasFilesSelector;
#endregion
#region Protected
protected IFilesSelector CreatePasFilesSelector()
{
return new PasFilesSelector(new FilesSelector());
}
protected IFilesSelector CreateDprFilesSelector()
{
return new DprFilesSelector(new FilesSelector());
}
protected void ImportFiles(string aDescription, string aFileMask, ICollection<string> aList)
{
ValidateModel();
IFolderFilesImporter vImporter = new FolderFilesImporter();
aList.Add(vImporter.SelectFiles(aDescription, aFileMask));
Model.NotifyObservers();
}
protected void SelectFiles(IFilesSelector aFilesSelector, ICollection<string> aList)
{
ValidateModel();
aList.Add(aFilesSelector.SelectFiles());
Model.NotifyObservers();
}
protected void SetFiles(ICollection<string> aNewFiles, IList<string> aDestList)
{
ValidateModel();
aDestList.Clear();
aDestList.Add(aNewFiles);
Model.NotifyObservers();
}
protected void ValidateModel()
{
if (Model == null)
throw new ArgumentNullException("Model", "Model is not assigned to the controller");
}
protected IFilesSelector DprFilesSelector
{
get { return fDprFilesSelector; }
}
protected IFilesSelector PasFilesSelector
{
get { return fPasFilesSelector; }
}
#endregion
#region Public
public FixProjectSettingsController(): base()
{
fDprFilesSelector = CreateDprFilesSelector();
fPasFilesSelector = CreatePasFilesSelector();
}
#endregion
#region IFixProjectSettingsController Members
public void ImportProjects()
{
ImportFiles("Select any folder containing your projects. Subfolders are automatically included.", "*.dpr", Model.Projects);
}
public void ImportUnits()
{
ImportFiles("Select any folder containing your units. Subfolders are automatically included.", "*.pas", Model.UnitsToManipulate);
}
public void SelectProjects()
{
SelectFiles(DprFilesSelector, Model.Projects);
}
public void SelectUnits()
{
SelectFiles(PasFilesSelector, Model.UnitsToManipulate);
}
public void SwitchAddUnitPathsToDPRs()
{
ValidateModel();
Model.AddUnitPathsToDPRs = !Model.AddUnitPathsToDPRs;
Model.NotifyObservers();
}
public void SetProjects(ICollection<string> aProjects)
{
SetFiles(aProjects, Model.Projects);
}
public void SetUnitConstraints(ICollection<string> aConstraints)
{
SetFiles(aConstraints, Model.UnitConstraints);
}
public void SetUnitsToManipulate(ICollection<string> aUnits)
{
SetFiles(aUnits, Model.UnitsToManipulate);
}
public IFixProjectSettings Model
{
get
{
return fModel;
}
set
{
if (value == null)
throw new ArgumentNullException("Model");
fModel = value;
}
}
#endregion
}
}
@@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DelphiProjectHandler.Model;
using DelphiProjectHandler.Operations;
using DelphiProjectHandler.Operations.Units;
namespace DelphiProjectHandler.Controller
{
public class FixUnitActionsController: IFixUnitActionsController
{
#region Private
private IFixUnitSettings fModel;
#endregion
#region IFixUnitActionsController Members
public void AddUnits()
{
IDelphiFileOperation vOperation = new DelphiUnitAddOperation(Model.InterfaceUnits, Model.ImplementationUnits, Model.UnitConstraints);
IDelphiFileAgent vAgent = new DelphiFileAgent();
foreach (string vUnitFilename in Model.UnitsToModify)
vAgent.Execute(vUnitFilename, vOperation);
}
public void RemoveUnits()
{
throw new NotImplementedException();
}
public Model.IFixUnitSettings Model
{
get { return fModel; }
set {
if (value == null)
throw new ArgumentNullException("Model");
fModel = value;
}
}
#endregion
}
}
@@ -0,0 +1,140 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DelphiProjectHandler.Dialogs.FileSelectors;
using DelphiProjectHandler.Dialogs.FileSelectors.Specialized;
using DelphiProjectHandler.Model;
using DelphiProjectHandler.Utils;
namespace DelphiProjectHandler.Controller
{
public class FixUnitSettingsController: IFixUnitSettingsController
{
#region Private
private IFixUnitSettings fModel;
private IFilesSelector fPasFilesSelector;
#endregion
#region Protected
protected IFilesSelector PasFilesSelector
{
get { return fPasFilesSelector; }
}
private IFilesSelector CreatePasFilesSelector()
{
return new PasFilesSelector(new FilesSelector());
}
protected void ImportFiles(string aDescription, string aFileMask, ICollection<string> aDestinationList)
{
ValidateModel();
IFolderFilesImporter vImporter = new FolderFilesImporter();
aDestinationList.Add(vImporter.SelectFiles(aDescription, aFileMask));
Model.NotifyObservers();
}
protected void SelectFiles(IList<string> aDestList)
{
ValidateModel();
aDestList.Add(PasFilesSelector.SelectFiles());
Model.NotifyObservers();
}
protected void SetFiles(ICollection<string> aNewFiles, IList<string> aDestList)
{
ValidateModel();
aDestList.Clear();
aDestList.Add(aNewFiles);
Model.NotifyObservers();
}
protected void ValidateModel()
{
if (Model == null)
throw new ArgumentNullException("Model", "Model is not assigned to the controller");
}
#endregion
#region Public
public FixUnitSettingsController()
: base()
{
fPasFilesSelector = CreatePasFilesSelector();
}
#endregion
#region IFixUnitSettingsController Members
public void ImportUnitsToModify()
{
ImportFiles("Select a folder to import Delphi units from. Subfolders are automatically included.", "*.pas", Model.UnitsToModify);
}
public void SelectUnitsToModify()
{
SelectFiles(Model.UnitsToModify);
}
public void ImportInterfaceUnits()
{
ImportFiles("Select a folder to import Delphi units from. Subfolders are automatically included.", "*.pas", Model.InterfaceUnits);
}
public void SelectInterfaceUnits()
{
SelectFiles(Model.InterfaceUnits);
}
public void ImportImplementationUnits()
{
ImportFiles("Select a folder to import Delphi units from. Subfolders are automatically included.", "*.pas", Model.ImplementationUnits);
}
public void SelectImplementationUnits()
{
SelectFiles(Model.ImplementationUnits);
}
public void SetUnitsToModify(ICollection<string> aUnits)
{
SetFiles(aUnits, Model.UnitsToModify);
}
public void SetInterfaceUnits(ICollection<string> aUnits)
{
SetFiles(aUnits, Model.InterfaceUnits);
}
public void SetImplementationUnits(ICollection<string> aUnits)
{
SetFiles(aUnits, Model.ImplementationUnits);
}
public void SetUnitConstraints(ICollection<string> aConstraints)
{
SetFiles(aConstraints, Model.UnitConstraints);
}
public Model.IFixUnitSettings Model
{
get
{
return fModel;
}
set
{
if (value == null)
throw new ArgumentNullException("Model");
fModel = value;
}
}
#endregion
}
}
@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DelphiProjectHandler.Model;
namespace DelphiProjectHandler.Controller
{
public interface IFixProjectActionsController
{
void AddUnits();
void RemoveUnits();
void FixPaths();
void FixForms();
IFixProjectSettings Model { get; set; }
}
}
@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DelphiProjectHandler.Model;
namespace DelphiProjectHandler.Controller
{
public interface IFixProjectSettingsController
{
void ImportProjects();
void SelectProjects();
void SelectUnits();
void ImportUnits();
void SwitchAddUnitPathsToDPRs();
void SetProjects(ICollection<string> aProjects);
void SetUnitsToManipulate(ICollection<string> aUnits);
void SetUnitConstraints(ICollection<string> aConstraints);
IFixProjectSettings Model { get; set; }
}
}
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DelphiProjectHandler.Model;
namespace DelphiProjectHandler.Controller
{
public interface IFixUnitActionsController
{
void AddUnits();
void RemoveUnits();
IFixUnitSettings Model { get; set; }
}
}
@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DelphiProjectHandler.Model;
namespace DelphiProjectHandler.Controller
{
public interface IFixUnitSettingsController
{
void ImportUnitsToModify();
void SelectUnitsToModify();
void ImportInterfaceUnits();
void SelectInterfaceUnits();
void ImportImplementationUnits();
void SelectImplementationUnits();
void SetUnitsToModify(ICollection<string> aUnits);
void SetInterfaceUnits(ICollection<string> aUnits);
void SetImplementationUnits(ICollection<string> aUnits);
void SetUnitConstraints(ICollection<string> aConstraints);
IFixUnitSettings Model { get; set; }
}
}
@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DelphiProjectHandler.LibraryPaths;
using DelphiProjectHandler.Model;
namespace DelphiProjectHandler.Controller
{
public interface ILibraryPathSettingsController
{
void LoadPreset(LibraryPathType aType);
void NormalizePaths();
void SetLibraryPaths(ICollection<string> aLibraryPaths);
ILibraryPathSettings Model { get; set; }
}
}
@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DelphiProjectHandler.Controller
{
public interface IProjectBulkOperationController
{
bool ProcessFile();
bool SelectFile();
}
}
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DelphiProjectHandler.Model;
namespace DelphiProjectHandler.Controller
{
public interface IUnitCleanupActionsController
{
void RemoveUnusedUnits();
IUnitCleanupSettings Model { get; set; }
}
}
@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DelphiProjectHandler.Model;
namespace DelphiProjectHandler.Controller
{
public interface IUnitCleanupSettingsController
{
void LoadFromLibraryPaths(ICollection<string> aLibraryPaths);
void PasteIcarusReport();
void SetIcarusReport(string aReport);
void SetIgnoredUnits(ICollection<string> aUnits);
void SetUnitsToClean(ICollection<string> aUnits);
IUnitCleanupSettings Model { get; set; }
}
}
@@ -0,0 +1,69 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DelphiProjectHandler.Model;
using DelphiProjectHandler.LibraryPaths;
using DelphiProjectHandler.Dialogs;
namespace DelphiProjectHandler.Controller
{
public class LibraryPathSettingsController: ILibraryPathSettingsController
{
#region (Private)
private ILibraryPathSettings fModel;
#endregion
#region (Protected)
protected void ValidateModel()
{
if (Model == null)
throw new ArgumentNullException("Model", "Model is not assigned to the controller");
}
#endregion
#region (ILibraryPathSettingsController Implementation)
public void LoadPreset(LibraryPathType aType)
{
ValidateModel();
ILibraryPathsProvider vProvider = LibraryPathsProviderFactory.CreateProvider(aType);
Model.LibraryPaths = vProvider.List();
Model.NotifyObservers();
}
public void NormalizePaths()
{
ValidateModel();
Model.LibraryPaths = PathUtils.Normalize(Model.LibraryPaths);
Model.NotifyObservers();
}
public void SetLibraryPaths(ICollection<string> aLibraryPaths)
{
ValidateModel();
Model.LibraryPaths = new List<string>(aLibraryPaths);
Model.NotifyObservers();
}
public ILibraryPathSettings Model
{
get
{
return fModel;
}
set
{
if (value == null)
throw new ArgumentNullException("Model");
fModel = value;
}
}
#endregion
}
}
@@ -0,0 +1,63 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DelphiProjectHandler.Operations;
using DelphiProjectHandler.Model;
using System.IO;
using DelphiProjectHandler.Dialogs.FileSelectors.Specialized;
using DelphiProjectHandler.Dialogs.FileSelectors;
namespace DelphiProjectHandler.Controller
{
public class ProjectBulkOperationController: IProjectBulkOperationController
{
protected XmlFileSelector Selector { get; private set; }
protected string FileName { get; private set; }
private static FixProjectActionsController CreateController(string aProjectName, IList<string> aUnits)
{
FixProjectActionsController vController = new FixProjectActionsController();
vController.Model = new FixProjectSettings();
vController.Model.Projects.Add(aProjectName);
vController.Model.UnitsToManipulate = aUnits;
return vController;
}
public bool ProcessFile()
{
ProjectBulkOperations vProjects = ProjectBulkOperationLoader.FromStream(new FileStream(FileName, FileMode.Open));
foreach (ProjectBulkOperation vProject in vProjects)
{
if (vProject.Remove.Count > 0)
{
FixProjectActionsController vController = CreateController(vProject.ProjectName, vProject.Remove);
vController.RemoveUnits();
}
if (vProject.Add.Count > 0)
{
FixProjectActionsController vController = CreateController(vProject.ProjectName, vProject.Add);
vController.AddUnits();
}
}
return true;
}
public ProjectBulkOperationController()
{
Selector = new XmlFileSelector(new FilesSelector());
FileName = "";
}
public bool SelectFile()
{
ICollection<string> vFiles = Selector.SelectFiles();
if (vFiles.Count == 0)
return false;
FileName = vFiles.ElementAt(0);
return true;
}
}
}
@@ -0,0 +1,69 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DelphiProjectHandler.Model;
using System.IO;
using DelphiProjectHandler.Operations;
namespace DelphiProjectHandler.Controller
{
public class UnitCleanupActionsController: IUnitCleanupActionsController
{
#region (Private)
private IUnitCleanupSettings fModel;
#endregion
#region (IUnitCleanupActionsController Implementation)
public void RemoveUnusedUnits()
{
SuggestedUnitStructureList vSuggestedStructures = IcarusAnalyzerReportParser.Parse(Model.IcarusReport);
StringBuilder vLog = new StringBuilder();
foreach (string vUnitFileName in Model.UnitsToClean)
{
if (vUnitFileName.Equals(""))
continue;
string vUnitName = Path.GetFileNameWithoutExtension(vUnitFileName).ToLower();
if (
!vSuggestedStructures.ContainsKey(vUnitName) ||
(vSuggestedStructures[vUnitName].MoveToInterface.Count == 0) &&
(vSuggestedStructures[vUnitName].ToDelete.Count == 0)
)
{
continue;
}
vLog.Append("Processing unit " + vUnitName + "\r\n");
DelphiUnitAgent vAgent = new DelphiUnitAgent(vUnitFileName);
vAgent.CleanupUnits(vSuggestedStructures[vUnitName], Model.IgnoredUnits);
if (vAgent.Modified)
{
vLog.Append("Saving changes in unit " + vUnitName + "\r\n");
vAgent.Save(vUnitFileName);
}
}
Model.IcarusReport = vLog.ToString();
Model.NotifyObservers();
}
public IUnitCleanupSettings Model
{
get
{
return fModel;
}
set
{
if (value == null)
throw new ArgumentNullException("Model");
fModel = value;
}
}
#endregion
}
}
@@ -0,0 +1,82 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DelphiProjectHandler.Model;
using System.IO;
using System.Windows.Forms;
namespace DelphiProjectHandler.Controller
{
public class UnitCleanupSettingsController: IUnitCleanupSettingsController
{
#region (Private)
private IUnitCleanupSettings fModel;
#endregion
#region (IUnitCleanupSettingsController Implementation)
public void LoadFromLibraryPaths(ICollection<string> aLibraryPaths)
{
List<string> vCompleteUnitList = new List<string>();
foreach (string vPath in aLibraryPaths)
{
if (vPath.Equals(""))
continue;
try
{
IList<string> vUnits = Directory.GetFiles(vPath, "*.pas", SearchOption.TopDirectoryOnly);
vCompleteUnitList.AddRange(vUnits);
}
catch (Exception iError)
{
throw new IOException("Error occurred when processing path: " + vPath + ". " + iError.Message);
}
}
Model.UnitsToClean = vCompleteUnitList;
Model.NotifyObservers();
}
public void PasteIcarusReport()
{
Model.IcarusReport = Clipboard.GetText();
Model.NotifyObservers();
}
public void SetIcarusReport(string aReport)
{
Model.IcarusReport = aReport;
Model.NotifyObservers();
}
public void SetIgnoredUnits(ICollection<string> aUnits)
{
Model.IgnoredUnits = new List<string>(aUnits);
Model.NotifyObservers();
}
public void SetUnitsToClean(ICollection<string> aUnits)
{
Model.UnitsToClean = new List<string>(aUnits);
Model.NotifyObservers();
}
public IUnitCleanupSettings Model
{
get
{
return fModel;
}
set
{
if (value == null)
throw new ArgumentNullException("Model");
fModel = value;
}
}
#endregion
}
}
@@ -0,0 +1,67 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace DelphiProjectHandler.Dialogs.FileSelectors
{
public class FilesSelector: IFilesSelector
{
#region Private
private IFilesSelectorOptions fDefaultOptions;
#endregion
#region Protected
protected IFilesSelectorOptions CreateDefaultOptions()
{
IFilesSelectorOptions vOptions = new FilesSelectorOptions();
vOptions.Filter = "Pas files|*.pas|All files|*.*";
vOptions.DefaultExt = "pas";
vOptions.MultiSelect = true;
vOptions.Title = "Select one or more units to add";
return vOptions;
}
#endregion
#region Public
public FilesSelector()
: base()
{
fDefaultOptions = CreateDefaultOptions();
}
#endregion
#region IFilesSelctor Implementation
public IFilesSelectorOptions DefaultOptions
{
get { return fDefaultOptions; }
}
public ICollection<string> SelectFiles(IFilesSelectorOptions aOptions)
{
OpenFileDialog vDialog = new OpenFileDialog();
vDialog.Filter = aOptions.Filter;
vDialog.DefaultExt = aOptions.DefaultExt;
vDialog.Multiselect = aOptions.MultiSelect;
vDialog.SupportMultiDottedExtensions = true;
vDialog.Title = aOptions.Title;
if (vDialog.ShowDialog() != DialogResult.OK)
return new List<string>();
return vDialog.FileNames;
}
public ICollection<string> SelectFiles()
{
return SelectFiles(DefaultOptions);
}
#endregion
}
}
@@ -0,0 +1,70 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DelphiProjectHandler.Dialogs.FileSelectors
{
public class FilesSelectorOptions: IFilesSelectorOptions
{
#region (Private)
private string fTitle;
private string fFilter;
private string fDefaultExt;
private bool fMultiSelect;
#endregion
#region (IFilesSelectorOptions Implementation)
public string Title
{
get
{
return fTitle;
}
set
{
fTitle = value;
}
}
public string Filter
{
get
{
return fFilter;
}
set
{
fFilter = value;
}
}
public string DefaultExt
{
get
{
return fDefaultExt;
}
set
{
fDefaultExt = value;
}
}
public bool MultiSelect
{
get
{
return fMultiSelect;
}
set
{
fMultiSelect = value;
}
}
#endregion
}
}
@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace DelphiProjectHandler.Dialogs.FileSelectors
{
public class FolderFilesImporter: IFolderFilesImporter
{
public ICollection<string> SelectFiles(string aDescription, string aFileMask)
{
FolderBrowserDialog vDialog = new FolderBrowserDialog();
vDialog.ShowNewFolderButton = false;
vDialog.Description = aDescription;
if (vDialog.ShowDialog() != DialogResult.OK)
return new List<string>();
return Directory.GetFiles(vDialog.SelectedPath, aFileMask, SearchOption.AllDirectories);
}
}
}
@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DelphiProjectHandler.Dialogs.FileSelectors
{
public interface IFilesSelectorOptions
{
string Title { get; set; }
string Filter { get; set; }
string DefaultExt { get; set; }
bool MultiSelect { get; set; }
}
public interface IFilesSelector
{
IFilesSelectorOptions DefaultOptions { get; }
ICollection<string> SelectFiles(IFilesSelectorOptions aOptions);
ICollection<string> SelectFiles();
}
}
@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DelphiProjectHandler.Dialogs.FileSelectors
{
public interface IFolderFilesImporter
{
ICollection<string> SelectFiles(string aDescription, string aFileMask);
}
}
@@ -0,0 +1,63 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DelphiProjectHandler.Dialogs.FileSelectors;
namespace DelphiProjectHandler.Dialogs.FileSelectors.Specialized
{
public class DprFilesSelector: IFilesSelector
{
#region Private
private IFilesSelector fBaseSelector;
private IFilesSelectorOptions fDefaultOptions;
#endregion
#region Protected
protected IFilesSelector BaseSelector
{
get { return fBaseSelector; }
}
protected IFilesSelectorOptions CreateDefaultOptions()
{
IFilesSelectorOptions vOptions = new FilesSelectorOptions();
vOptions.Filter = "DPR files|*.dpr|All files|*.*";
vOptions.DefaultExt = "dpr";
vOptions.MultiSelect = true;
vOptions.Title = "Select one or more projects";
return vOptions;
}
#endregion
#region Public
public DprFilesSelector(IFilesSelector aBaseSelector): base()
{
fBaseSelector = aBaseSelector;
fDefaultOptions = CreateDefaultOptions();
}
#endregion
#region IFilesSelector Members
public IFilesSelectorOptions DefaultOptions
{
get { return fDefaultOptions; }
}
public ICollection<string> SelectFiles(IFilesSelectorOptions aOptions)
{
return BaseSelector.SelectFiles(aOptions);
}
public ICollection<string> SelectFiles()
{
return SelectFiles(DefaultOptions);
}
#endregion
}
}
@@ -0,0 +1,63 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DelphiProjectHandler.Dialogs.FileSelectors.Specialized
{
public class PasFilesSelector: IFilesSelector
{
#region Private
private IFilesSelector fBaseSelector;
private IFilesSelectorOptions fDefaultOptions;
#endregion
#region Protected
protected IFilesSelector BaseSelector
{
get { return fBaseSelector; }
}
protected IFilesSelectorOptions CreateDefaultOptions()
{
IFilesSelectorOptions vOptions = new FilesSelectorOptions();
vOptions.Filter = "Pas files|*.pas|All files|*.*";
vOptions.DefaultExt = "pas";
vOptions.MultiSelect = true;
vOptions.Title = "Select one or more units to add";
return vOptions;
}
#endregion
#region Public
public PasFilesSelector(IFilesSelector aBaseSelector)
: base()
{
fBaseSelector = aBaseSelector;
fDefaultOptions = CreateDefaultOptions();
}
#endregion
#region IFilesSelector Members
public IFilesSelectorOptions DefaultOptions
{
get { return fDefaultOptions; }
}
public ICollection<string> SelectFiles(IFilesSelectorOptions aOptions)
{
return BaseSelector.SelectFiles(aOptions);
}
public ICollection<string> SelectFiles()
{
return SelectFiles(DefaultOptions);
}
#endregion
}
}
@@ -0,0 +1,62 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DelphiProjectHandler.Dialogs.FileSelectors.Specialized
{
public class XmlFileSelector: IFilesSelector
{
#region Private
private IFilesSelector fBaseSelector;
private IFilesSelectorOptions fDefaultOptions;
#endregion
#region Protected
protected IFilesSelector BaseSelector
{
get { return fBaseSelector; }
}
protected IFilesSelectorOptions CreateDefaultOptions()
{
IFilesSelectorOptions vOptions = new FilesSelectorOptions();
vOptions.Filter = "XML files|*.xml|All files|*.*";
vOptions.DefaultExt = "xml";
vOptions.MultiSelect = false;
vOptions.Title = "Select existing XML file";
return vOptions;
}
#endregion
#region Public
public XmlFileSelector(IFilesSelector aBaseSelector): base()
{
fBaseSelector = aBaseSelector;
fDefaultOptions = CreateDefaultOptions();
}
#endregion
#region IFilesSelector Members
public IFilesSelectorOptions DefaultOptions
{
get { return fDefaultOptions; }
}
public ICollection<string> SelectFiles(IFilesSelectorOptions aOptions)
{
return BaseSelector.SelectFiles(aOptions);
}
public ICollection<string> SelectFiles()
{
return SelectFiles(DefaultOptions);
}
#endregion
}
}
@@ -0,0 +1,96 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
namespace DelphiProjectHandler
{
public class IcarusAnalyzerReportException: Exception
{
public IcarusAnalyzerReportException(string iMessage): base(iMessage) {}
}
/// <summary>
/// This class is used for parsing Icarus Analyzer results. For the given report it creates a
/// list containing all units listed in the report and list of used units, splitted into
/// interface & implementation categories.
/// </summary>
public class IcarusAnalyzerReportParser
{
protected enum UsesListType: int
{
Interface = 0,
Implementation = 1
}
protected static string ExtractUnitName(string iMatch)
{
Regex vRegExpr = new Regex(@"Module (\w+) uses:", RegexOptions.IgnoreCase | RegexOptions.Singleline);
Match vMatch = vRegExpr.Match(iMatch);
if (!vMatch.Success)
throw new IcarusAnalyzerReportException("Not recognized module name. " + iMatch);
return vMatch.Groups[1].Value;
}
protected static UsesListType ExtractUsesListType(string iMatch)
{
if (Regex.IsMatch(iMatch, "Units used in interface", RegexOptions.IgnoreCase | RegexOptions.Singleline))
return UsesListType.Interface;
else
if (Regex.IsMatch(iMatch, "Units used in implementation", RegexOptions.IgnoreCase | RegexOptions.Singleline))
return UsesListType.Implementation;
else
throw new IcarusAnalyzerReportException("Not recognized uses section type. " + iMatch);
}
protected static void ExtractUnitNames(string iMatch, UsesListType iUsesType, SuggestedUnitStructure iUnitUses)
{
Regex vRegExpr = new Regex(@"(-->|==>)?\s?(\w+)\s(in\simplementation|in\sinterface|unnecessary|source\snot\sfound)(?=\s\(|\r\n)", RegexOptions.IgnoreCase | RegexOptions.Singleline);
MatchCollection vMatches = vRegExpr.Matches(iMatch);
ExtractUnitsGroup(vMatches, "", (iUsesType == UsesListType.Interface ? iUnitUses.Uses.Interface : iUnitUses.Uses.Implementation));
ExtractUnitsGroup(vMatches, "==>", iUnitUses.ToDelete);
if (iUsesType == UsesListType.Interface)
ExtractUnitsGroup(vMatches, "-->", iUnitUses.MoveToInterface, iUnitUses.Uses.Implementation);
}
protected static void ExtractUnitsGroup(MatchCollection aUnitLineMatches, string aGroupCondition, params UnitList[] aListsToAddTo)
{
var vMatchedUnits = from Match vMatch in aUnitLineMatches
where vMatch.Groups[1].Value.Equals(aGroupCondition)
select new UnitItem(vMatch.Groups[2].Value);
foreach (var vUnit in vMatchedUnits)
foreach (var vListToAddTo in aListsToAddTo)
vListToAddTo.Add(vUnit);
}
protected static void ParseMatch(string aUnitName, UsesListType aUsesListType, string aModuleReport, SuggestedUnitStructureList aLists)
{
if (!aLists.ContainsKey(aUnitName))
aLists.Add(aUnitName, new SuggestedUnitStructure());
SuggestedUnitStructure vList = aLists[aUnitName];
ExtractUnitNames(aModuleReport, aUsesListType, vList);
}
protected static void DoParse(string iReport, SuggestedUnitStructureList iLists)
{
Regex vRegEx = new Regex(@"\bModule\s[\w\s.\:\(\),\-\>=]+?(?=\bModule|\bProgram|\bLibrary)|\bModule\s[\w\s.\:\(\),\-\>=]+", RegexOptions.IgnoreCase | RegexOptions.Singleline);
var vModuleReports = from Match vMatch in vRegEx.Matches(iReport)
let vModuleReport = vMatch.Value
select new { UnitName = ExtractUnitName(vModuleReport).ToLower(), UsesListType = ExtractUsesListType(vModuleReport), Report = vModuleReport };
foreach (var vModuleReport in vModuleReports)
ParseMatch(vModuleReport.UnitName, vModuleReport.UsesListType, vModuleReport.Report, iLists);
}
public static SuggestedUnitStructureList Parse(string iReport)
{
SuggestedUnitStructureList vResult = new SuggestedUnitStructureList();
DoParse(iReport, vResult);
return vResult;
}
}
}
@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace DelphiProjectHandler.LibraryPaths
{
public class ClipboardLibraryPathsProvider: ILibraryPathsProvider
{
#region ILibraryPathsProvider Members
public IList<string> List()
{
string vPathsStr = Clipboard.GetText();
string[] vPaths = vPathsStr.Split(';');
return new List<string>(vPaths);
}
#endregion
}
}
@@ -0,0 +1,56 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace DelphiProjectHandler.LibraryPaths
{
public class DelphiLibraryPathsBuilder: ILibraryPathsBuilder
{
#region (Protected Methods)
protected IList<string> CopyFromList(IList<string> iPaths)
{
IList<string> vResult = new List<string>();
foreach (string vPath in iPaths)
vResult.Add(vPath.ToLower());
return vResult;
}
protected bool SubstituteEnvironmentPaths(IList<string> iPaths, int iPathIdx, IDictionary<string, string> iEnvironmentPaths)
{
bool vReplaced = false;
string vNewPath = iPaths[iPathIdx];
vNewPath = SubstituteEnvironmentPaths(vNewPath, iEnvironmentPaths);
vReplaced = !vNewPath.Equals(iPaths[iPathIdx]);
if (vReplaced)
iPaths[iPathIdx] = vNewPath;
return vReplaced;
}
protected string SubstituteEnvironmentPaths(string iPath, IDictionary<string, string> iEnvironmentPaths)
{
foreach (string vKey in iEnvironmentPaths.Keys)
iPath = iPath.Replace("$(" + vKey.ToLower() + ")", iEnvironmentPaths[vKey].ToLower());
return iPath;
}
#endregion
#region ILibraryPathsBuilder Members
public IList<string> Build(IList<string> iPaths, IDictionary<string, string> iEnvironmentPaths)
{
bool vReplaced = false;
IList<string> vResult = CopyFromList(iPaths);
do
{
vReplaced = false;
for (int vPathIdx = 0; vPathIdx < vResult.Count; vPathIdx++)
vReplaced = SubstituteEnvironmentPaths(vResult, vPathIdx, iEnvironmentPaths) || vReplaced;
} while (vReplaced);
return vResult;
}
#endregion
}
}
@@ -0,0 +1,76 @@
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Win32;
namespace DelphiProjectHandler.LibraryPaths
{
public class DelphiLibraryPathsProvider: ILibraryPathsProvider
{
#region (Public Methods)
public DelphiLibraryPathsProvider(LibraryPathType iType)
{
fLibraryType = iType;
}
#endregion
#region ILibraryPathsProvider Members
IList<string> ILibraryPathsProvider.List()
{
List<string> vPaths = ListPaths(LibraryType);
IDictionary<string, string> vEnvironmentPaths = ListEnvironmentPaths(LibraryType);
return BuildPaths(vPaths, vEnvironmentPaths);
}
#endregion
#region (Protected Methods)
protected string ReadString(RegistryKey iKey, string iValueName)
{
return iKey.GetValue(iValueName).ToString();
}
protected List<string> ListPaths(LibraryPathType iType)
{
List<string> vResult = new List<string>();
vResult.AddRange(ReadString(DelphiRegistryKeys.LibraryKey(iType), "Search Path").ToString().Split(';'));
return vResult;
}
protected IDictionary<string, string> ListEnvironmentPaths(LibraryPathType iType)
{
Dictionary<string, string> vResult = new Dictionary<string, string>();
try
{
vResult.Add("delphi", ReadString(DelphiRegistryKeys.RootDirKey(iType), "RootDir"));
RegistryKey vKey = DelphiRegistryKeys.EnvironmentPathsKey(iType);
foreach (string vValueName in vKey.GetValueNames())
vResult.Add(vValueName, vKey.GetValue(vValueName).ToString());
}
catch (NotSupportedException)
{
// In this case return empty dictionary - no environment variables to return
}
return vResult;
}
protected IList<string> BuildPaths(List<string> vPaths, IDictionary<string, string> vEnvironmentPaths)
{
ILibraryPathsBuilder vBuilder = new DelphiLibraryPathsBuilder();
return vBuilder.Build(vPaths, vEnvironmentPaths);
}
#endregion
#region (Protected Properties)
protected LibraryPathType LibraryType
{
get { return fLibraryType; }
}
public LibraryPathType fLibraryType;
#endregion
}
}
@@ -0,0 +1,56 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Win32;
namespace DelphiProjectHandler.LibraryPaths
{
public sealed class DelphiRegistryKeys
{
public static RegistryKey LibraryKey(LibraryPathType iType)
{
string vKey = "";
switch (iType)
{
case LibraryPathType.Delphi5:
vKey = @"Software\Borland\Delphi\5.0\Library";
break;
case LibraryPathType.Delphi6:
vKey = @"Software\Borland\Delphi\6.0\Library";
break;
default:
throw new NotSupportedException("The library type " + iType.ToString() + " is not supported");
}
return Registry.CurrentUser.OpenSubKey(vKey);
}
public static RegistryKey EnvironmentPathsKey(LibraryPathType iType)
{
string vKey = "";
switch (iType)
{
case LibraryPathType.Delphi6:
vKey = @"Software\Borland\Delphi\6.0\Environment Variables";
break;
default:
throw new NotSupportedException("The library type " + iType.ToString() + " is not supported");
}
return Registry.CurrentUser.OpenSubKey(vKey);
}
public static RegistryKey RootDirKey(LibraryPathType iType)
{
switch (iType)
{
case LibraryPathType.Delphi5:
return Registry.LocalMachine.OpenSubKey(@"Software\Borland\Delphi\5.0");
case LibraryPathType.Delphi6:
return Registry.CurrentUser.OpenSubKey(@"Software\Borland\Delphi\6.0");
default:
throw new NotSupportedException("The library type " + iType.ToString() + " is not supported");
}
}
}
}
@@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace DelphiProjectHandler.LibraryPaths
{
public interface ILibraryPathsBuilder
{
IList<string> Build(IList<string> iPaths, IDictionary<string, string> iEnvironmentPaths);
}
}
@@ -0,0 +1,59 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DelphiProjectHandler.LibraryPaths
{
public sealed class LibraryPathsProviderFactory
{
public static bool IsProviderSupported(LibraryPathType iLibraryType)
{
try
{
ILibraryPathsProvider vProvider = LibraryPathsProviderFactory.CreateProvider(iLibraryType);
return (vProvider != null);
}
catch (NotSupportedException)
{
return false;
}
}
public static LibraryPathType[] ListSupportedProviders()
{
Array vLibraryTypes = Enum.GetValues(typeof(LibraryPathType));
List<object> vSupported = new List<object>();
for (int vLibraryTypeIdx = 0; vLibraryTypeIdx < vLibraryTypes.Length; vLibraryTypeIdx++)
{
LibraryPathType vType = (LibraryPathType)vLibraryTypes.GetValue(vLibraryTypeIdx);
if (!IsProviderSupported(vType))
continue;
vSupported.Add(vType);
}
LibraryPathType[] vResult = new LibraryPathType[vSupported.Count];
for (int vSupportedIdx = 0; vSupportedIdx < vSupported.Count; vSupportedIdx++)
vResult[vSupportedIdx] = (LibraryPathType)vSupported[vSupportedIdx];
return vResult;
}
public static ILibraryPathsProvider CreateProvider(LibraryPathType iType)
{
switch (iType)
{
case LibraryPathType.Delphi5:
case LibraryPathType.Delphi6:
return new DelphiLibraryPathsProvider(iType);
case LibraryPathType.Clipboard:
return new ClipboardLibraryPathsProvider();
default:
throw new NotSupportedException("Provider " + iType.ToString() + " is not supported, yet.");
}
}
}
}
@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DelphiProjectHandler.LibraryPaths
{
public enum LibraryPathType : int
{
Delphi5 = 0,
Delphi6 = 1,
Delphi7 = 2,
Delphi2005 = 3,
Delphi2007 = 4,
Delphi2009 = 5,
Clipboard = 6
}
public interface ILibraryPathsProvider
{
IList<string> List();
}
}
@@ -0,0 +1,106 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DelphiProjectHandler.View;
namespace DelphiProjectHandler.Model
{
public class FixProjectSettings: IFixProjectSettings
{
#region (Private)
private bool fAddUnitPathsToDPRs = true;
private IList<string> fProjects = new List<string>();
private IList<string> fUnitsToManipulate = new List<string>();
private IList<string> fUnitConstraints = new List<string>();
private IList<IFixProjectSettingsView> fObservers = new List<IFixProjectSettingsView>();
#endregion
#region (Protected)
protected IList<IFixProjectSettingsView> Observers
{
get { return fObservers; }
}
#endregion
#region (IFixProjectSettingsModel implementation)
public bool AddUnitPathsToDPRs
{
get
{
return fAddUnitPathsToDPRs;
}
set
{
fAddUnitPathsToDPRs = value;
}
}
public IList<string> Projects
{
get
{
return fProjects;
}
set
{
if (value == null)
throw new ArgumentNullException("Projects");
fProjects = value;
}
}
public IList<string> UnitsToManipulate
{
get
{
return fUnitsToManipulate;
}
set
{
if (value == null)
throw new ArgumentNullException("UnitsToManipulate");
fUnitsToManipulate = value;
}
}
public IList<string> UnitConstraints
{
get
{
return fUnitConstraints;
}
set
{
if (value == null)
throw new ArgumentNullException("UnitConstraints");
}
}
public void AddObserver(View.IFixProjectSettingsView aView)
{
Observers.Add(aView);
}
public void RemoveObserver(View.IFixProjectSettingsView aView)
{
Observers.Remove(aView);
}
public void NotifyObservers()
{
foreach (IFixProjectSettingsView vObserver in Observers)
vObserver.UpdateView(this);
}
#endregion
}
}
@@ -0,0 +1,104 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DelphiProjectHandler.View;
namespace DelphiProjectHandler.Model
{
public class FixUnitSettings: IFixUnitSettings
{
#region (Private)
private IList<string> fUnitsToModify = new List<string>();
private IList<string> fInterfaceUnits = new List<string>();
private IList<string> fImplementationUnits = new List<string>();
private IList<string> fUnitConstraints = new List<string>();
private ICollection<IFixUnitSettingsView> fObservers = new List<IFixUnitSettingsView>();
#endregion
#region (Protected)
protected ICollection<IFixUnitSettingsView> Observers
{
get { return fObservers; }
}
#endregion
#region (IFixUnitSettings Implementation)
public IList<string> UnitsToModify
{
get
{
return fUnitsToModify;
}
set
{
if (value == null)
throw new ArgumentNullException("UnitsToModify");
fUnitsToModify = value;
}
}
public IList<string> InterfaceUnits
{
get
{
return fInterfaceUnits;
}
set
{
if (value == null)
throw new ArgumentNullException("InterfaceUnits");
fInterfaceUnits = value;
}
}
public IList<string> ImplementationUnits
{
get
{
return fImplementationUnits;
}
set
{
if (value == null)
throw new ArgumentNullException("ImplementationUnits");
fImplementationUnits = value;
}
}
public IList<string> UnitConstraints
{
get
{
return fUnitConstraints;
}
set
{
if (value == null)
throw new ArgumentNullException("UnitConstraints");
fUnitConstraints = value;
}
}
public void AddObserver(IFixUnitSettingsView aView)
{
Observers.Add(aView);
}
public void RemoveObserver(IFixUnitSettingsView aView)
{
Observers.Remove(aView);
}
public void NotifyObservers()
{
foreach (IFixUnitSettingsView vObserver in Observers)
vObserver.UpdateView(this);
}
}
#endregion
}
@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DelphiProjectHandler.View;
namespace DelphiProjectHandler.Model
{
public interface IFixProjectSettings
{
IList<string> Projects { get; set; }
IList<string> UnitsToManipulate { get; set; }
IList<string> UnitConstraints { get; set; }
bool AddUnitPathsToDPRs { get; set; }
void AddObserver(IFixProjectSettingsView aView);
void RemoveObserver(IFixProjectSettingsView aView);
void NotifyObservers();
}
}
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DelphiProjectHandler.View;
namespace DelphiProjectHandler.Model
{
public interface IFixUnitSettings
{
IList<string> UnitsToModify { get; set; }
IList<string> InterfaceUnits { get; set; }
IList<string> ImplementationUnits { get; set; }
IList<string> UnitConstraints { get; set; }
void AddObserver(IFixUnitSettingsView aView);
void RemoveObserver(IFixUnitSettingsView aView);
void NotifyObservers();
}
}
@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DelphiProjectHandler.LibraryPaths;
using DelphiProjectHandler.View;
namespace DelphiProjectHandler.Model
{
public interface ILibraryPathSettings
{
IList<LibraryPathType> SupportedProviders { get; }
IList<string> LibraryPaths { get; set; }
void AddObserver(ILibraryPathSettingsView aView);
void RemoveObserver(ILibraryPathSettingsView aView);
void NotifyObservers();
}
}
@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DelphiProjectHandler.View;
namespace DelphiProjectHandler.Model
{
public interface IUnitCleanupSettings
{
IList<string> UnitsToClean { get; set; }
IList<string> IgnoredUnits { get; set; }
String IcarusReport { get; set; }
void AddObserver(IUnitCleanupSettingsView aView);
void RemoveObserver(IUnitCleanupSettingsView aView);
void NotifyObservers();
}
}
@@ -0,0 +1,66 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DelphiProjectHandler.View;
using DelphiProjectHandler.LibraryPaths;
namespace DelphiProjectHandler.Model
{
public class LibraryPathSettings: ILibraryPathSettings
{
#region (Private)
private IList<string> fLibraryPaths = new List<string>();
private IList<ILibraryPathSettingsView> fObservers = new List<ILibraryPathSettingsView>();
private IList<LibraryPathType> fSupportedProviders = LibraryPathsProviderFactory.ListSupportedProviders();
#endregion
#region (Protected)
protected IList<ILibraryPathSettingsView> Observers
{
get { return fObservers; }
}
#endregion
#region (ILibraryPathSettings Implementation)
public IList<LibraryPathType> SupportedProviders
{
get { return fSupportedProviders; }
}
public IList<string> LibraryPaths
{
get
{
return fLibraryPaths;
}
set
{
if (value == null)
throw new ArgumentNullException("LibraryPaths");
fLibraryPaths = value;
}
}
public void AddObserver(ILibraryPathSettingsView aView)
{
Observers.Add(aView);
}
public void RemoveObserver(ILibraryPathSettingsView aView)
{
Observers.Remove(aView);
}
public void NotifyObservers()
{
foreach (ILibraryPathSettingsView vObserver in Observers)
vObserver.UpdateView(this);
}
#endregion
}
}
@@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
namespace DelphiProjectHandler.Model
{
[Serializable]
[XmlType(TypeName="project")]
public class ProjectBulkOperation
{
[XmlAttribute("name")]
public string ProjectName { get; set; }
[XmlArray("add")]
[XmlArrayItem("file")]
public List<string> Add { get; set; }
[XmlArray("remove")]
[XmlArrayItem("file")]
public List<string> Remove { get; set; }
public ProjectBulkOperation()
{
Add = new List<string>();
Remove = new List<string>();
}
}
[Serializable]
[XmlType(TypeName="projects")]
public class ProjectBulkOperations: List<ProjectBulkOperation>
{
}
}
@@ -0,0 +1,89 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DelphiProjectHandler.View;
namespace DelphiProjectHandler.Model
{
public class UnitCleanupSettings: IUnitCleanupSettings
{
#region (Private)
private IList<IUnitCleanupSettingsView> fObservers = new List<IUnitCleanupSettingsView>();
private IList<string> fUnitsToClean = new List<string>();
private IList<string> fIgnoredUnits = new List<string>();
private string fIcarusReport = "";
#endregion
#region (Protected)
protected IList<IUnitCleanupSettingsView> Observers
{
get { return fObservers; }
}
#endregion
#region (IUnitCleanupSettings Implementation)
public IList<string> UnitsToClean
{
get
{
return fUnitsToClean;
}
set
{
if (value == null)
throw new ArgumentNullException("UnitsToClean");
fUnitsToClean = value;
}
}
public IList<string> IgnoredUnits
{
get
{
return fIgnoredUnits;
}
set
{
if (value == null)
throw new ArgumentNullException("IgnoredUnits");
fIgnoredUnits = value;
}
}
public string IcarusReport
{
get
{
return fIcarusReport;
}
set
{
if (value == null)
throw new ArgumentNullException("IcarusReport");
fIcarusReport = value;
}
}
public void AddObserver(View.IUnitCleanupSettingsView aView)
{
Observers.Add(aView);
}
public void RemoveObserver(View.IUnitCleanupSettingsView aView)
{
Observers.Remove(aView);
}
public void NotifyObservers()
{
foreach (IUnitCleanupSettingsView vObserver in Observers)
vObserver.UpdateView(this);
}
#endregion
}
}
@@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace DelphiProjectHandler.Operations
{
public class DelphiFileAgentError : Exception
{
public DelphiFileAgentError(string aMessage): base(aMessage)
{
}
}
public class DelphiFileAgent: IDelphiFileAgent
{
public void Execute(String aUnitFileName, IDelphiFileOperation aOperation)
{
Execute(aUnitFileName, new IDelphiFileOperation[] { aOperation });
}
public void Execute(String aUnitFileName, params IDelphiFileOperation[] aOperations)
{
FileModifierAgent vFileAgent = new FileModifierAgent(aUnitFileName);
foreach (IDelphiFileOperation vOperation in aOperations)
{
try
{
vOperation.Initialize(aUnitFileName, vFileAgent.Content);
if (!vOperation.CanProcess())
return;
vFileAgent.Content = vOperation.Execute();
}
catch (Exception e)
{
throw new DelphiFileAgentError(String.Format("Error processing file: {0}. {1}", aUnitFileName, e.Message));
}
}
if (vFileAgent.Modified)
vFileAgent.Save(aUnitFileName);
}
}
}
@@ -0,0 +1,12 @@
using System;
namespace DelphiProjectHandler.Operations
{
public abstract class DelphiOperation
{
protected virtual string ReplaceContent(string iContent, string iOldValue, string iNewValue)
{
return iContent.Replace(iOldValue, iNewValue);
}
}
}
@@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using DelphiProjectHandler.Operations.Projects;
namespace DelphiProjectHandler.Operations
{
/// <summary>
/// Modifies Delphi projects, e.g. by adding units, changing unit paths etc.
/// </summary>
public class DelphiProjectAgent
{
protected FileModifierAgent FileAgent
{
get { return fFileAgent; }
}
private FileModifierAgent fFileAgent;
public DelphiProjectAgent(string iProjectName)
{
fFileAgent = new FileModifierAgent(iProjectName);
}
public bool Modified
{
get { return FileAgent.Modified; }
}
public void Save(string iProjectName)
{
FileAgent.Save(iProjectName);
}
}
}
@@ -0,0 +1,52 @@
/*
* Created by SharpDevelop.
* User: SG0894652
* Date: 8/12/2009
* Time: 10:58 PM
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Collections.Generic;
using DelphiProjectHandler.Operations.Units;
namespace DelphiProjectHandler.Operations
{
/// <summary>
/// Description of DelphiUnitAgent.
/// </summary>
public class DelphiUnitAgent
{
#region (Protected Properties)
protected FileModifierAgent FileAgent
{
get { return fFileAgent; }
}
private FileModifierAgent fFileAgent;
#endregion
public DelphiUnitAgent(string aUnitFilename)
{
fFileAgent = new FileModifierAgent(aUnitFilename);
}
public void CleanupUnits(SuggestedUnitStructure aSuggestedStructure, IList<string> aIgnoredUnits)
{
DelphiUnitCleanerOperation vOperation = new DelphiUnitCleanerOperation();
FileAgent.Content = vOperation.Execute(FileAgent.Content, aSuggestedStructure, aIgnoredUnits);
}
public bool Modified
{
get { return FileAgent.Modified; }
}
public void Save(string aUnitFilename)
{
FileAgent.Save(aUnitFilename);
}
}
}
@@ -0,0 +1,67 @@
/*
* Created by SharpDevelop.
* User: SG0894652
* Date: 8/12/2009
* Time: 10:49 PM
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.IO;
namespace DelphiProjectHandler.Operations
{
/// <summary>
/// Description of FileModifierAgent.
/// </summary>
public class FileModifierAgent
{
public FileModifierAgent(string iFileName)
{
Load(iFileName);
}
public virtual void Save(string iFileName)
{
string vTempFileName = iFileName + ".tmp";
string vBackupFileName = iFileName + ".backup";
File.SetAttributes(iFileName, FileAttributes.Normal);
File.WriteAllText(vTempFileName, Content);
File.Replace(vTempFileName, iFileName, vBackupFileName, false);
fFileName = iFileName;
fOriginalContent = Content;
}
public virtual void Load(string iFileName)
{
fFileName = iFileName;
fOriginalContent = File.ReadAllText(iFileName);
Content = OriginalContent;
}
public string FileName
{
get { return fFileName; }
}
protected string fFileName;
public string Content
{
get { return fContent; }
set { fContent = value; }
}
protected string fContent;
public string OriginalContent
{
get { return fOriginalContent; }
}
protected string fOriginalContent;
public bool Modified
{
get { return OriginalContent != Content; }
}
}
}
@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DelphiProjectHandler.Operations
{
public interface IDelphiFileAgent
{
void Execute(String aUnitFileName, IDelphiFileOperation aOperation);
void Execute(String aUnitFileName, params IDelphiFileOperation[] aOperations);
}
}
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DelphiProjectHandler.Operations
{
public interface IDelphiFileOperation
{
void Initialize(string aFileName, string aFileContent);
bool CanProcess();
string Execute();
}
}
@@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DelphiProjectHandler.Operations
{
public interface IOperationState
{
}
}
@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DelphiProjectHandler.Operations
{
public interface IUnitItemBuilder
{
UnitItem Create(string aUnitFileName);
}
}
@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DelphiProjectHandler.Model;
using System.IO;
using System.Xml.Serialization;
using System.Xml;
namespace DelphiProjectHandler.Operations
{
public class ProjectBulkOperationLoader
{
public static ProjectBulkOperations FromStream(Stream aStream)
{
XmlSerializer vSerializer = new XmlSerializer(typeof(ProjectBulkOperations));
//if (!vSerializer.CanDeserialize(XmlReader.Create(aStream)))
// throw new InvalidDataException("Unsupported stream format");
return vSerializer.Deserialize(aStream) as ProjectBulkOperations;
}
}
}
@@ -0,0 +1,83 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DelphiProjectHandler.Operations.Uses;
namespace DelphiProjectHandler.Operations.Projects
{
public abstract class AbstractDelphiProjectOperation : IDelphiFileOperation
{
private IUsesListOperation fOperation;
private IProjectOperationSettings fSettings;
private IProjectOperationState fState;
protected IUsesListOperation Operation
{
get { return fOperation; }
set { fOperation = value; }
}
protected IProjectOperationSettings Settings
{
get { return fSettings; }
set { fSettings = value; }
}
protected IProjectOperationState State
{
get { return fState; }
set { fState = value; }
}
protected virtual string ReplaceContent(string iContent, string iOldValue, string iNewValue)
{
return iContent.Replace(iOldValue, iNewValue);
}
protected IProjectOperationSettings CreateProjectSettings(ICollection<string> aRequiredUnits, ICollection<string> aUnitsToManipulate, bool aUsePaths)
{
IProjectOperationSettings vSettings = new ProjectOperationSettings();
vSettings.RequiredUnits = aRequiredUnits;
vSettings.UnitsToManipulate = aUnitsToManipulate;
vSettings.UsePaths = aUsePaths;
return vSettings;
}
protected IUnitItemBuilder CreateUnitItemBuilder(string aFileName, bool aUsePaths)
{
return new ProjectUnitItemBuilder(aFileName, aUsePaths);
}
protected abstract IUsesListOperation CreateUsesOperation(string aFileName, IProjectOperationSettings aSettings, IUnitItemBuilder aBuilder);
public AbstractDelphiProjectOperation(ICollection<string> aRequiredUnits, ICollection<string> aUnitsToManipulate, bool aUsePaths)
{
fState = new ProjectOperationState();
fSettings = CreateProjectSettings(aRequiredUnits, aUnitsToManipulate, aUsePaths);
}
public virtual void Initialize(string aFileName, string aFileContent)
{
State.FileContent = aFileContent;
State.OriginalUsesClause = UsesClauseReader.ExtractUses(aFileContent);
State.Units = UsesClauseReader.GetUnits(State.FileContent);
IUnitItemBuilder vBuilder = CreateUnitItemBuilder(aFileName, Settings.UsePaths);
fOperation = CreateUsesOperation(aFileName, Settings, vBuilder);
Operation.Initialize(State.Units);
}
public bool CanProcess()
{
return Operation.CanProcess();
}
public string Execute()
{
if (!Operation.Execute())
return State.FileContent;
return ReplaceContent(State.FileContent, State.OriginalUsesClause, State.Units.ToString());
}
}
}
@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Text;
using DelphiProjectHandler.Operations.Uses;
namespace DelphiProjectHandler.Operations.Projects
{
public class DelphiProjectAddUnitOperation: AbstractDelphiProjectOperation
{
protected override IUsesListOperation CreateUsesOperation(string aFileName, IProjectOperationSettings aSettings, IUnitItemBuilder aBuilder)
{
IUsesListOperationSettings vUsesSettings = new UsesListOperationSettings();
vUsesSettings.RequiredUnits = aSettings.RequiredUnits;
vUsesSettings.UnitItemBuilder = aBuilder;
vUsesSettings.UnitsToManipulate = aSettings.UnitsToManipulate;
return new UsesListAddOperation(vUsesSettings);
}
public DelphiProjectAddUnitOperation(ICollection<string> aRequiredUnits, ICollection<string> aUnitsToManipulate, bool aUsePaths)
: base(aRequiredUnits, aUnitsToManipulate, aUsePaths)
{
}
}
}
@@ -0,0 +1,23 @@
using System;
using DelphiProjectHandler.Operations.Uses;
using System.Collections.Generic;
namespace DelphiProjectHandler.Operations.Projects
{
public class DelphiProjectFixFormsOperation: AbstractDelphiProjectOperation
{
protected override IUsesListOperation CreateUsesOperation(string aFileName, IProjectOperationSettings aSettings, IUnitItemBuilder aBuilder)
{
IUsesListOperationSettings vUsesSettings = new UsesListOperationSettings();
vUsesSettings.RequiredUnits = aSettings.RequiredUnits;
vUsesSettings.UnitItemBuilder = aBuilder;
vUsesSettings.UnitsToManipulate = aSettings.UnitsToManipulate;
return new UsesListFixFormOperation(vUsesSettings);
}
public DelphiProjectFixFormsOperation(ICollection<string> aRequiredUnits, ICollection<string> aUnitsToManipulate, bool aUsePaths): base(aRequiredUnits, aUnitsToManipulate, aUsePaths)
{
}
}
}
@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Text;
using DelphiProjectHandler.Operations.Uses;
namespace DelphiProjectHandler.Operations.Projects
{
public class DelphiProjectFixPathsOperation: AbstractDelphiProjectOperation
{
protected override IUsesListOperation CreateUsesOperation(string aFileName, IProjectOperationSettings aSettings, IUnitItemBuilder aBuilder)
{
IUsesListOperationSettings vUsesSettings = new UsesListOperationSettings();
vUsesSettings.RequiredUnits = aSettings.RequiredUnits;
vUsesSettings.UnitItemBuilder = aBuilder;
vUsesSettings.UnitsToManipulate = aSettings.UnitsToManipulate;
return new UsesListFixPathOperation(vUsesSettings);
}
public DelphiProjectFixPathsOperation(ICollection<string> aRequiredUnits, ICollection<string> aUnitsToManipulate, bool aUsePaths): base(aRequiredUnits, aUnitsToManipulate, aUsePaths)
{
}
}
}
@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Text;
using DelphiProjectHandler.Operations.Uses;
namespace DelphiProjectHandler.Operations.Projects
{
public class DelphiProjectRemoveUnitOperation: AbstractDelphiProjectOperation
{
public DelphiProjectRemoveUnitOperation(ICollection<string> aRequiredUnits, ICollection<string> aUnitsToManipulate, bool aUsePaths)
: base(aRequiredUnits, aUnitsToManipulate, aUsePaths)
{
}
protected override IUsesListOperation CreateUsesOperation(string aFileName, IProjectOperationSettings aSettings, IUnitItemBuilder aBuilder)
{
IUsesListOperationSettings vUsesSettings = new UsesListOperationSettings();
vUsesSettings.RequiredUnits = aSettings.RequiredUnits;
vUsesSettings.UnitItemBuilder = aBuilder;
vUsesSettings.UnitsToManipulate = aSettings.UnitsToManipulate;
return new UsesListDeleteOperation(vUsesSettings);
}
}
}
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DelphiProjectHandler.Operations.Projects
{
public interface IProjectOperationSettings
{
ICollection<string> RequiredUnits { get; set; }
ICollection<string> UnitsToManipulate { get; set; }
bool UsePaths { get; set; }
}
}
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DelphiProjectHandler.Operations.Projects
{
public interface IProjectOperationState : IOperationState
{
string FileContent { get; set; }
string OriginalUsesClause { get; set; }
UnitList Units { get; set; }
}
}
@@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DelphiProjectHandler.Operations.Projects
{
public class ProjectOperationSettings: IProjectOperationSettings
{
private ICollection<string> fRequiredUnits;
public ICollection<string> RequiredUnits
{
get { return fRequiredUnits; }
set { fRequiredUnits = value; }
}
private ICollection<string> fUnitsToManipulate;
public ICollection<string> UnitsToManipulate
{
get { return fUnitsToManipulate; }
set { fUnitsToManipulate = value; }
}
private bool fUsePaths;
public bool UsePaths
{
get { return fUsePaths; }
set { fUsePaths = value; }
}
}
}
@@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DelphiProjectHandler.Operations.Projects
{
public class ProjectOperationState : IProjectOperationState
{
private string fFileContent;
public string FileContent
{
get { return fFileContent; }
set { fFileContent = value; }
}
private string fOriginalUsesState;
public string OriginalUsesClause
{
get { return fOriginalUsesState; }
set { fOriginalUsesState = value; }
}
private UnitList fUnits;
public UnitList Units
{
get { return fUnits; }
set { fUnits = value; }
}
}
}
@@ -0,0 +1,63 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using DelphiProjectHandler.Dialogs;
namespace DelphiProjectHandler.Operations.Projects
{
/// <summary>
/// UnitItem builder for creating complete project file unit item. New UnitItem will have all properties set that are normally used in a project Delphi file. It will also
/// search for corresponding dfm file.
/// </summary>
class ProjectUnitItemBuilder: IUnitItemBuilder
{
/// <summary>
/// Complete fileName or path of the project file. It is used to calculate new unit item path relative to project file location.
/// </summary>
public string BasePath
{
get { return fBasePath; }
}
private string fBasePath;
/// <summary>
/// Indicates, if unit paths should be added in a project file style, when converting the unit list to uses clause.
/// </summary>
public bool UsePaths
{
get { return fUsePaths; }
}
private bool fUsePaths;
/// <summary>
/// Creates new instance of the ProjectItemBuilder.
/// </summary>
/// <param name="aBasePath">Complete fileName or path of the project file. It is used to calculate new unit item path relative to project file location.</param>
public ProjectUnitItemBuilder(string aBasePath, bool aUsePaths)
{
fBasePath = aBasePath;
fUsePaths = aUsePaths;
}
/// <summary>
/// Creates new UnitItem object and fills it will all required information that can be used in a project file. Requires valid RelativePath builder and UnitFormFinder.
/// It finds corresponding form for the unit automatically. Path is always set relatively to the BasePath.
/// </summary>
/// <param name="aUnitFileName"></param>
/// <returns></returns>
public UnitItem Create(string aUnitFileName)
{
UnitItem vResult = new UnitItem();
vResult.Name = Path.GetFileNameWithoutExtension(aUnitFileName);
vResult.UsePath = UsePaths;
if (!aUnitFileName.Equals(""))
vResult.Path = Path.GetDirectoryName(aUnitFileName);
vResult.Path = RelativePath.GetRelativeFileName(BasePath, vResult.Path);
vResult.Form = UnitFormReader.GetUnitForm(aUnitFileName);
return vResult;
}
}
}
@@ -0,0 +1,87 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DelphiProjectHandler.Operations.Uses;
namespace DelphiProjectHandler.Operations.Units
{
public abstract class AbstractDelphiUnitOperation: IDelphiFileOperation
{
private IUsesListOperation fIntfOperation;
private IUsesListOperation fImplOperation;
private IDelphiUnitOperationState fState;
protected IDelphiUnitOperationState State
{
get { return fState; }
set { fState = value; }
}
private IDelphiUnitOperationSettings fSettings;
protected IDelphiUnitOperationSettings Settings
{
get { return fSettings; }
set { fSettings = value; }
}
protected IUnitItemBuilder CreateUnitItemBuilder()
{
return new DelphiUnitItemBuilder();
}
protected IDelphiUnitOperationSettings CreateSettings(ICollection<string> aRequiredUnits, ICollection<string> aInterfaceUnits, ICollection<string> aImplementationUnits)
{
IDelphiUnitOperationSettings vSettings = new DelphiUnitOperationSettings();
vSettings.RequiredUnits = aRequiredUnits;
vSettings.IntfUnitsToManipulate = aInterfaceUnits;
vSettings.ImplUnitsToManipulate = aImplementationUnits;
return vSettings;
}
protected abstract IUsesListOperation CreateUsesOperation(ICollection<string> aUnitsToManipulate, ICollection<string> aRequiredUnits, IUnitItemBuilder aBuilder);
protected virtual string ReplaceContent(string iContent, string iOldValue, string iNewValue)
{
return iContent.Replace(iOldValue, iNewValue);
}
public AbstractDelphiUnitOperation(ICollection<string> aInterfaceUnits, ICollection<string> aImplementationUnits, ICollection<string> aRequiredUnits)
{
fState = new DelphiUnitOperationState();
fSettings = CreateSettings(aRequiredUnits, aInterfaceUnits, aImplementationUnits);
}
public void Initialize(string aFileName, string aFileContent)
{
State.FileContent = aFileContent;
string vIntfUsesClause = "", vImplUsesClause = "";
UsesClauseReader.ExtractUses(aFileContent, out vIntfUsesClause, out vImplUsesClause);
State.OriginalIntfUsesClause = vIntfUsesClause;
State.OriginalImplUsesClause = vImplUsesClause;
State.IntfUnits = UsesClauseReader.GetUnits(vIntfUsesClause);
State.ImplUnits = UsesClauseReader.GetUnits(vImplUsesClause);
IUnitItemBuilder vBuilder = CreateUnitItemBuilder();
fIntfOperation = CreateUsesOperation(Settings.IntfUnitsToManipulate, Settings.RequiredUnits, vBuilder);
fImplOperation = CreateUsesOperation(Settings.ImplUnitsToManipulate, Settings.RequiredUnits, vBuilder);
fIntfOperation.Initialize(State.IntfUnits);
fImplOperation.Initialize(State.ImplUnits);
}
public bool CanProcess()
{
return (fIntfOperation.CanProcess() || fImplOperation.CanProcess());
}
public string Execute()
{
string vContent = State.FileContent;
if (fIntfOperation.Execute())
vContent = ReplaceContent(vContent, State.OriginalIntfUsesClause, State.IntfUnits.ToString());
if (fImplOperation.Execute())
vContent = ReplaceContent(vContent, State.OriginalImplUsesClause, State.ImplUnits.ToString());
return vContent;
}
}
}
@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using DelphiProjectHandler.Operations.Uses;
namespace DelphiProjectHandler.Operations.Units
{
public class DelphiUnitAddOperation: AbstractDelphiUnitOperation
{
protected override IUsesListOperation CreateUsesOperation(ICollection<string> aUnitsToManipulate, ICollection<string> aRequiredUnits, IUnitItemBuilder aBuilder)
{
IUsesListOperationSettings vUsesSettings = new UsesListOperationSettings();
vUsesSettings.RequiredUnits = aRequiredUnits;
vUsesSettings.UnitItemBuilder = aBuilder;
vUsesSettings.UnitsToManipulate = aUnitsToManipulate;
return new UsesListAddOperation(vUsesSettings);
}
public DelphiUnitAddOperation(ICollection<string> aInterfaceUnits, ICollection<string> aImplementationUnits, ICollection<string> aRequiredUnits)
: base(aInterfaceUnits, aImplementationUnits, aRequiredUnits)
{
}
}
}
@@ -0,0 +1,101 @@
/*
* Created by SharpDevelop.
* User: SG0894652
* Date: 8/12/2009
* Time: 11:06 PM
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Collections.Generic;
using DelphiProjectHandler.Operations;
namespace DelphiProjectHandler.Operations.Units
{
/// <summary>
/// Description of DelphiUnitCleanerOperation.
/// </summary>
public class DelphiUnitCleanerOperation: DelphiOperation
{
public DelphiUnitCleanerOperation(): base()
{
}
protected SuggestedUnitStructure RemoveIgnoredUnits(SuggestedUnitStructure iSuggestedUnitStructure, IList<string> iIgnoredUnits)
{
List<string> vList = new List<string>(iIgnoredUnits);
for (int vUnitIdx = 0; vUnitIdx < vList.Count; vUnitIdx++)
vList[vUnitIdx] = vList[vUnitIdx].ToLower();
SuggestedUnitStructure vResult = iSuggestedUnitStructure.Clone();
RemoveUnits(vResult.MoveToInterface, vList);
RemoveUnits(vResult.ToDelete, vList);
return vResult;
}
protected void RemoveUnits(UnitList iList, IList<string> iToRemove)
{
for (int vUnitIdx = iList.Count - 1; vUnitIdx >= 0; vUnitIdx--)
if (iToRemove.IndexOf(iList[vUnitIdx].Name.ToLower()) >= 0)
iList.RemoveAt(vUnitIdx);
}
protected void AddUnits(UnitList iList, UnitList iToAdd)
{
for (int vUnitIdx = iToAdd.Count - 1; vUnitIdx >= 0; vUnitIdx--)
{
UnitItem vUnit = iToAdd[vUnitIdx];
if (iList.IndexOf(vUnit.Name) < 0)
iList.Insert(0, vUnit);
}
}
protected UnitList GetUsesList(string iUsesContent)
{
if (!iUsesContent.Trim().Equals(""))
return UsesClauseReader.GetUnits(iUsesContent);
else
return new UnitList();
}
protected string CleanUpInterface(string iUnitContent, string iUsesContent, SuggestedUnitStructure iSuggestedStructure)
{
if (iUsesContent.Trim().Equals(""))
return iUnitContent;
UnitList vUnits = GetUsesList(iUsesContent);
RemoveUnits(vUnits, iSuggestedStructure.ToDelete);
RemoveUnits(vUnits, iSuggestedStructure.MoveToInterface);
return ReplaceContent(iUnitContent, iUsesContent, vUnits.ToString());
}
protected string CleanUpImplementation(string iUnitContent, string iUsesContent, SuggestedUnitStructure iSuggestedStructure)
{
UnitList vUnits = GetUsesList(iUsesContent);
RemoveUnits(vUnits, iSuggestedStructure.ToDelete);
AddUnits(vUnits, iSuggestedStructure.MoveToInterface);
if (vUnits.Count == 0 && iUsesContent.Trim().Equals(""))
return iUnitContent;
string vNewValue = vUnits.ToString();
if (iUsesContent.Trim().Equals(""))
{
iUsesContent = "implementation";
vNewValue = "implementation\r\n\r\n" + vNewValue;
}
return ReplaceContent(iUnitContent, iUsesContent, vNewValue);
}
public string Execute(string iUnitContent, SuggestedUnitStructure iSuggestedStructure, IList<string> iIgnoredUnits)
{
string vInterface, vImplementation;
SuggestedUnitStructure vSuggestedStructure = RemoveIgnoredUnits(iSuggestedStructure.Clone(), iIgnoredUnits);
UsesClauseReader.ExtractUses(iUnitContent, out vInterface, out vImplementation);
string vResult = iUnitContent;
vResult = CleanUpInterface(vResult, vInterface, vSuggestedStructure);
vResult = CleanUpImplementation(vResult, vImplementation, vSuggestedStructure);
return vResult;
}
}
}
@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace DelphiProjectHandler.Operations.Units
{
public class DelphiUnitItemBuilder: IUnitItemBuilder
{
public UnitItem Create(string aUnitFileName)
{
UnitItem vResult = new UnitItem();
vResult.Name = Path.GetFileNameWithoutExtension(aUnitFileName);
return vResult;
}
}
}
@@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DelphiProjectHandler.Operations.Units
{
public class DelphiUnitOperationSettings: IDelphiUnitOperationSettings
{
private ICollection<string> fRequiredUnits;
public ICollection<string> RequiredUnits
{
get { return fRequiredUnits; }
set { fRequiredUnits = value; }
}
private ICollection<string> fIntfUnitsToManipulate;
public ICollection<string> IntfUnitsToManipulate
{
get { return fIntfUnitsToManipulate; }
set { fIntfUnitsToManipulate = value; }
}
private ICollection<string> fImplUnitsToManipulate;
public ICollection<string> ImplUnitsToManipulate
{
get { return fImplUnitsToManipulate; }
set { fImplUnitsToManipulate = value; }
}
}
}
@@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DelphiProjectHandler.Operations.Units
{
public class DelphiUnitOperationState: IDelphiUnitOperationState
{
private string fFileContent;
public string FileContent
{
get { return fFileContent; }
set { fFileContent = value; }
}
private string fOriginalIntfUsesClause;
public string OriginalIntfUsesClause
{
get { return fOriginalIntfUsesClause; }
set { fOriginalIntfUsesClause = value; }
}
private string fOriginalImplUsesClause;
public string OriginalImplUsesClause
{
get { return fOriginalImplUsesClause; }
set { fOriginalImplUsesClause = value; }
}
private UnitList fIntfUnits;
public UnitList IntfUnits
{
get { return fIntfUnits; }
set { fIntfUnits = value; }
}
private UnitList fImplUnits;
public UnitList ImplUnits
{
get { return fImplUnits; }
set { fImplUnits = value; }
}
}
}
@@ -0,0 +1,55 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DelphiProjectHandler.Operations;
namespace DelphiProjectHandler.Operations.Units
{
public abstract class DelphiUnitUsesOperation: DelphiOperation, IDelphiUnitOperation
{
protected virtual bool CanProcessUnit(UnitList aCurrentIntfUnits, UnitList aCurrentImplUnits, ICollection<string> aRequiredUnits)
{
return aCurrentIntfUnits.Concat<string>(aCurrentImplUnits).Intersect<string>(aRequiredUnits).Count() == aRequiredUnits.Count;
}
public string Execute(string aUnitContent, ICollection<string> aInterfaceUnits, ICollection<string> aImplementationUnits, ICollection<string> aRequiredUnits)
{
string vCurrentIntfUses = "";
string vCurrentImplUses = "";
UsesClauseReader.ExtractUses(aUnitContent, out vCurrentIntfUses, out vCurrentImplUses);
UnitList vCurrentIntfUnits = UsesClauseReader.GetUnits(vCurrentIntfUses);
UnitList vCurrentImplUnits = UsesClauseReader.GetUnits(vCurrentImplUses);
if (!CanProcessUnit(vCurrentIntfUnits, vCurrentImplUnits, aRequiredUnits))
return aUnitContent;
string vNewUnitContent = ProcessUsesSection(aUnitContent, vCurrentIntfUses, vCurrentIntfUnits, aInterfaceUnits, "interface");
return ProcessUsesSection(vNewUnitContent, vCurrentImplUses, vCurrentImplUnits, aImplementationUnits, "implementation");
}
protected string ProcessUsesSection(string aUnitContent, string aCurrentUsesClause, UnitList aCurrentUnitList, ICollection<string> aUnits, string aMissingUsesReplacement)
{
bool vListModified = ProcessUsesList(aCurrentUnitList, aUnits);
if (!vListModified)
return aUnitContent;
return BuildNewUsesClause(aUnitContent, aCurrentUsesClause, aCurrentUnitList, aMissingUsesReplacement);
}
protected string BuildNewUsesClause(string aUnitContent, string aCurrentUsesClause, UnitList aCurrentUnitList, string aMissingUsesReplacement)
{
string vLineStarting = "";
string vLineEnding = "";
if (aCurrentUsesClause == "")
{
aCurrentUsesClause = aMissingUsesReplacement + Environment.NewLine;
vLineStarting = aCurrentUsesClause + Environment.NewLine;
}
return ReplaceContent(aUnitContent, aCurrentUsesClause, vLineStarting + aCurrentUnitList.ToString() + vLineEnding);
}
protected abstract bool ProcessUsesList(UnitList aCurrentUnitList, ICollection<string> aUnits);
}
}
@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DelphiProjectHandler.Operations.Units
{
public interface IDelphiUnitOperation
{
string Execute(string aUnitContent, ICollection<string> aInterfaceUnits, ICollection<string> aImplementationUnits, ICollection<string> aRequiredUnits);
}
}
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DelphiProjectHandler.Operations.Units
{
public interface IDelphiUnitOperationSettings
{
ICollection<string> RequiredUnits { get; set; }
ICollection<string> IntfUnitsToManipulate { get; set; }
ICollection<string> ImplUnitsToManipulate { get; set; }
}
}
Loaded 100 of 133 files, more files were not shown because too many files have changed in this diff. Show more