From: <br...@us...> - 2008-10-31 21:47:45
|
Revision: 425 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=425&view=rev Author: brus07 Date: 2008-10-31 21:47:35 +0000 (Fri, 31 Oct 2008) Log Message: ----------- Added Configuration class. Get address to plugins from initialization files (INI). Modified Paths: -------------- ACMServer/trunk/ACMServer/Library/LibraryExtention/LibraryExtention.csproj ACMServer/trunk/ACMServer/Mediator/Form1.cs ACMServer/trunk/ACMServer/Mediator/Mediator.csproj ACMServer/trunk/ACMServer/Mediator/Program.cs Added Paths: ----------- ACMServer/trunk/ACMServer/Library/LibraryExtention/Configuration.cs ACMServer/trunk/ACMServer/Mediator/Config.ini ACMServer/trunk/ACMServer/Mediator/TesterConfig.ini Added: ACMServer/trunk/ACMServer/Library/LibraryExtention/Configuration.cs =================================================================== --- ACMServer/trunk/ACMServer/Library/LibraryExtention/Configuration.cs (rev 0) +++ ACMServer/trunk/ACMServer/Library/LibraryExtention/Configuration.cs 2008-10-31 21:47:35 UTC (rev 425) @@ -0,0 +1,58 @@ +using System; + +namespace AcmContester.Library.LibraryExtention +{ + public static class Configuration + { + public static string ExecutablePath; + + static readonly string defaultConfigFileName = "config.ini"; + static public string DefaultConfigFileName + { + get + { + return defaultConfigFileName; + } + } + + static string concreteConfigFileName; + + public static string ConcreteConfigFileName + { + get + { + return concreteConfigFileName; + } + set + { + concreteConfigFileName = value; + } + } + + public static string PluginLeftDirectory; + public static string PluginRightDirectory; + + private static string LoadStringFromDifferentFile(string sectionName, string keyName) + { + string defaultString = "#$%^$343@#$"; + string result = defaultString; + if (concreteConfigFileName != null) + { + IniFile ini = new IniFile(ConcreteConfigFileName); + result = ini.GetString(sectionName, keyName, defaultString); + } + if (result == defaultString) + { + IniFile ini = new IniFile(DefaultConfigFileName); + result = ini.GetString(sectionName, keyName, ""); + } + return result; + } + + public static void Load() + { + PluginLeftDirectory = LoadStringFromDifferentFile("Plugin", "LeftDirectory"); + PluginRightDirectory = LoadStringFromDifferentFile("Plugin", "RightDirectory"); + } + } +} Modified: ACMServer/trunk/ACMServer/Library/LibraryExtention/LibraryExtention.csproj =================================================================== --- ACMServer/trunk/ACMServer/Library/LibraryExtention/LibraryExtention.csproj 2008-10-31 21:44:07 UTC (rev 424) +++ ACMServer/trunk/ACMServer/Library/LibraryExtention/LibraryExtention.csproj 2008-10-31 21:47:35 UTC (rev 425) @@ -33,6 +33,7 @@ <Reference Include="System.Xml" /> </ItemGroup> <ItemGroup> + <Compile Include="Configuration.cs" /> <Compile Include="IniFile.cs" /> <Compile Include="Log.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> @@ -50,4 +51,4 @@ <Target Name="AfterBuild"> </Target> --> -</Project> \ No newline at end of file +</Project> Added: ACMServer/trunk/ACMServer/Mediator/Config.ini =================================================================== --- ACMServer/trunk/ACMServer/Mediator/Config.ini (rev 0) +++ ACMServer/trunk/ACMServer/Mediator/Config.ini 2008-10-31 21:47:35 UTC (rev 425) @@ -0,0 +1,3 @@ +[Plugin] +LeftDirectory=Dll_Web +RightDirectory=Dll_Tester \ No newline at end of file Modified: ACMServer/trunk/ACMServer/Mediator/Form1.cs =================================================================== --- ACMServer/trunk/ACMServer/Mediator/Form1.cs 2008-10-31 21:44:07 UTC (rev 424) +++ ACMServer/trunk/ACMServer/Mediator/Form1.cs 2008-10-31 21:47:35 UTC (rev 425) @@ -11,6 +11,8 @@ using AcmContester.Library.LibraryExtention; using AcmContester.Plugins.PluginsFramework; + + namespace Mediator { public partial class Form1 : Form @@ -27,7 +29,10 @@ private void button2_Click(object sender, EventArgs e) { - kernel = new MediatorKernelGUI("Dll_Tester", "Dll_Web"); + kernel = new MediatorKernelGUI(Configuration.PluginRightDirectory, + Configuration.PluginLeftDirectory); + //kernel = new MediatorKernelGUI("Dll_Tester", "Dll_Web"); + //kernel = new MediatorKernelGUI("Dll_Runner", "Dll_Client"); kernel.Dock = DockStyle.Fill; this.panel1.Controls.Add(kernel); } Modified: ACMServer/trunk/ACMServer/Mediator/Mediator.csproj =================================================================== --- ACMServer/trunk/ACMServer/Mediator/Mediator.csproj 2008-10-31 21:44:07 UTC (rev 424) +++ ACMServer/trunk/ACMServer/Mediator/Mediator.csproj 2008-10-31 21:47:35 UTC (rev 425) @@ -58,6 +58,12 @@ <DependentUpon>Resources.resx</DependentUpon> <DesignTime>True</DesignTime> </Compile> + <None Include="Config.ini"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </None> + <None Include="TesterConfig.ini"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </None> <None Include="Properties\Settings.settings"> <Generator>SettingsSingleFileGenerator</Generator> <LastGenOutput>Settings.Designer.cs</LastGenOutput> @@ -93,4 +99,4 @@ <Target Name="AfterBuild"> </Target> --> -</Project> \ No newline at end of file +</Project> Modified: ACMServer/trunk/ACMServer/Mediator/Program.cs =================================================================== --- ACMServer/trunk/ACMServer/Mediator/Program.cs 2008-10-31 21:44:07 UTC (rev 424) +++ ACMServer/trunk/ACMServer/Mediator/Program.cs 2008-10-31 21:47:35 UTC (rev 425) @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Windows.Forms; +using System.IO; namespace Mediator { @@ -10,8 +11,16 @@ /// The main entry point for the application. /// </summary> [STAThread] - static void Main() + static void Main(string[] args) { + string path = Application.ExecutablePath; + path = System.IO.Path.GetDirectoryName(path); + AcmContester.Library.LibraryExtention.Configuration.ExecutablePath = path; + if (args.Length == 1) + { + AcmContester.Library.LibraryExtention.Configuration.ConcreteConfigFileName = args[0]; + } + AcmContester.Library.LibraryExtention.Configuration.Load(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); Added: ACMServer/trunk/ACMServer/Mediator/TesterConfig.ini =================================================================== --- ACMServer/trunk/ACMServer/Mediator/TesterConfig.ini (rev 0) +++ ACMServer/trunk/ACMServer/Mediator/TesterConfig.ini 2008-10-31 21:47:35 UTC (rev 425) @@ -0,0 +1,3 @@ +[Plugin] +LeftDirectory=Dll_Web1 +RightDirectory=Dll_Tester1 \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |