From abb3754bad9ddc796daa069f1293dd5b1458208f Mon Sep 17 00:00:00 2001 From: Niko Ehrenfeuchter <nikolaus.ehrenfeuchter@unibas.ch> Date: Tue, 9 Jan 2018 15:18:40 +0100 Subject: [PATCH] Add command line validation tool for config and status files. Fixes #22 --- ATXConfigTest/ATXConfigTest.csproj | 64 ++++++++++++++++++++++++ ATXConfigTest/App.config | 6 +++ ATXConfigTest/AutoTxConfigTest.cs | 43 ++++++++++++++++ ATXConfigTest/Properties/AssemblyInfo.cs | 36 +++++++++++++ ATXService.sln | 6 +++ 5 files changed, 155 insertions(+) create mode 100644 ATXConfigTest/ATXConfigTest.csproj create mode 100644 ATXConfigTest/App.config create mode 100644 ATXConfigTest/AutoTxConfigTest.cs create mode 100644 ATXConfigTest/Properties/AssemblyInfo.cs diff --git a/ATXConfigTest/ATXConfigTest.csproj b/ATXConfigTest/ATXConfigTest.csproj new file mode 100644 index 0000000..df442c4 --- /dev/null +++ b/ATXConfigTest/ATXConfigTest.csproj @@ -0,0 +1,64 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProjectGuid>{81E0A5AC-0E0D-4F98-B399-41A58612EF33}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>ATXConfigTest</RootNamespace> + <AssemblyName>AutoTxConfigTest</AssemblyName> + <TargetFrameworkVersion>v4.5</TargetFrameworkVersion> + <FileAlignment>512</FileAlignment> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <PlatformTarget>AnyCPU</PlatformTarget> + <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' "> + <PlatformTarget>AnyCPU</PlatformTarget> + <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" /> + <Reference Include="System.Xml.Linq" /> + <Reference Include="System.Data.DataSetExtensions" /> + <Reference Include="Microsoft.CSharp" /> + <Reference Include="System.Data" /> + <Reference Include="System.Xml" /> + </ItemGroup> + <ItemGroup> + <Compile Include="AutoTxConfigTest.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="App.config" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\ATXSerializables\ATXSerializables.csproj"> + <Project>{166D65D5-EE10-4364-8AA3-4D86BA5CE244}</Project> + <Name>ATXSerializables</Name> + </ProjectReference> + </ItemGroup> + <Import Project="$(MSBuildToolsPath)\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> \ No newline at end of file diff --git a/ATXConfigTest/App.config b/ATXConfigTest/App.config new file mode 100644 index 0000000..8e15646 --- /dev/null +++ b/ATXConfigTest/App.config @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8" ?> +<configuration> + <startup> + <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> + </startup> +</configuration> \ No newline at end of file diff --git a/ATXConfigTest/AutoTxConfigTest.cs b/ATXConfigTest/AutoTxConfigTest.cs new file mode 100644 index 0000000..a649bc0 --- /dev/null +++ b/ATXConfigTest/AutoTxConfigTest.cs @@ -0,0 +1,43 @@ +using System; +using System.IO; +using ATXSerializables; + +namespace ATXConfigTest +{ + internal class AutoTxConfigTest + { + + private static ServiceConfig _config; + private static ServiceStatus _status; + + private static void Main(string[] args) { + var baseDir = AppDomain.CurrentDomain.BaseDirectory; + + try { + baseDir = args[0]; + } + catch { + // ignored (use default value from above) + } + + var configPath = Path.Combine(baseDir, "configuration.xml"); + var statusPath = Path.Combine(baseDir, "status.xml"); + + try { + string msg; + Console.WriteLine("\nTrying to parse configuration file [{0}]...\n", configPath); + _config = ServiceConfig.Deserialize(configPath); + msg = "------------------ configuration settings ------------------"; + Console.WriteLine("{0}\n{1}{0}\n", msg, _config.Summary()); + + Console.WriteLine("\nTrying to parse status file [{0}]...\n", statusPath); + _status = ServiceStatus.Deserialize(statusPath, _config); + msg = "------------------ status parameters ------------------"; + Console.WriteLine("{0}\n{1}{0}\n", msg, _status.Summary()); + } + catch (Exception ex) { + Console.WriteLine(ex); + } + } + } +} diff --git a/ATXConfigTest/Properties/AssemblyInfo.cs b/ATXConfigTest/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..098148d --- /dev/null +++ b/ATXConfigTest/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +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("ATXConfigTest")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Universitaet Basel")] +[assembly: AssemblyProduct("ATXConfigTest")] +[assembly: AssemblyCopyright("Copyright © Universitaet Basel 2018")] +[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("1efe21ab-b31e-43ef-95c3-72b9addfabb4")] + +// 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 Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/ATXService.sln b/ATXService.sln index 0c405b0..59edaea 100644 --- a/ATXService.sln +++ b/ATXService.sln @@ -7,6 +7,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ATXProject", "AutoTx\ATXPro EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ATXSerializables", "ATXSerializables\ATXSerializables.csproj", "{166D65D5-EE10-4364-8AA3-4D86BA5CE244}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ATXConfigTest", "ATXConfigTest\ATXConfigTest.csproj", "{81E0A5AC-0E0D-4F98-B399-41A58612EF33}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -21,6 +23,10 @@ Global {166D65D5-EE10-4364-8AA3-4D86BA5CE244}.Debug|Any CPU.Build.0 = Debug|Any CPU {166D65D5-EE10-4364-8AA3-4D86BA5CE244}.Release|Any CPU.ActiveCfg = Release|Any CPU {166D65D5-EE10-4364-8AA3-4D86BA5CE244}.Release|Any CPU.Build.0 = Release|Any CPU + {81E0A5AC-0E0D-4F98-B399-41A58612EF33}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {81E0A5AC-0E0D-4F98-B399-41A58612EF33}.Debug|Any CPU.Build.0 = Debug|Any CPU + {81E0A5AC-0E0D-4F98-B399-41A58612EF33}.Release|Any CPU.ActiveCfg = Release|Any CPU + {81E0A5AC-0E0D-4F98-B399-41A58612EF33}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE -- GitLab