Skip to content
Browse files

Added simple test module loaded by MEF.

  • Loading branch information...
1 parent bc0dcb2 commit c098b1e2aa2648e2c3e2dd43a3c829ff2e2552d4 @soend committed Feb 27, 2012
View
64 Glucodyn.ModuleManager/Glucodyn.ModuleManager.csproj
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.30703</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{2BA0D831-2226-4F0E-A487-C3C1CA46FCBF}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Glucodyn.ModuleManager</RootNamespace>
+ <AssemblyName>Glucodyn.ModuleManager</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </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.ComponentModel.Composition.CodePlex">
+ <HintPath>..\Glucodyn\Libs\System.ComponentModel.Composition.CodePlex.dll</HintPath>
+ </Reference>
+ <Reference Include="System.ComponentModel.Composition.Registration.CodePlex">
+ <HintPath>..\Glucodyn\Libs\System.ComponentModel.Composition.Registration.CodePlex.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Core" />
+ <Reference Include="System.Reflection.Context.CodePlex">
+ <HintPath>..\Glucodyn\Libs\System.Reflection.Context.CodePlex.dll</HintPath>
+ </Reference>
+ <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="IModule.cs" />
+ <Compile Include="ModuleManager.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </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>
View
13 Glucodyn.ModuleManager/IModule.cs
@@ -0,0 +1,13 @@
+using System;
+
+namespace Glucodyn.ModuleManager
+{
+ public interface IModule
+ {
+ Guid Id { get; }
+ string Name { get; }
+ string Version { get; }
+
+ void Initialize();
+ }
+}
View
36 Glucodyn.ModuleManager/ModuleManager.cs
@@ -0,0 +1,36 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel.Composition;
+using System.ComponentModel.Composition.Hosting;
+using System.Linq;
+using System.Reflection;
+using System.Text;
+
+namespace Glucodyn.ModuleManager
+{
+ public class ModuleManager
+ {
+ [ImportMany(typeof(IModule))]
+ private Lazy<IModule, IDictionary<string, object>>[] Modules { get; set; }
+
+
+ public IModule FindModule(string cmd)
+ {
+ LoadModules();
+
+ return (from codeVault in Modules
+ where (string)codeVault.Metadata["Command"] == cmd
+ select codeVault).Single().Value;
+ }
+
+ private void LoadModules()
+ {
+ var catalog = new AggregateCatalog();
+ catalog.Catalogs.Add(new DirectoryCatalog(@"C:\Users\soojendi\Documents\Visual Studio 2010\Projects\Glucodyn\Modules\TestModule\bin\Debug", "*.dll"));
+ var container = new CompositionContainer(catalog);
+ container.ComposeParts(this);
+ }
+ }
+
+}
View
36 Glucodyn.ModuleManager/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("Glucodyn.ModuleManager")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Glucodyn.ModuleManager")]
+[assembly: AssemblyCopyright("Copyright © 2012")]
+[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("71208057-afa7-4901-b0de-67aa162232b9")]
+
+// 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")]
View
29 Glucodyn.sln
@@ -10,6 +10,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
README = README
EndProjectSection
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Glucodyn.ModuleManager", "Glucodyn.ModuleManager\Glucodyn.ModuleManager.csproj", "{2BA0D831-2226-4F0E-A487-C3C1CA46FCBF}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Modules", "Modules", "{59F91E71-154F-4233-AF97-D09C4C9D2749}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestModule", "Modules\TestModule\TestModule.csproj", "{C8510856-B975-44F5-808D-0FB918DF7E36}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -40,8 +46,31 @@ Global
{191E864E-0C9D-446C-89A6-CA6B569FB4F9}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{191E864E-0C9D-446C-89A6-CA6B569FB4F9}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{191E864E-0C9D-446C-89A6-CA6B569FB4F9}.Release|x86.ActiveCfg = Release|Any CPU
+ {2BA0D831-2226-4F0E-A487-C3C1CA46FCBF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {2BA0D831-2226-4F0E-A487-C3C1CA46FCBF}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {2BA0D831-2226-4F0E-A487-C3C1CA46FCBF}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {2BA0D831-2226-4F0E-A487-C3C1CA46FCBF}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {2BA0D831-2226-4F0E-A487-C3C1CA46FCBF}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {2BA0D831-2226-4F0E-A487-C3C1CA46FCBF}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {2BA0D831-2226-4F0E-A487-C3C1CA46FCBF}.Release|Any CPU.Build.0 = Release|Any CPU
+ {2BA0D831-2226-4F0E-A487-C3C1CA46FCBF}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {2BA0D831-2226-4F0E-A487-C3C1CA46FCBF}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {2BA0D831-2226-4F0E-A487-C3C1CA46FCBF}.Release|x86.ActiveCfg = Release|Any CPU
+ {C8510856-B975-44F5-808D-0FB918DF7E36}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {C8510856-B975-44F5-808D-0FB918DF7E36}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {C8510856-B975-44F5-808D-0FB918DF7E36}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {C8510856-B975-44F5-808D-0FB918DF7E36}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {C8510856-B975-44F5-808D-0FB918DF7E36}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {C8510856-B975-44F5-808D-0FB918DF7E36}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {C8510856-B975-44F5-808D-0FB918DF7E36}.Release|Any CPU.Build.0 = Release|Any CPU
+ {C8510856-B975-44F5-808D-0FB918DF7E36}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {C8510856-B975-44F5-808D-0FB918DF7E36}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {C8510856-B975-44F5-808D-0FB918DF7E36}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
+ GlobalSection(NestedProjects) = preSolution
+ {C8510856-B975-44F5-808D-0FB918DF7E36} = {59F91E71-154F-4233-AF97-D09C4C9D2749}
+ EndGlobalSection
EndGlobal
View
4 Glucodyn/Glucodyn.csproj
@@ -69,6 +69,10 @@
<Project>{191E864E-0C9D-446C-89A6-CA6B569FB4F9}</Project>
<Name>Glucodyn.Config</Name>
</ProjectReference>
+ <ProjectReference Include="..\Glucodyn.ModuleManager\Glucodyn.ModuleManager.csproj">
+ <Project>{2BA0D831-2226-4F0E-A487-C3C1CA46FCBF}</Project>
+ <Name>Glucodyn.ModuleManager</Name>
+ </ProjectReference>
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
View
BIN Glucodyn/Libs/System.ComponentModel.Composition.CodePlex.dll
Binary file not shown.
View
BIN Glucodyn/Libs/System.ComponentModel.Composition.Registration.CodePlex.dll
Binary file not shown.
View
BIN Glucodyn/Libs/System.Reflection.Context.CodePlex.dll
Binary file not shown.
View
5 Glucodyn/Program.cs
@@ -1,6 +1,4 @@
using System;
-using System.Threading;
-using Meebey.SmartIrc4net;
using Glucodyn.Config;
namespace Glucodyn
@@ -10,6 +8,9 @@ class Program
static void Main()
{
var identities = new GlucodynConfig();
+ ModuleManager.ModuleManager mM = new ModuleManager.ModuleManager();
+ var foo = mM.FindModule("TestModule");
+ Console.WriteLine(foo.Name);
foreach (var ident in identities.Config.identities)
{
View
36 Modules/TestModule/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("TestModule")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("TestModule")]
+[assembly: AssemblyCopyright("Copyright © 2012")]
+[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("59e607f5-07d3-4e82-8fa2-9d8a68a25dea")]
+
+// 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")]
View
23 Modules/TestModule/TestModule.cs
@@ -0,0 +1,23 @@
+using System;
+using System.ComponentModel.Composition;
+using System.Reflection;
+using Glucodyn.ModuleManager;
+
+namespace TestModule
+{
+ [Export(typeof(IModule))]
+ [ExportMetadata("Command", "TestModule")]
+ class TestModule : IModule
+ {
+ public Guid Id { get { return Guid.NewGuid(); } }
+
+ public string Name { get { return "Test module"; } }
+
+ public string Version { get { return Assembly.GetExecutingAssembly().GetName().Version.ToString(); } }
+
+ public void Initialize()
+ {
+ Console.WriteLine("TestModule is starting up ...");
+ }
+ }
+}
View
73 Modules/TestModule/TestModule.csproj
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.30703</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{C8510856-B975-44F5-808D-0FB918DF7E36}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>TestModule</RootNamespace>
+ <AssemblyName>TestModule</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </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.ComponentModel.Composition.CodePlex">
+ <HintPath>..\Glucodyn\Libs\System.ComponentModel.Composition.CodePlex.dll</HintPath>
+ </Reference>
+ <Reference Include="System.ComponentModel.Composition.Registration.CodePlex">
+ <HintPath>..\Glucodyn\Libs\System.ComponentModel.Composition.Registration.CodePlex.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Core" />
+ <Reference Include="System.Reflection.Context.CodePlex">
+ <HintPath>..\Glucodyn\Libs\System.Reflection.Context.CodePlex.dll</HintPath>
+ </Reference>
+ <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="Properties\AssemblyInfo.cs" />
+ <Compile Include="TestModule.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\..\Glucodyn.ModuleManager\Glucodyn.ModuleManager.csproj">
+ <Project>{2BA0D831-2226-4F0E-A487-C3C1CA46FCBF}</Project>
+ <Name>Glucodyn.ModuleManager</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <PropertyGroup>
+ <PostBuildEvent>
+ </PostBuildEvent>
+ </PropertyGroup>
+ <!-- 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>
View
1 README
@@ -29,5 +29,4 @@ How to write modules: throw new NotImplementedException();
ToDO: * Create module system
* Exception handling
- * Logging - each identity should have seperate log file

0 comments on commit c098b1e

Please sign in to comment.
Something went wrong with that request. Please try again.