From: <br...@us...> - 2008-06-11 09:15:41
|
Revision: 244 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=244&view=rev Author: brus07 Date: 2008-06-11 02:15:49 -0700 (Wed, 11 Jun 2008) Log Message: ----------- Added new plugin project. Load plugin from folder Dll, and file extension *.dllx Modified Paths: -------------- ACMServer/trunk/ACMServer/ACMMediator.sln ACMServer/trunk/ACMServer/Plugin/MediatorPlugins/Plugin1/Class1.cs ACMServer/trunk/ACMServer/Plugin/MediatorPlugins/Plugin1/Plugin1.csproj ACMServer/trunk/ACMServer/Plugin/PluginsFramework/PluginLoader.cs ACMServer/trunk/ACMServer/Plugin/testRun/Program.cs Added Paths: ----------- ACMServer/trunk/ACMServer/Plugin/MediatorPlugins/Plugin1/Class2.cs ACMServer/trunk/ACMServer/Plugin/MediatorPlugins/WebGatePlugin/ ACMServer/trunk/ACMServer/Plugin/MediatorPlugins/WebGatePlugin/Properties/ ACMServer/trunk/ACMServer/Plugin/MediatorPlugins/WebGatePlugin/Properties/AssemblyInfo.cs ACMServer/trunk/ACMServer/Plugin/MediatorPlugins/WebGatePlugin/WebGatePlugin.cs ACMServer/trunk/ACMServer/Plugin/MediatorPlugins/WebGatePlugin/WebGatePlugin.csproj ACMServer/trunk/ACMServer/Plugin/PluginsFramework/BaseMediatorPlugin.cs Removed Paths: ------------- ACMServer/trunk/ACMServer/Plugin/PluginsFramework/BaseMediatorPlugin.cs Modified: ACMServer/trunk/ACMServer/ACMMediator.sln =================================================================== --- ACMServer/trunk/ACMServer/ACMMediator.sln 2008-06-11 07:03:37 UTC (rev 243) +++ ACMServer/trunk/ACMServer/ACMMediator.sln 2008-06-11 09:15:49 UTC (rev 244) @@ -19,6 +19,8 @@ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "testRun", "Plugin\testRun\testRun.csproj", "{A855D392-4817-4408-80CE-61D8C8E77322}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebGatePlugin", "Plugin\MediatorPlugins\WebGatePlugin\WebGatePlugin.csproj", "{20B192BC-FD4D-4ED5-90F5-B5994F995238}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -49,6 +51,10 @@ {A855D392-4817-4408-80CE-61D8C8E77322}.Debug|Any CPU.Build.0 = Debug|Any CPU {A855D392-4817-4408-80CE-61D8C8E77322}.Release|Any CPU.ActiveCfg = Release|Any CPU {A855D392-4817-4408-80CE-61D8C8E77322}.Release|Any CPU.Build.0 = Release|Any CPU + {20B192BC-FD4D-4ED5-90F5-B5994F995238}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {20B192BC-FD4D-4ED5-90F5-B5994F995238}.Debug|Any CPU.Build.0 = Debug|Any CPU + {20B192BC-FD4D-4ED5-90F5-B5994F995238}.Release|Any CPU.ActiveCfg = Release|Any CPU + {20B192BC-FD4D-4ED5-90F5-B5994F995238}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -60,5 +66,6 @@ {E4F4B91E-CC25-410B-B53A-E2507EFA4FCB} = {D80861F5-3751-4D49-884B-1A10FE1BCB07} {A855D392-4817-4408-80CE-61D8C8E77322} = {D80861F5-3751-4D49-884B-1A10FE1BCB07} {B75187D7-2032-44F3-AC12-20804C7229AC} = {E4F4B91E-CC25-410B-B53A-E2507EFA4FCB} + {20B192BC-FD4D-4ED5-90F5-B5994F995238} = {E4F4B91E-CC25-410B-B53A-E2507EFA4FCB} EndGlobalSection EndGlobal Modified: ACMServer/trunk/ACMServer/Plugin/MediatorPlugins/Plugin1/Class1.cs =================================================================== --- ACMServer/trunk/ACMServer/Plugin/MediatorPlugins/Plugin1/Class1.cs 2008-06-11 07:03:37 UTC (rev 243) +++ ACMServer/trunk/ACMServer/Plugin/MediatorPlugins/Plugin1/Class1.cs 2008-06-11 09:15:49 UTC (rev 244) @@ -7,7 +7,9 @@ { public override void Send(string message) { - throw new Exception("The method or operation is not implemented."); + Console.WriteLine("Plugin1::Class1::Send(" + message + ");"); + Console.WriteLine("The method or operation is not implemented."); + //throw new Exception("The method or operation is not implemented."); } } } Added: ACMServer/trunk/ACMServer/Plugin/MediatorPlugins/Plugin1/Class2.cs =================================================================== --- ACMServer/trunk/ACMServer/Plugin/MediatorPlugins/Plugin1/Class2.cs (rev 0) +++ ACMServer/trunk/ACMServer/Plugin/MediatorPlugins/Plugin1/Class2.cs 2008-06-11 09:15:49 UTC (rev 244) @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Plugin1 +{ + public class Class2 + { + public void Send(string message) + { + Console.WriteLine("Plugin1::Class2::Send(" + message + ");"); + Console.WriteLine("The method or operation is not implemented."); + //throw new Exception("The method or operation is not implemented."); + } + } +} Modified: ACMServer/trunk/ACMServer/Plugin/MediatorPlugins/Plugin1/Plugin1.csproj =================================================================== --- ACMServer/trunk/ACMServer/Plugin/MediatorPlugins/Plugin1/Plugin1.csproj 2008-06-11 07:03:37 UTC (rev 243) +++ ACMServer/trunk/ACMServer/Plugin/MediatorPlugins/Plugin1/Plugin1.csproj 2008-06-11 09:15:49 UTC (rev 244) @@ -32,6 +32,7 @@ </ItemGroup> <ItemGroup> <Compile Include="Class1.cs" /> + <Compile Include="Class2.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> </ItemGroup> <ItemGroup> Property changes on: ACMServer/trunk/ACMServer/Plugin/MediatorPlugins/WebGatePlugin ___________________________________________________________________ Name: svn:ignore + bin obj WebGatePlugin.csproj.user Added: ACMServer/trunk/ACMServer/Plugin/MediatorPlugins/WebGatePlugin/Properties/AssemblyInfo.cs =================================================================== --- ACMServer/trunk/ACMServer/Plugin/MediatorPlugins/WebGatePlugin/Properties/AssemblyInfo.cs (rev 0) +++ ACMServer/trunk/ACMServer/Plugin/MediatorPlugins/WebGatePlugin/Properties/AssemblyInfo.cs 2008-06-11 09:15:49 UTC (rev 244) @@ -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("WebGatePlugin")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Home")] +[assembly: AssemblyProduct("WebGatePlugin")] +[assembly: AssemblyCopyright("Copyright © Home 2008")] +[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("4c84bd0e-8704-4e0e-94b4-d35256692a05")] + +// 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")] Copied: ACMServer/trunk/ACMServer/Plugin/MediatorPlugins/WebGatePlugin/WebGatePlugin.cs (from rev 238, ACMServer/trunk/ACMServer/Mediator/Library/Plugins/WebGate/WebGatePlugin.cs) =================================================================== --- ACMServer/trunk/ACMServer/Plugin/MediatorPlugins/WebGatePlugin/WebGatePlugin.cs (rev 0) +++ ACMServer/trunk/ACMServer/Plugin/MediatorPlugins/WebGatePlugin/WebGatePlugin.cs 2008-06-11 09:15:49 UTC (rev 244) @@ -0,0 +1,33 @@ +using System; +using AcmContester.Plugins.PluginsFramework; +using AcmContester.Library.Connector; + +namespace AcmContester.Plugins.MediatorPlugins.WebGatePlugin +{ + /// <summary> + /// Pattern: Singleton + /// </summary> + public class WebGatePlugin: BaseMediatorPlugin + { + //private static WebGatePlugin instance = new WebGatePlugin(); + + private WebConnector connector = new WebConnector(); + + public WebGatePlugin() + { + connector.onDataArrived += DataArrived; + } + + public static WebGatePlugin GetInstance() + { + return null; + //return instance; + } + + public override void Send(string message) + { + WorkingData("WebGatePlugin::Send(" + message + ")"); + connector.Send(message); + } + } +} Added: ACMServer/trunk/ACMServer/Plugin/MediatorPlugins/WebGatePlugin/WebGatePlugin.csproj =================================================================== --- ACMServer/trunk/ACMServer/Plugin/MediatorPlugins/WebGatePlugin/WebGatePlugin.csproj (rev 0) +++ ACMServer/trunk/ACMServer/Plugin/MediatorPlugins/WebGatePlugin/WebGatePlugin.csproj 2008-06-11 09:15:49 UTC (rev 244) @@ -0,0 +1,55 @@ +<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProductVersion>8.0.50727</ProductVersion> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{20B192BC-FD4D-4ED5-90F5-B5994F995238}</ProjectGuid> + <OutputType>Library</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>WebGatePlugin</RootNamespace> + <AssemblyName>WebGatePlugin</AssemblyName> + </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" /> + </ItemGroup> + <ItemGroup> + <Compile Include="Properties\AssemblyInfo.cs" /> + <Compile Include="WebGatePlugin.cs" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\..\..\Library\Connector\Connector.csproj"> + <Project>{211DD6A5-2D73-439E-8722-ED2C89ED1DDB}</Project> + <Name>Connector</Name> + </ProjectReference> + <ProjectReference Include="..\..\PluginsFramework\PluginsFramework.csproj"> + <Project>{69FB4176-F298-4AF7-B714-B6758AA9A58E}</Project> + <Name>PluginsFramework</Name> + </ProjectReference> + </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> \ No newline at end of file Deleted: ACMServer/trunk/ACMServer/Plugin/PluginsFramework/BaseMediatorPlugin.cs =================================================================== --- ACMServer/trunk/ACMServer/Plugin/PluginsFramework/BaseMediatorPlugin.cs 2008-06-11 07:03:37 UTC (rev 243) +++ ACMServer/trunk/ACMServer/Plugin/PluginsFramework/BaseMediatorPlugin.cs 2008-06-11 09:15:49 UTC (rev 244) @@ -1,9 +0,0 @@ -using System; - -namespace AcmContester.Plugins.PluginsFramework -{ - public abstract class BaseMediatorPlugin - { - public abstract void Send(string message); - } -} Copied: ACMServer/trunk/ACMServer/Plugin/PluginsFramework/BaseMediatorPlugin.cs (from rev 238, ACMServer/trunk/ACMServer/Mediator/Library/Plugins/BaseMediatorPlugin.cs) =================================================================== --- ACMServer/trunk/ACMServer/Plugin/PluginsFramework/BaseMediatorPlugin.cs (rev 0) +++ ACMServer/trunk/ACMServer/Plugin/PluginsFramework/BaseMediatorPlugin.cs 2008-06-11 09:15:49 UTC (rev 244) @@ -0,0 +1,28 @@ +using System; + +namespace AcmContester.Plugins.PluginsFramework +{ + public abstract class BaseMediatorPlugin + { + public delegate void DataArrived_EventHandler(string message); + public event DataArrived_EventHandler onDataArrived; + + public delegate void WorkingData_EventHandler(string message); + public event WorkingData_EventHandler onWorkingData; + + public abstract void Send(string message); + + protected virtual void DataArrived(string message) + { + WorkingData("BaseMediatorPlugin::DataArrived(" + message + ")"); + if (onDataArrived != null) + onDataArrived(message); + } + + protected virtual void WorkingData(string message) + { + if (onWorkingData != null) + onWorkingData(message); + } + } +} Modified: ACMServer/trunk/ACMServer/Plugin/PluginsFramework/PluginLoader.cs =================================================================== --- ACMServer/trunk/ACMServer/Plugin/PluginsFramework/PluginLoader.cs 2008-06-11 07:03:37 UTC (rev 243) +++ ACMServer/trunk/ACMServer/Plugin/PluginsFramework/PluginLoader.cs 2008-06-11 09:15:49 UTC (rev 244) @@ -18,7 +18,7 @@ List<T> plugins = new List<T>(); if (!Directory.Exists(path)) throw new ArgumentException("Specified path does not exists!"); - string[] allFiles = Directory.GetFiles(path, "*.dll", SearchOption.TopDirectoryOnly); + string[] allFiles = Directory.GetFiles(path, "*.dllx", SearchOption.TopDirectoryOnly); foreach (string file in allFiles) { ScanAndLoad(file, plugins); @@ -43,16 +43,25 @@ { try { - if (t.IsClass && !t.IsAbstract && (t.GetInterface(typeof(T).FullName) != null || t.GetMember(typeof(T).FullName) != null)) - lst.Add((T)Activator.CreateInstance(t)); + if (t.IsClass && !t.IsAbstract) + if (t.GetInterface(typeof(T).FullName) != null || t.GetMember(typeof(T).FullName) != null) + lst.Add((T)Activator.CreateInstance(t)); } catch (System.Reflection.TargetInvocationException ex) { - throw ex; + //throw ex; } + catch (System.MissingMethodException ex) + { + //throw ex; + } + catch (System.InvalidCastException ex) + { + //throw ex; + } catch (Exception ex) { - throw ex; + //throw ex; } } } Modified: ACMServer/trunk/ACMServer/Plugin/testRun/Program.cs =================================================================== --- ACMServer/trunk/ACMServer/Plugin/testRun/Program.cs 2008-06-11 07:03:37 UTC (rev 243) +++ ACMServer/trunk/ACMServer/Plugin/testRun/Program.cs 2008-06-11 09:15:49 UTC (rev 244) @@ -2,12 +2,18 @@ using AcmContester.Plugins.PluginsFramework; using System.Collections.Generic; +using System.Security; +using System.Reflection; + + namespace testRun { + class Program { static void Main(string[] args) { + //BaseMediatorPlugin wgp = new AcmContester.Plugins.MediatorPlugins.WebGatePlugin.WebGatePlugin(); List<BaseMediatorPlugin> plugins = PluginsLoader<BaseMediatorPlugin>.Load("Dll"); foreach (BaseMediatorPlugin cp in plugins) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |