Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added simple test module loaded by MEF.

  • Loading branch information...
commit c098b1e2aa2648e2c3e2dd43a3c829ff2e2552d4 1 parent bc0dcb2
soend authored
64 Glucodyn.ModuleManager/Glucodyn.ModuleManager.csproj
... ... @@ -0,0 +1,64 @@
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  3 + <PropertyGroup>
  4 + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
  5 + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
  6 + <ProductVersion>8.0.30703</ProductVersion>
  7 + <SchemaVersion>2.0</SchemaVersion>
  8 + <ProjectGuid>{2BA0D831-2226-4F0E-A487-C3C1CA46FCBF}</ProjectGuid>
  9 + <OutputType>Library</OutputType>
  10 + <AppDesignerFolder>Properties</AppDesignerFolder>
  11 + <RootNamespace>Glucodyn.ModuleManager</RootNamespace>
  12 + <AssemblyName>Glucodyn.ModuleManager</AssemblyName>
  13 + <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
  14 + <FileAlignment>512</FileAlignment>
  15 + </PropertyGroup>
  16 + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
  17 + <DebugSymbols>true</DebugSymbols>
  18 + <DebugType>full</DebugType>
  19 + <Optimize>false</Optimize>
  20 + <OutputPath>bin\Debug\</OutputPath>
  21 + <DefineConstants>DEBUG;TRACE</DefineConstants>
  22 + <ErrorReport>prompt</ErrorReport>
  23 + <WarningLevel>4</WarningLevel>
  24 + </PropertyGroup>
  25 + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
  26 + <DebugType>pdbonly</DebugType>
  27 + <Optimize>true</Optimize>
  28 + <OutputPath>bin\Release\</OutputPath>
  29 + <DefineConstants>TRACE</DefineConstants>
  30 + <ErrorReport>prompt</ErrorReport>
  31 + <WarningLevel>4</WarningLevel>
  32 + </PropertyGroup>
  33 + <ItemGroup>
  34 + <Reference Include="System" />
  35 + <Reference Include="System.ComponentModel.Composition.CodePlex">
  36 + <HintPath>..\Glucodyn\Libs\System.ComponentModel.Composition.CodePlex.dll</HintPath>
  37 + </Reference>
  38 + <Reference Include="System.ComponentModel.Composition.Registration.CodePlex">
  39 + <HintPath>..\Glucodyn\Libs\System.ComponentModel.Composition.Registration.CodePlex.dll</HintPath>
  40 + </Reference>
  41 + <Reference Include="System.Core" />
  42 + <Reference Include="System.Reflection.Context.CodePlex">
  43 + <HintPath>..\Glucodyn\Libs\System.Reflection.Context.CodePlex.dll</HintPath>
  44 + </Reference>
  45 + <Reference Include="System.Xml.Linq" />
  46 + <Reference Include="System.Data.DataSetExtensions" />
  47 + <Reference Include="Microsoft.CSharp" />
  48 + <Reference Include="System.Data" />
  49 + <Reference Include="System.Xml" />
  50 + </ItemGroup>
  51 + <ItemGroup>
  52 + <Compile Include="IModule.cs" />
  53 + <Compile Include="ModuleManager.cs" />
  54 + <Compile Include="Properties\AssemblyInfo.cs" />
  55 + </ItemGroup>
  56 + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  57 + <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
  58 + Other similar extension points exist, see Microsoft.Common.targets.
  59 + <Target Name="BeforeBuild">
  60 + </Target>
  61 + <Target Name="AfterBuild">
  62 + </Target>
  63 + -->
  64 +</Project>
13 Glucodyn.ModuleManager/IModule.cs
... ... @@ -0,0 +1,13 @@
  1 +using System;
  2 +
  3 +namespace Glucodyn.ModuleManager
  4 +{
  5 + public interface IModule
  6 + {
  7 + Guid Id { get; }
  8 + string Name { get; }
  9 + string Version { get; }
  10 +
  11 + void Initialize();
  12 + }
  13 +}
36 Glucodyn.ModuleManager/ModuleManager.cs
... ... @@ -0,0 +1,36 @@
  1 +using System;
  2 +using System.Collections.Generic;
  3 +using System.Collections.ObjectModel;
  4 +using System.ComponentModel.Composition;
  5 +using System.ComponentModel.Composition.Hosting;
  6 +using System.Linq;
  7 +using System.Reflection;
  8 +using System.Text;
  9 +
  10 +namespace Glucodyn.ModuleManager
  11 +{
  12 + public class ModuleManager
  13 + {
  14 + [ImportMany(typeof(IModule))]
  15 + private Lazy<IModule, IDictionary<string, object>>[] Modules { get; set; }
  16 +
  17 +
  18 + public IModule FindModule(string cmd)
  19 + {
  20 + LoadModules();
  21 +
  22 + return (from codeVault in Modules
  23 + where (string)codeVault.Metadata["Command"] == cmd
  24 + select codeVault).Single().Value;
  25 + }
  26 +
  27 + private void LoadModules()
  28 + {
  29 + var catalog = new AggregateCatalog();
  30 + catalog.Catalogs.Add(new DirectoryCatalog(@"C:\Users\soojendi\Documents\Visual Studio 2010\Projects\Glucodyn\Modules\TestModule\bin\Debug", "*.dll"));
  31 + var container = new CompositionContainer(catalog);
  32 + container.ComposeParts(this);
  33 + }
  34 + }
  35 +
  36 +}
36 Glucodyn.ModuleManager/Properties/AssemblyInfo.cs
... ... @@ -0,0 +1,36 @@
  1 +using System.Reflection;
  2 +using System.Runtime.CompilerServices;
  3 +using System.Runtime.InteropServices;
  4 +
  5 +// General Information about an assembly is controlled through the following
  6 +// set of attributes. Change these attribute values to modify the information
  7 +// associated with an assembly.
  8 +[assembly: AssemblyTitle("Glucodyn.ModuleManager")]
  9 +[assembly: AssemblyDescription("")]
  10 +[assembly: AssemblyConfiguration("")]
  11 +[assembly: AssemblyCompany("")]
  12 +[assembly: AssemblyProduct("Glucodyn.ModuleManager")]
  13 +[assembly: AssemblyCopyright("Copyright © 2012")]
  14 +[assembly: AssemblyTrademark("")]
  15 +[assembly: AssemblyCulture("")]
  16 +
  17 +// Setting ComVisible to false makes the types in this assembly not visible
  18 +// to COM components. If you need to access a type in this assembly from
  19 +// COM, set the ComVisible attribute to true on that type.
  20 +[assembly: ComVisible(false)]
  21 +
  22 +// The following GUID is for the ID of the typelib if this project is exposed to COM
  23 +[assembly: Guid("71208057-afa7-4901-b0de-67aa162232b9")]
  24 +
  25 +// Version information for an assembly consists of the following four values:
  26 +//
  27 +// Major Version
  28 +// Minor Version
  29 +// Build Number
  30 +// Revision
  31 +//
  32 +// You can specify all the values or you can default the Build and Revision Numbers
  33 +// by using the '*' as shown below:
  34 +// [assembly: AssemblyVersion("1.0.*")]
  35 +[assembly: AssemblyVersion("1.0.0.0")]
  36 +[assembly: AssemblyFileVersion("1.0.0.0")]
29 Glucodyn.sln
@@ -10,6 +10,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
10 10 README = README
11 11 EndProjectSection
12 12 EndProject
  13 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Glucodyn.ModuleManager", "Glucodyn.ModuleManager\Glucodyn.ModuleManager.csproj", "{2BA0D831-2226-4F0E-A487-C3C1CA46FCBF}"
  14 +EndProject
  15 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Modules", "Modules", "{59F91E71-154F-4233-AF97-D09C4C9D2749}"
  16 +EndProject
  17 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestModule", "Modules\TestModule\TestModule.csproj", "{C8510856-B975-44F5-808D-0FB918DF7E36}"
  18 +EndProject
13 19 Global
14 20 GlobalSection(SolutionConfigurationPlatforms) = preSolution
15 21 Debug|Any CPU = Debug|Any CPU
@@ -40,8 +46,31 @@ Global
40 46 {191E864E-0C9D-446C-89A6-CA6B569FB4F9}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
41 47 {191E864E-0C9D-446C-89A6-CA6B569FB4F9}.Release|Mixed Platforms.Build.0 = Release|Any CPU
42 48 {191E864E-0C9D-446C-89A6-CA6B569FB4F9}.Release|x86.ActiveCfg = Release|Any CPU
  49 + {2BA0D831-2226-4F0E-A487-C3C1CA46FCBF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
  50 + {2BA0D831-2226-4F0E-A487-C3C1CA46FCBF}.Debug|Any CPU.Build.0 = Debug|Any CPU
  51 + {2BA0D831-2226-4F0E-A487-C3C1CA46FCBF}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
  52 + {2BA0D831-2226-4F0E-A487-C3C1CA46FCBF}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
  53 + {2BA0D831-2226-4F0E-A487-C3C1CA46FCBF}.Debug|x86.ActiveCfg = Debug|Any CPU
  54 + {2BA0D831-2226-4F0E-A487-C3C1CA46FCBF}.Release|Any CPU.ActiveCfg = Release|Any CPU
  55 + {2BA0D831-2226-4F0E-A487-C3C1CA46FCBF}.Release|Any CPU.Build.0 = Release|Any CPU
  56 + {2BA0D831-2226-4F0E-A487-C3C1CA46FCBF}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
  57 + {2BA0D831-2226-4F0E-A487-C3C1CA46FCBF}.Release|Mixed Platforms.Build.0 = Release|Any CPU
  58 + {2BA0D831-2226-4F0E-A487-C3C1CA46FCBF}.Release|x86.ActiveCfg = Release|Any CPU
  59 + {C8510856-B975-44F5-808D-0FB918DF7E36}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
  60 + {C8510856-B975-44F5-808D-0FB918DF7E36}.Debug|Any CPU.Build.0 = Debug|Any CPU
  61 + {C8510856-B975-44F5-808D-0FB918DF7E36}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
  62 + {C8510856-B975-44F5-808D-0FB918DF7E36}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
  63 + {C8510856-B975-44F5-808D-0FB918DF7E36}.Debug|x86.ActiveCfg = Debug|Any CPU
  64 + {C8510856-B975-44F5-808D-0FB918DF7E36}.Release|Any CPU.ActiveCfg = Release|Any CPU
  65 + {C8510856-B975-44F5-808D-0FB918DF7E36}.Release|Any CPU.Build.0 = Release|Any CPU
  66 + {C8510856-B975-44F5-808D-0FB918DF7E36}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
  67 + {C8510856-B975-44F5-808D-0FB918DF7E36}.Release|Mixed Platforms.Build.0 = Release|Any CPU
  68 + {C8510856-B975-44F5-808D-0FB918DF7E36}.Release|x86.ActiveCfg = Release|Any CPU
43 69 EndGlobalSection
44 70 GlobalSection(SolutionProperties) = preSolution
45 71 HideSolutionNode = FALSE
46 72 EndGlobalSection
  73 + GlobalSection(NestedProjects) = preSolution
  74 + {C8510856-B975-44F5-808D-0FB918DF7E36} = {59F91E71-154F-4233-AF97-D09C4C9D2749}
  75 + EndGlobalSection
47 76 EndGlobal
4 Glucodyn/Glucodyn.csproj
@@ -69,6 +69,10 @@
69 69 <Project>{191E864E-0C9D-446C-89A6-CA6B569FB4F9}</Project>
70 70 <Name>Glucodyn.Config</Name>
71 71 </ProjectReference>
  72 + <ProjectReference Include="..\Glucodyn.ModuleManager\Glucodyn.ModuleManager.csproj">
  73 + <Project>{2BA0D831-2226-4F0E-A487-C3C1CA46FCBF}</Project>
  74 + <Name>Glucodyn.ModuleManager</Name>
  75 + </ProjectReference>
72 76 </ItemGroup>
73 77 <ItemGroup />
74 78 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
BIN  Glucodyn/Libs/System.ComponentModel.Composition.CodePlex.dll
Binary file not shown
BIN  Glucodyn/Libs/System.ComponentModel.Composition.Registration.CodePlex.dll
Binary file not shown
BIN  Glucodyn/Libs/System.Reflection.Context.CodePlex.dll
Binary file not shown
5 Glucodyn/Program.cs
... ... @@ -1,6 +1,4 @@
1 1 using System;
2   -using System.Threading;
3   -using Meebey.SmartIrc4net;
4 2 using Glucodyn.Config;
5 3
6 4 namespace Glucodyn
@@ -10,6 +8,9 @@ class Program
10 8 static void Main()
11 9 {
12 10 var identities = new GlucodynConfig();
  11 + ModuleManager.ModuleManager mM = new ModuleManager.ModuleManager();
  12 + var foo = mM.FindModule("TestModule");
  13 + Console.WriteLine(foo.Name);
13 14
14 15 foreach (var ident in identities.Config.identities)
15 16 {
36 Modules/TestModule/Properties/AssemblyInfo.cs
... ... @@ -0,0 +1,36 @@
  1 +using System.Reflection;
  2 +using System.Runtime.CompilerServices;
  3 +using System.Runtime.InteropServices;
  4 +
  5 +// General Information about an assembly is controlled through the following
  6 +// set of attributes. Change these attribute values to modify the information
  7 +// associated with an assembly.
  8 +[assembly: AssemblyTitle("TestModule")]
  9 +[assembly: AssemblyDescription("")]
  10 +[assembly: AssemblyConfiguration("")]
  11 +[assembly: AssemblyCompany("")]
  12 +[assembly: AssemblyProduct("TestModule")]
  13 +[assembly: AssemblyCopyright("Copyright © 2012")]
  14 +[assembly: AssemblyTrademark("")]
  15 +[assembly: AssemblyCulture("")]
  16 +
  17 +// Setting ComVisible to false makes the types in this assembly not visible
  18 +// to COM components. If you need to access a type in this assembly from
  19 +// COM, set the ComVisible attribute to true on that type.
  20 +[assembly: ComVisible(false)]
  21 +
  22 +// The following GUID is for the ID of the typelib if this project is exposed to COM
  23 +[assembly: Guid("59e607f5-07d3-4e82-8fa2-9d8a68a25dea")]
  24 +
  25 +// Version information for an assembly consists of the following four values:
  26 +//
  27 +// Major Version
  28 +// Minor Version
  29 +// Build Number
  30 +// Revision
  31 +//
  32 +// You can specify all the values or you can default the Build and Revision Numbers
  33 +// by using the '*' as shown below:
  34 +// [assembly: AssemblyVersion("1.0.*")]
  35 +[assembly: AssemblyVersion("1.0.0.0")]
  36 +[assembly: AssemblyFileVersion("1.0.0.0")]
23 Modules/TestModule/TestModule.cs
... ... @@ -0,0 +1,23 @@
  1 +using System;
  2 +using System.ComponentModel.Composition;
  3 +using System.Reflection;
  4 +using Glucodyn.ModuleManager;
  5 +
  6 +namespace TestModule
  7 +{
  8 + [Export(typeof(IModule))]
  9 + [ExportMetadata("Command", "TestModule")]
  10 + class TestModule : IModule
  11 + {
  12 + public Guid Id { get { return Guid.NewGuid(); } }
  13 +
  14 + public string Name { get { return "Test module"; } }
  15 +
  16 + public string Version { get { return Assembly.GetExecutingAssembly().GetName().Version.ToString(); } }
  17 +
  18 + public void Initialize()
  19 + {
  20 + Console.WriteLine("TestModule is starting up ...");
  21 + }
  22 + }
  23 +}
73 Modules/TestModule/TestModule.csproj
... ... @@ -0,0 +1,73 @@
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  3 + <PropertyGroup>
  4 + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
  5 + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
  6 + <ProductVersion>8.0.30703</ProductVersion>
  7 + <SchemaVersion>2.0</SchemaVersion>
  8 + <ProjectGuid>{C8510856-B975-44F5-808D-0FB918DF7E36}</ProjectGuid>
  9 + <OutputType>Library</OutputType>
  10 + <AppDesignerFolder>Properties</AppDesignerFolder>
  11 + <RootNamespace>TestModule</RootNamespace>
  12 + <AssemblyName>TestModule</AssemblyName>
  13 + <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
  14 + <FileAlignment>512</FileAlignment>
  15 + </PropertyGroup>
  16 + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
  17 + <DebugSymbols>true</DebugSymbols>
  18 + <DebugType>full</DebugType>
  19 + <Optimize>false</Optimize>
  20 + <OutputPath>bin\Debug\</OutputPath>
  21 + <DefineConstants>DEBUG;TRACE</DefineConstants>
  22 + <ErrorReport>prompt</ErrorReport>
  23 + <WarningLevel>4</WarningLevel>
  24 + </PropertyGroup>
  25 + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
  26 + <DebugType>pdbonly</DebugType>
  27 + <Optimize>true</Optimize>
  28 + <OutputPath>bin\Release\</OutputPath>
  29 + <DefineConstants>TRACE</DefineConstants>
  30 + <ErrorReport>prompt</ErrorReport>
  31 + <WarningLevel>4</WarningLevel>
  32 + </PropertyGroup>
  33 + <ItemGroup>
  34 + <Reference Include="System" />
  35 + <Reference Include="System.ComponentModel.Composition.CodePlex">
  36 + <HintPath>..\Glucodyn\Libs\System.ComponentModel.Composition.CodePlex.dll</HintPath>
  37 + </Reference>
  38 + <Reference Include="System.ComponentModel.Composition.Registration.CodePlex">
  39 + <HintPath>..\Glucodyn\Libs\System.ComponentModel.Composition.Registration.CodePlex.dll</HintPath>
  40 + </Reference>
  41 + <Reference Include="System.Core" />
  42 + <Reference Include="System.Reflection.Context.CodePlex">
  43 + <HintPath>..\Glucodyn\Libs\System.Reflection.Context.CodePlex.dll</HintPath>
  44 + </Reference>
  45 + <Reference Include="System.Xml.Linq" />
  46 + <Reference Include="System.Data.DataSetExtensions" />
  47 + <Reference Include="Microsoft.CSharp" />
  48 + <Reference Include="System.Data" />
  49 + <Reference Include="System.Xml" />
  50 + </ItemGroup>
  51 + <ItemGroup>
  52 + <Compile Include="Properties\AssemblyInfo.cs" />
  53 + <Compile Include="TestModule.cs" />
  54 + </ItemGroup>
  55 + <ItemGroup>
  56 + <ProjectReference Include="..\..\Glucodyn.ModuleManager\Glucodyn.ModuleManager.csproj">
  57 + <Project>{2BA0D831-2226-4F0E-A487-C3C1CA46FCBF}</Project>
  58 + <Name>Glucodyn.ModuleManager</Name>
  59 + </ProjectReference>
  60 + </ItemGroup>
  61 + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  62 + <PropertyGroup>
  63 + <PostBuildEvent>
  64 + </PostBuildEvent>
  65 + </PropertyGroup>
  66 + <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
  67 + Other similar extension points exist, see Microsoft.Common.targets.
  68 + <Target Name="BeforeBuild">
  69 + </Target>
  70 + <Target Name="AfterBuild">
  71 + </Target>
  72 + -->
  73 +</Project>
1  README
@@ -29,5 +29,4 @@ How to write modules: throw new NotImplementedException();
29 29
30 30 ToDO: * Create module system
31 31 * Exception handling
32   - * Logging - each identity should have seperate log file
33 32

0 comments on commit c098b1e

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