diff --git a/src/Artemis.Core/Artemis.Core.csproj b/src/Artemis.Core/Artemis.Core.csproj
index 988875376..a86594536 100644
--- a/src/Artemis.Core/Artemis.Core.csproj
+++ b/src/Artemis.Core/Artemis.Core.csproj
@@ -35,9 +35,6 @@
..\packages\Castle.Core.4.2.1\lib\net45\Castle.Core.dll
-
- ..\packages\CS-Script.bin.3.28.0.1\lib\net46\CSScriptLibrary.dll
-
..\packages\HidSharp.1.5\lib\net35\HidSharp.dll
@@ -47,15 +44,6 @@
..\packages\Microsoft.CodeAnalysis.CSharp.2.6.1\lib\netstandard1.3\Microsoft.CodeAnalysis.CSharp.dll
-
- ..\packages\Microsoft.CodeAnalysis.CSharp.Scripting.2.6.1\lib\netstandard1.3\Microsoft.CodeAnalysis.CSharp.Scripting.dll
-
-
- ..\packages\Microsoft.CodeAnalysis.Scripting.Common.2.6.1\lib\netstandard1.3\Microsoft.CodeAnalysis.Scripting.dll
-
-
- ..\packages\CS-Script.bin.3.28.0.1\lib\net46\Mono.CSharp.dll
-
..\packages\Newtonsoft.Json.11.0.1\lib\net45\Newtonsoft.Json.dll
@@ -68,61 +56,47 @@
..\packages\Ninject.Extensions.Factory.3.3.2\lib\net45\Ninject.Extensions.Factory.dll
-
+
..\packages\RGB.NET.Brushes.0.0.1.38\lib\net45\RGB.NET.Brushes.dll
- True
-
+
..\packages\RGB.NET.Core.0.0.1.38\lib\net45\RGB.NET.Core.dll
- True
-
+
..\packages\RGB.NET.Decorators.0.0.1.38\lib\net45\RGB.NET.Decorators.dll
- True
-
+
..\packages\RGB.NET.Devices.Asus.0.0.1.38\lib\net45\RGB.NET.Devices.Asus.dll
- True
-
+
..\packages\RGB.NET.Devices.CoolerMaster.0.0.1.38\lib\net45\RGB.NET.Devices.CoolerMaster.dll
- True
-
+
..\packages\RGB.NET.Devices.Corsair.0.0.1.38\lib\net45\RGB.NET.Devices.Corsair.dll
- True
-
+
..\packages\RGB.NET.Devices.DMX.0.0.1.38\lib\net45\RGB.NET.Devices.DMX.dll
- True
-
+
..\packages\RGB.NET.Devices.Logitech.0.0.1.38\lib\net45\RGB.NET.Devices.Logitech.dll
- True
-
+
..\packages\RGB.NET.Devices.Msi.0.0.1.38\lib\net45\RGB.NET.Devices.Msi.dll
- True
-
+
..\packages\RGB.NET.Devices.Novation.0.0.1.38\lib\net45\RGB.NET.Devices.Novation.dll
- True
-
+
..\packages\RGB.NET.Devices.Razer.0.0.1.38\lib\net45\RGB.NET.Devices.Razer.dll
- True
-
+
..\packages\RGB.NET.Groups.0.0.1.38\lib\net45\RGB.NET.Groups.dll
- True
-
+
..\packages\RGB.NET.Input.0.0.1.38\lib\net45\RGB.NET.Input.dll
- True
-
+
..\packages\RGB.NET.Input.Corsair.0.0.1.38\lib\net45\RGB.NET.Input.Corsair.dll
- True
..\packages\Sanford.Multimedia.Midi.6.6.0\lib\net20\Sanford.Multimedia.Midi.dll
@@ -216,9 +190,6 @@
-
-
-
@@ -237,26 +208,34 @@
{cd23bc5e-57f0-46ce-a007-24d031146219}
Artemis.Plugins
+
+ {58113cc5-a9ca-4ec3-ab4e-3c94b99268d8}
+ Module.General
+
-
+
+
+
+
+
+
This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
-
-
+
+
-
-
-
+
+
\ No newline at end of file
diff --git a/src/Artemis.Core/Constants.cs b/src/Artemis.Core/Constants.cs
index 5c3942950..ad65affd1 100644
--- a/src/Artemis.Core/Constants.cs
+++ b/src/Artemis.Core/Constants.cs
@@ -4,7 +4,6 @@ namespace Artemis.Core
{
public static class Constants
{
- public static readonly string DataFolder =
- Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\Artemis\\";
+ public static readonly string DataFolder = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\Artemis\\";
}
}
\ No newline at end of file
diff --git a/src/Artemis.Core/Ninject/CoreModule.cs b/src/Artemis.Core/Ninject/CoreModule.cs
index 6b1c062c2..5698176f1 100644
--- a/src/Artemis.Core/Ninject/CoreModule.cs
+++ b/src/Artemis.Core/Ninject/CoreModule.cs
@@ -1,4 +1,5 @@
using Artemis.Core.Services.Interfaces;
+using Artemis.Plugins.Interfaces;
using Ninject.Extensions.Conventions;
using Ninject.Modules;
@@ -17,6 +18,15 @@ namespace Artemis.Core.Ninject
.BindAllInterfaces()
.Configure(c => c.InSingletonScope());
});
+
+ // Bind all built-in plugins
+ Kernel.Bind(x =>
+ {
+ x.FromThisAssembly()
+ .SelectAllClasses()
+ .InheritedFrom()
+ .BindAllBaseClasses();
+ });
}
}
}
\ No newline at end of file
diff --git a/src/Artemis.Core/Scripting.Extensions.cs b/src/Artemis.Core/Scripting.Extensions.cs
deleted file mode 100644
index 070536442..000000000
--- a/src/Artemis.Core/Scripting.Extensions.cs
+++ /dev/null
@@ -1,295 +0,0 @@
-using CSScriptLibrary;
-using System;
-using System.Diagnostics;
-using System.Reflection;
-using System.Runtime.Remoting.Lifetime;
-using System.Threading;
-using System.Threading.Tasks;
-
-// Read in more details about all aspects of CS-Script hosting in applications
-// here: http://www.csscript.net/help/Script_hosting_guideline_.html
-//
-// This file contains samples for the script hosting scenarios requiring asynchronous script execution as well as unloading the
-// scripts being executed.
-// AsyncSamples
-// Samples demonstrate the use of Async and Await mechanism available in C# 5 and higher. Note that the async method extensions
-// cover the complete set of CSScript.Evaluator methods.
-//
-// UnloadingSamples
-// Samples demonstrate the use of temporary AppDoamain for loading and executing dynamic C# code (script). It is the
-// only mechanism available for unloading dynamically loaded assemblies. This is a well known CLR design limitation that leads to
-// memory leaks if the assembly/script loaded in the caller AppDomain. The problem affects all C# script engines (e.g. Roslyn, CodeDom)
-// and it cannot be solved by the engine itself thus CS-Script provides a work around in form of the MethodExtensions for the
-// CSScript.Evaluator methods that are compatible with the unloading mechanism.
-//
-// Nevertheless you should try to avoid using remote AppDoamain unless you have to. It is very heavy and also imposes the serialization
-// constrains.
-//
-// All samples rely on the compiler agnostic CSScript.Evaluator API.
-namespace CSScriptEvaluatorExtensions
-{
- public class HostApp
- {
- public static void Test()
- {
- Console.WriteLine("---------------------------------------------");
- Console.WriteLine("Testing asynchronous API");
- Console.WriteLine("---------------------------------------------");
- new AsyncSamples().RunAll();
- Thread.Sleep(2000);
- Console.WriteLine("\nPress 'Enter' to run uloading samples...");
- Console.ReadLine();
- Console.WriteLine("---------------------------------------------");
- Console.WriteLine("Testing unloading API");
- Console.WriteLine("---------------------------------------------");
- new UnloadingSamples().RunAll();
- }
-
- class AsyncSamples
- {
- public void RunAll()
- {
- Action run = (action, name) => { action(); Console.WriteLine(name); };
-
- run(LoadDelegateAsync, "Start of " + nameof(LoadDelegateAsync));
- run(LoadMethodAsync, "Start of " + nameof(LoadMethodAsync));
- run(LoadCodeAsync, "Start of " + nameof(LoadCodeAsync));
- run(CreateDelegateAsync, "Start of " + nameof(CreateDelegateAsync));
- run(CompileCodeAsync, "Start of " + nameof(CompileCodeAsync));
- run(RemoteAsynch, "Start of " + nameof(RemoteAsynch));
- }
-
- async void LoadDelegateAsync()
- {
- var product = await CSScript.Evaluator
- .LoadDelegateAsync>(
- @"int Product(int a, int b)
- {
- return a * b;
- }");
-
- Console.WriteLine(" End of {0}: {1}", nameof(LoadDelegateAsync), product(4, 2));
- }
-
- public async void LoadMethodAsync()
- {
- dynamic script = await CSScript.Evaluator
- .LoadMethodAsync(@"public int Sum(int a, int b)
- {
- return a + b;
- }
- public int Div(int a, int b)
- {
- return a/b;
- }");
-
- Console.WriteLine(" End of {0}: {1}", nameof(LoadMethodAsync), script.Div(15, 3));
- }
-
- public async void LoadCodeAsync()
- {
- //This use-case uses Interface Alignment and this requires all assemblies involved to have
- //non-empty Assembly.Location
- CSScript.GlobalSettings.InMemoryAssembly = false;
-
- ICalc calc = await CSScript.Evaluator
- .LoadCodeAsync(
- @"using System;
- public class Script
- {
- public int Sum(int a, int b)
- {
- return a+b;
- }
- }");
-
- Console.WriteLine(" End of {0}: {1}", nameof(LoadCodeAsync), calc.Sum(1, 2));
- }
-
- public async void CreateDelegateAsync()
- {
- var product = await CSScript.Evaluator
- .CreateDelegateAsync(
- @"int Product(int a, int b)
- {
- return a * b;
- }");
-
- Console.WriteLine(" End of {0}: {1}", nameof(CreateDelegateAsync), product(15, 3));
- }
-
- public async void CompileCodeAsync()
- {
- Assembly script = await CSScript.Evaluator
- .CompileCodeAsync(@"using System;
- public class Script
- {
- public int Sum(int a, int b)
- {
- return a+b;
- }
- }");
- dynamic calc = script.CreateObject("*");
-
- Console.WriteLine(" End of {0}: {1}", nameof(CompileCodeAsync), calc.Sum(15, 3));
- }
-
- public async void RemoteAsynch()
- {
- var sum = await Task.Run(() =>
- CSScript.Evaluator
- .CreateDelegateRemotely(
- @"int Sum(int a, int b)
- {
- return a+b;
- }")
- );
- Console.WriteLine(" End of {0}: {1}", nameof(RemoteAsynch), sum(1, 2));
-
- sum.UnloadOwnerDomain();
- }
- }
-
- class UnloadingSamples
- {
- public void RunAll()
- {
- CreateDelegateRemotely();
- LoadMethodRemotely();
- LoadCodeRemotely();
- LoadCodeRemotelyWithInterface();
- }
-
- public void CreateDelegateRemotely()
- {
- var sum = CSScript.Evaluator
- .CreateDelegateRemotely(@"int Sum(int a, int b)
- {
- return a+b;
- }");
-
- Console.WriteLine("{0}: {1}", nameof(CreateDelegateRemotely), sum(15, 3));
-
- sum.UnloadOwnerDomain();
- }
-
- public void LoadCodeRemotely()
- {
- // Class Calc doesn't implement ICals interface. Thus the compiled object cannot be typecasted into
- // the interface and Evaluator will emit duck-typed assembly instead.
- // But Mono and Roslyn build file-less assemblies, meaning that they cannot be used to build
- // duck-typed proxies and CodeDomEvaluator needs to be used explicitly.
- // Note class Calc also inherits from MarshalByRefObject. This is required for all object that
- // are passed between AppDomain: they must inherit from MarshalByRefObject or be serializable.
-
- //This use-case uses Interface Alignment and this requires all assemblies involved to have
- //non-empty Assembly.Location
- CSScript.GlobalSettings.InMemoryAssembly = false;
-
- var script = CSScript.CodeDomEvaluator
- .LoadCodeRemotely(
- @"using System;
- public class Calc : MarshalByRefObject
- {
- object t;
- public int Sum(int a, int b)
- {
- t = new Test();
- return a+b;
- }
- }
-
- class Test
- {
- ~Test()
- {
- Console.WriteLine(""Domain is unloaded: ~Test()"");
- }
- }
- ");
-
- Console.WriteLine("{0}: {1}", nameof(LoadCodeRemotely), script.Sum(15, 3));
-
- script.UnloadOwnerDomain();
- }
-
- public void LoadCodeRemotelyWithInterface()
- {
- // Note class Calc also inherits from MarshalByRefObject. This is required for all object that
- // are passed between AppDomain: they must inherit from MarshalByRefObject or be serializable.
- var script = CSScript.Evaluator
- .LoadCodeRemotely(
- @"using System;
- public class Calc : MarshalByRefObject, CSScriptEvaluatorExtensions.ICalc
- {
- public int Sum(int a, int b)
- {
- return a+b;
- }
- }
- ");
-
- Console.WriteLine("{0}: {1}", nameof(LoadCodeRemotelyWithInterface), script.Sum(15, 3));
-
- script.UnloadOwnerDomain();
- }
-
- public void LoadMethodRemotely()
- {
- // LoadMethodRemotely is essentially the same as LoadCodeRemotely. It just deals not with the
- // whole class definition but a single method(s) only. And the rest of the class definition is
- // added automatically by CS-Script. The auto-generated class declaration also indicates
- // that the class implements ICalc interface. Meaning that it will trigger compile error
- // if the set of methods in the script code doesn't implement all interface members.
-
- //This use-case uses Interface Alignment and this requires all assemblies involved to have
- //non-empty Assembly.Location
- CSScript.GlobalSettings.InMemoryAssembly = false;
-
- var script = CSScript.Evaluator
- .LoadMethodRemotely(
- @"public int Sum(int a, int b)
- {
- return a+b;
- }
- public int Sub(int a, int b)
- {
- return a-b;
- }");
-
- Console.WriteLine("{0}: {1}", nameof(LoadMethodRemotely), script.Sum(15, 3));
-
- script.UnloadOwnerDomain();
- }
-
- MethodDelegate sum;
- ClientSponsor sumSponsor;
-
- public void KeepRemoteObjectAlive()
- {
- sum = CSScript.Evaluator
- .CreateDelegateRemotely(@"int Sum(int a, int b)
- {
- return a+b;
- }");
-
- //Normally remote objects are disposed if they are not accessed withing a default timeout period.
- //It is not even enough to keep transparent proxies or their wrappers (e.g. 'sum') referenced.
- //To prevent GC collection in the remote domain use .NET ClientSponsor mechanism as below.
- sumSponsor = sum.ExtendLifeFromMinutes(30);
- }
- }
- }
-
- public interface ICalc
- {
- int Sum(int a, int b);
- }
-
- public interface IFullCalc
- {
- int Sum(int a, int b);
-
- int Sub(int a, int b);
- }
-}
\ No newline at end of file
diff --git a/src/Artemis.Core/Scripting.evaluator.cs b/src/Artemis.Core/Scripting.evaluator.cs
deleted file mode 100644
index 0e195776f..000000000
--- a/src/Artemis.Core/Scripting.evaluator.cs
+++ /dev/null
@@ -1,345 +0,0 @@
-using CSScriptLibrary;
-using System;
-using System.Diagnostics;
-
-// Read in more details about all aspects of CS-Script hosting in applications
-// here: http://www.csscript.net/help/Script_hosting_guideline_.html
-//
-// This file contains samples for the script hosting scenarios relying on CS-Script Evaluator interface (API).
-// This API is a unified generic interface allowing dynamic switch of the underlying compiling services (Mono, Roslyn, CodeDom)
-// without the need for changing the hosting code.
-//
-// Apart from Evaluator (compiler agnostic) API CS-Script offers alternative hosting model: CS-Script Native,
-// which relies solely on CodeDom compiler. CS-Script Native offers some features that are not available with CS-Script Evaluator
-// (e.g. script unloading).
-//
-// The choice of the underlying compiling engine (e.g. Mono vs CodeDom) when using CS-Script Evaluator is always dictated by the
-// specifics of the hosting scenario. Thanks to in-process compiler hosting, Mono and Roslyn demonstrate much better compiling
-// performance comparing to CodeDom engine. However they don't allow script debugging and caching easily supported with CodeDom.
-// Mono and particularly Roslyn also leas create more memory pressure due to the higher volume of the temp assemblies loaded into
-// the hosting AppDomain. Roslyn (at least CSharp.Scripting-v1.2.0.0) also has very high initial loading overhead up to 4 seconds.
-//
-// One of the possible approaches would be to use EvaluatorEngine.CodeDom during the active development and later on switch to Mono/Roslyn.
-
-namespace CSScriptEvaluatorApi
-{
- public class HostApp
- {
- public static void Test()
- {
- // Just in case clear AlternativeCompiler so it is not set to Roslyn or anything else by
- // the CS-Script installed (if any) on the host OS
- CSScript.GlobalSettings.UseAlternativeCompiler = null;
-
- var samples = new EvaluatorSamples();
-
- Console.WriteLine("Testing compiling services");
- Console.WriteLine("---------------------------------------------");
-
- CSScript.EvaluatorConfig.Engine = EvaluatorEngine.Mono;
- Console.WriteLine(CSScript.Evaluator.GetType().Name + "...");
- samples.RunAll();
-
- Console.WriteLine("---------------------------------------------");
-
- CSScript.EvaluatorConfig.Engine = EvaluatorEngine.Roslyn;
- Console.WriteLine(CSScript.Evaluator.GetType().Name + "...");
- samples.RunAll();
-
- Console.WriteLine("---------------------------------------------");
-
- CSScript.EvaluatorConfig.Engine = EvaluatorEngine.CodeDom;
- Console.WriteLine(CSScript.Evaluator.GetType().Name + "...");
-
- samples.RunAll();
-
- //samples.DebugTest(); //uncomment if want to fire an assertion during the script execution
-
- //Profile(); //uncomment if want to test performance of the engines
- }
-
- class EvaluatorSamples
- {
- public void RunAll()
- {
- Action run = (action, name) => { action(); Console.WriteLine(name + " - OK"); };
-
- run(CompileMethod_Instance, nameof(CompileMethod_Instance));
- run(CompileMethod_Static, nameof(CompileMethod_Static));
- run(CreateDelegate, nameof(CreateDelegate));
- run(LoadDelegate, nameof(LoadDelegate));
- run(LoadCode, nameof(LoadCode));
- run(LoadMethod, nameof(LoadMethod));
- run(LoadMethodWithInterface, nameof(LoadMethodWithInterface));
- run(LoadCode_WithInterface, nameof(LoadCode_WithInterface));
- run(LoadCode_WithDuckTypedInterface, nameof(LoadCode_WithDuckTypedInterface));
- }
-
- public void CompileMethod_Instance()
- {
- // 1- CompileMethod wraps method into a class definition and returns compiled assembly
- // 2 - CreateObject creates instance of a first class in the assembly
-
- dynamic script = CSScript.Evaluator
- .CompileMethod(@"int Sqr(int data)
- {
- return data * data;
- }")
- .CreateObject("*");
-
- var result = script.Sqr(7);
- }
-
- public void CompileMethod_Static()
- {
- // 1 - CompileMethod wraps method into a class definition and returns compiled assembly
- // 2 - GetStaticMethod returns duck-typed delegate that accepts 'params object[]' arguments
- // Note: GetStaticMethodWithArgs can be replaced with a more convenient/shorter version
- // that takes the object instead of the Type and then queries objects type internally:
- // "GetStaticMethod("*.Test", data)"
-
- var test = CSScript.Evaluator
- .CompileMethod(@"using CSScriptEvaluatorApi;
- static void Test(InputData data)
- {
- data.Index = GetIndex();
- }
- static int GetIndex()
- {
- return Environment.TickCount;
- }")
- .GetStaticMethodWithArgs("*.Test", typeof(InputData));
-
- var data = new InputData();
- test(data);
- }
-
- public void CreateDelegate()
- {
- // Wraps method into a class definition, compiles it and loads the compiled assembly.
- // It returns duck-typed delegate. A delegate with 'params object[]' arguments and
- // without any specific return type.
-
- var sqr = CSScript.Evaluator
- .CreateDelegate(@"int Sqr(int a)
- {
- return a * a;
- }");
-
- var r = sqr(3);
- }
-
- public void LoadDelegate()
- {
- // Wraps method into a class definition, loads the compiled assembly
- // and returns the method delegate for the method, which matches the delegate specified
- // as the type parameter of LoadDelegate
-
- var product = CSScript.Evaluator
- .LoadDelegate>(
- @"int Product(int a, int b)
- {
- return a * b;
- }");
-
- int result = product(3, 2);
- }
-
- public void LoadCode()
- {
- // LoadCode compiles code and returns instance of a first class
- // in the compiled assembly
-
- dynamic script = CSScript.Evaluator
- .LoadCode(@"using System;
- public class Script
- {
- public int Sum(int a, int b)
- {
- return a+b;
- }
- }");
-
- int result = script.Sum(1, 2);
- }
-
- public void LoadMethod()
- {
- // LoadMethod compiles code and returns instance of a first class
- // in the compiled assembly.
- // LoadMethod is essentially the same as LoadCode. It just deals not with the
- // whole class definition but a single method(s) only. And the rest of the class definition is
- // added automatically by CS-Script.
- // 'public' is optional as it will be injected if the code doesn't start with it.
- dynamic script = CSScript.Evaluator
- .LoadMethod(@"using System;
- public int Sum(int a, int b)
- {
- return a+b;
- }");
-
- int result = script.Sum(1, 2);
- }
-
- public void LoadMethodWithInterface()
- {
- // LoadMethod compiles code and returns instance of a first class
- // in the compiled assembly.
- // LoadMethod is essentially the same as LoadCode. It just deals not with the
- // whole class definition but a single method(s) only. And the rest of the class definition is
- // added automatically by CS-Script. The auto-generated class declaration also indicates
- // that the class implements ICalc interface. Meaning that it will trigger compile error
- // if the set of methods in the script code doesn't implement all interface members.
-
- //This use-case uses Interface Alignment and this requires all assemblies involved to have
- //non-empty Assembly.Location
- CSScript.GlobalSettings.InMemoryAssembly = false;
-
- ICalc script = CSScript.Evaluator
- .LoadMethod(
- @"int Sum(int a, int b)
- {
- return a+b;
- }");
-
- int result = script.Sum(1, 2);
- }
-
- public void LoadCode_WithInterface()
- {
- // 1 - LoadCode compiles code and returns instance of a first class in the compiled assembly
- // 2 - The script class implements host app interface so the returned object can be type casted into it
-
- var script = (ICalc)CSScript.Evaluator
- .LoadCode(@"using System;
- public class Script : CSScriptEvaluatorApi.ICalc
- {
- public int Sum(int a, int b)
- {
- return a+b;
- }
- }");
-
- int result = script.Sum(1, 2);
- }
-
- public void LoadCode_WithDuckTypedInterface()
- {
- // 1 - LoadCode compiles code and returns instance of a first class in the compiled assembly
- // 2- The script class doesn't implement host app interface but it can still be aligned to
- // one as long at it implements the interface members
-
- //This use-case uses Interface Alignment and this requires all assemblies involved to have
- //non-empty Assembly.Location
- CSScript.GlobalSettings.InMemoryAssembly = false;
-
- ICalc script = CSScript.MonoEvaluator
- .LoadCode(@"using System;
- public class Script
- {
- public int Sum(int a, int b)
- {
- return a+b;
- }
- }");
-
- int result = script.Sum(1, 2);
- }
-
- public void PerformanceTest(int count = -1)
- {
- var code = @"int Sqr(int a)
- {
- return a * a;
- }";
-
- if (count != -1)
- code += "//" + count; //this unique extra code comment ensures the code to be compiled cannot be cached
-
- dynamic script = CSScript.Evaluator
- .CompileMethod(code)
- .CreateObject("*");
-
- var r = script.Sqr(3);
- }
-
- public void DebugTest()
- {
- //pops up an assertion dialog
-
- CSScript.EvaluatorConfig.DebugBuild = true;
- CSScript.EvaluatorConfig.Engine = EvaluatorEngine.CodeDom;
-
- dynamic script = CSScript.Evaluator
- .LoadCode(@"using System;
- using System.Diagnostics;
- public class Script
- {
- public int Sum(int a, int b)
- {
- Debug.Assert(false,""Testing CS-Script debugging..."");
- return a+b;
- }
- }");
-
- var r = script.Sum(3, 4);
- }
- }
-
- public static void Profile()
- {
- var sw = new Stopwatch();
- var samples = new EvaluatorSamples();
- var count = 20;
- var inxed = 0;
- bool preventCaching = false;
-
- Action run = () =>
- {
- sw.Restart();
- for (int i = 0; i < count; i++)
- if (preventCaching)
- samples.PerformanceTest(inxed++);
- else
- samples.PerformanceTest();
-
- Console.WriteLine(CSScript.Evaluator.GetType().Name + ": " + sw.ElapsedMilliseconds);
- };
-
- Action runAll = () =>
- {
- Console.WriteLine("\n---------------------------------------------");
- Console.WriteLine($"Caching enabled: {!preventCaching}\n");
-
- CSScript.EvaluatorConfig.Engine = EvaluatorEngine.Mono;
- run();
-
- CSScript.EvaluatorConfig.Engine = EvaluatorEngine.CodeDom;
- run();
-
- CSScript.EvaluatorConfig.Engine = EvaluatorEngine.Roslyn;
- run();
- };
-
- RoslynEvaluator.LoadCompilers(); //Roslyn is extremely heavy so exclude startup time from profiling
-
- Console.WriteLine("Testing performance");
-
- preventCaching = true;
- runAll();
-
- preventCaching = false;
- runAll();
- }
- }
-
- public interface ICalc
- {
- int Sum(int a, int b);
- }
-
- public class InputData
- {
- public int Index = 0;
- }
-}
\ No newline at end of file
diff --git a/src/Artemis.Core/Scripting.native.cs b/src/Artemis.Core/Scripting.native.cs
deleted file mode 100644
index 37c7ef2f7..000000000
--- a/src/Artemis.Core/Scripting.native.cs
+++ /dev/null
@@ -1,354 +0,0 @@
-using CSScriptLibrary;
-using System;
-using System.Linq;
-using System.IO;
-using csscript;
-using System.CodeDom.Compiler;
-
-// Read in more details about all aspects of CS-Script hosting in applications
-// here: http://www.csscript.net/help/Script_hosting_guideline_.html
-//
-// This file contains samples for the script hosting scenarios relying on CS-Script Native interface (API).
-// This API is a compiler specific interface, which relies solely on CodeDom compiler. In most of the cases
-// CS-Script Native model is the most flexible and natural choice
-//
-// Apart from Native API CS-Script offers alternative hosting model: CS-Script Evaluator, which provides
-// a unified generic interface allowing dynamic switch the underlying compiling services (Mono, Roslyn, CodeDom)
-// without the need for changing the hosting code.
-//
-// The Native interface is the original API that was designed to take maximum advantage of the dynamic C# code
-// execution with CodeDom. The original implementation of this API was developed even before any compiler-as-service
-// solution became available. Being based solely on CodeDOM the API doesn't utilize neither Mono nor Roslyn
-// scripting solutions. Despite that CS-Script Native is the most mature, powerful and flexible API available with CS-Script.
-//
-// Native interface allows some unique features that are not available with CS-Script Evaluator:
-// - Debugging scripts
-// - Script caching
-// - Script unloading
-
-namespace CSScriptNativeApi
-{
- public class HostApp
- {
- public static void Test()
- {
- var host = new HostApp();
- host.Log("Testing compiling services CS-Script Native API");
- Console.WriteLine("---------------------------------------------");
-
- CodeDomSamples.LoadMethod_Instance();
- CodeDomSamples.LoadMethod_Static();
- CodeDomSamples.LoadDelegate();
- CodeDomSamples.CreateAction();
- CodeDomSamples.CreateFunc();
- CodeDomSamples.LoadCode();
- CodeDomSamples.LoadCode_WithInterface(host);
- CodeDomSamples.LoadCode_WithDuckTypedInterface(host);
- CodeDomSamples.ExecuteAndUnload();
- //CodeDomSamples.DebugTest(); //uncomment if want to fire an assertion during the script execution
- }
-
- public class CodeDomSamples
- {
- public static void LoadMethod_Instance()
- {
- // 1- LoadMethod wraps method into a class definition, compiles it and returns loaded assembly
- // 2 - CreateObject creates instance of a first class in the assembly
-
- dynamic script = CSScript.LoadMethod(@"int Sqr(int data)
- {
- return data * data;
- }")
- .CreateObject("*");
-
- var result = script.Sqr(7);
- }
-
- public static void LoadMethod_Static()
- {
- // 1 - LoadMethod wraps method into a class definition, compiles it and returns loaded assembly
- // 2 - GetStaticMethod returns first found static method as a duck-typed delegate that
- // accepts 'params object[]' arguments
- //
- // Note: you can use GetStaticMethodWithArgs for higher precision method search: GetStaticMethodWithArgs("*.SayHello", typeof(string));
- var sayHello = CSScript.LoadMethod(@"static void SayHello(string greeting)
- {
- Console.WriteLine(greeting);
- }")
- .GetStaticMethod();
-
- sayHello("Hello World!");
- }
-
- public static void LoadDelegate()
- {
- // LoadDelegate wraps method into a class definition, compiles it and loads the compiled assembly.
- // It returns the method delegate for the method, which matches the delegate specified
- // as the type parameter of LoadDelegate
-
- // The 'using System;' is optional; it demonstrates how to specify 'using' in the method-only syntax
-
- var sayHello = CSScript.LoadDelegate>(
- @"void SayHello(string greeting)
- {
- Console.WriteLine(greeting);
- }");
-
- sayHello("Hello World!");
- }
-
- public static void CreateAction()
- {
- // Wraps method into a class definition, compiles it and loads the compiled assembly.
- // It returns duck-typed delegate. A delegate with 'params object[]' arguments and
- // without any specific return type.
-
- var sayHello = CSScript.CreateAction(@"void SayHello(string greeting)
- {
- Console.WriteLine(greeting);
- }");
-
- sayHello("Hello World!");
- }
-
- public static void CreateFunc()
- {
- // Wraps method into a class definition, compiles it and loads the compiled assembly.
- // It returns duck-typed delegate. A delegate with 'params object[]' arguments and
- // int as a return type.
-
- var Sqr = CSScript.CreateFunc(@"int Sqr(int a)
- {
- return a * a;
- }");
- int r = Sqr(3);
- }
-
- public static void LoadCode()
- {
- // LoadCode compiles code and returns instance of a first class
- // in the compiled assembly
-
- dynamic script = CSScript.LoadCode(@"using System;
- public class Script
- {
- public int Sum(int a, int b)
- {
- return a+b;
- }
- }")
- .CreateObject("*");
-
- int result = script.Sum(1, 2);
- }
-
- public static void LoadCodeWithConfig()
- {
- // LoadCode compiles code and returns instance of a first class
- // in the compiled assembly
-
- string file = Path.GetTempFileName();
- try
- {
- File.WriteAllText(file, @"using System;
- public class Script
- {
- public int Sum(int a, int b)
- {
- return a+b;
- }
- }");
-
- var settings = new Settings();
- //settings = null; // set to null to foll back to defaults
-
- dynamic script = CSScript.LoadWithConfig(file, null, false, settings, "/define:TEST")
- .CreateObject("*");
-
- int result = script.Sum(1, 2);
- }
- finally
- {
- if (File.Exists(file))
- File.Delete(file);
- }
- }
-
- public static void LoadCode_WithInterface(HostApp host)
- {
- // 1 - LoadCode compiles code and returns instance of a first class in the compiled assembly.
- // 2 - The script class implements host app interface so the returned object can be type casted into it.
- // 3 - In this sample host object is passed into script routine.
-
- var calc = (ICalc) CSScript.LoadCode(@"using CSScriptNativeApi;
- public class Script : ICalc
- {
- public int Sum(int a, int b)
- {
- if(Host != null)
- Host.Log(""Sum is invoked"");
- return a + b;
- }
-
- public HostApp Host { get; set; }
- }")
- .CreateObject("*");
- calc.Host = host;
- int result = calc.Sum(1, 2);
- }
-
- public static void LoadCode_WithDuckTypedInterface(HostApp host)
- {
- // 1 - LoadCode compiles code and returns instance of a first class in the compiled assembly
- // 2- The script class doesn't implement host app interface but it can still be aligned to
- // one as long at it implements the interface members
- // 3 - In this sample host object is passed into script routine.
-
- //This use-case uses Interface Alignment and this requires all assemblies involved to have
- //non-empty Assembly.Location
- CSScript.GlobalSettings.InMemoryAssembly = false;
-
- ICalc calc = CSScript.LoadCode(@"using CSScriptNativeApi;
- public class Script
- {
- public int Sum(int a, int b)
- {
- if(Host != null)
- Host.Log(""Sum is invoked"");
- return a + b;
- }
-
- public HostApp Host { get; set; }
- }")
- .CreateObject("*")
- .AlignToInterface();
- calc.Host = host;
- int result = calc.Sum(1, 2);
- }
-
- public static void ExecuteAndUnload()
- {
- // The script will be loaded into a temporary AppDomain and unloaded after the execution.
-
- // Note: remote execution is a subject of some restrictions associated with the nature of the
- // CLR cross-AppDomain interaction model:
- // * the script class must be serializable or derived from MarshalByRefObject.
- //
- // * any object (call arguments, return objects) that crosses ApPDomain boundaries
- // must be serializable or derived from MarshalByRefObject.
- //
- // * long living script class instances may get disposed in remote domain even if they are
- // being referenced in the current AppDomain. You need to use the usual .NET techniques
- // to prevent that. See LifetimeManagement.cs sample for details.
-
- //This use-case uses Interface Alignment and this requires all assemblies involved to have
- //non-empty Assembly.Location
- CSScript.GlobalSettings.InMemoryAssembly = false;
-
- var code = @"using System;
- public class Script : MarshalByRefObject
- {
- public void Hello(string greeting)
- {
- Console.WriteLine(greeting);
- }
- }";
-
- //Note: usage of helper.CreateAndAlignToInterface("Script") is also acceptable
- using (var helper = new AsmHelper(CSScript.CompileCode(code), null, deleteOnExit: true))
- {
- IScript script = helper.CreateAndAlignToInterface("*");
- script.Hello("Hi there...");
- }
- //from this point AsmHelper is disposed and the temp AppDomain is unloaded
- }
-
- public static void DebugTest()
- {
- //pops up an assertion dialog
- dynamic script = CSScript.LoadCode(@"using System;
- using System.Diagnostics;
- public class Script
- {
- public int Sum(int a, int b)
- {
- Debug.Assert(false,""Testing CS-Script debugging..."");
- return a+b;
- }
- }", null, debugBuild: true).CreateObject("*");
-
- int result = script.Sum(1, 2);
- }
- }
-
- public void Log(string message)
- {
- Console.WriteLine(message);
- }
- }
-
- public interface IScript
- {
- void Hello(string greeting);
- }
-
- public interface ICalc
- {
- HostApp Host { get; set; }
-
- int Sum(int a, int b);
- }
-
- public class Samples
- {
- static public void CompilingHistory()
- {
- string script = Path.GetTempFileName();
- string scriptAsm = script + ".dll";
- CSScript.KeepCompilingHistory = true;
-
- try
- {
- File.WriteAllText(script, @"using System;
- using System.Windows.Forms;
- public class Script
- {
- public int Sum(int a, int b)
- {
- return a+b;
- }
- }");
-
-
-
- CSScript.CompileFile(script, scriptAsm, false, null);
-
- CompilingInfo info = CSScript.CompilingHistory
- .Values
- .FirstOrDefault(item => item.ScriptFile == script);
- if (info != null)
- {
- Console.WriteLine("Script: " + info.ScriptFile);
-
- Console.WriteLine("Referenced assemblies:");
- foreach (string asm in info.Input.ReferencedAssemblies)
- Console.WriteLine(asm);
-
- if (info.Result.Errors.HasErrors)
- {
- foreach (CompilerError err in info.Result.Errors)
- if (!err.IsWarning)
- Console.WriteLine("Error: " + err.ErrorText);
- }
- }
-
- CSScript.CompilingHistory.Clear();
-
- }
- finally
- {
- CSScript.KeepCompilingHistory = false;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/src/Artemis.Core/Services/PluginService.cs b/src/Artemis.Core/Services/PluginService.cs
index cade01e89..8473f0ffc 100644
--- a/src/Artemis.Core/Services/PluginService.cs
+++ b/src/Artemis.Core/Services/PluginService.cs
@@ -2,15 +2,12 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
-using System.Linq;
using System.Threading.Tasks;
using Artemis.Core.Events;
using Artemis.Core.Exceptions;
using Artemis.Core.Services.Interfaces;
using Artemis.Plugins.Interfaces;
using Artemis.Plugins.Models;
-using CSScriptLibrary;
-using Newtonsoft.Json;
using Ninject;
namespace Artemis.Core.Services
@@ -24,7 +21,7 @@ namespace Artemis.Core.Services
{
_kernel = kernel;
_plugins = new List();
-
+
if (!Directory.Exists(Constants.DataFolder + "plugins"))
Directory.CreateDirectory(Constants.DataFolder + "plugins");
}
@@ -41,12 +38,18 @@ namespace Artemis.Core.Services
OnStartedLoadingPlugins();
// Empty the list of plugins
+ foreach (var pluginInfo in _plugins)
+ pluginInfo.Dispose();
_plugins.Clear();
+ // Load all built-in plugins
+ foreach (var builtInPlugin in _kernel.GetAll())
+ _plugins.Add(PluginInfo.FromBuiltInPlugin(_kernel, builtInPlugin));
+
// Iterate all plugin folders and load each plugin
foreach (var directory in Directory.GetDirectories(Constants.DataFolder + "plugins"))
- _plugins.Add(await LoadPluginFromFolder(directory));
-
+ _plugins.Add(await PluginInfo.FromFolder(_kernel, directory));
+
OnFinishedLoadedPlugins();
}
@@ -57,44 +60,15 @@ namespace Artemis.Core.Services
public async Task GetModuleViewModel(PluginInfo pluginInfo)
{
- // Don't attempt to locave VMs for something other than a module
- if (pluginInfo.Plugin is IModule)
- throw new ArtemisPluginException(pluginInfo, "Cannot locate a view model for this plugin as it's not a module.");
- // Compile the ViewModel and get the type
- var compile = await Task.Run(() => CSScript.LoadFile(pluginInfo.Folder + pluginInfo.ViewModel));
- var vmType = compile.ExportedTypes.FirstOrDefault(t => typeof(IModuleViewModel).IsAssignableFrom(t));
- if (vmType == null)
- throw new ArtemisPluginException(pluginInfo, "Cannot locate a view model for this module.");
-
- // Instantiate the ViewModel with Ninject
- var vm = (IModuleViewModel) _kernel.Get(vmType);
- vm.PluginInfo = pluginInfo;
- return vm;
+ return await pluginInfo.GetModuleViewModel(_kernel);
}
-
+
public void Dispose()
{
}
- private async Task LoadPluginFromFolder(string folder)
- {
- if (!folder.EndsWith("\\"))
- folder += "\\";
- if (!File.Exists(folder + "plugin.json"))
- throw new ArtemisPluginException(null, "Failed to load plugin, no plugin.json found in " + folder);
-
- var pluginInfo = JsonConvert.DeserializeObject(File.ReadAllText(folder + "plugin.json"));
- pluginInfo.Folder = folder;
-
- // Load the main plugin which will contain a class implementing IPlugin
- var plugin = await CSScript.Evaluator.LoadFileAsync(folder + pluginInfo.Main);
- pluginInfo.Plugin = plugin;
-
- return pluginInfo;
- }
-
#region Events
-
+
public event EventHandler PluginLoaded;
public event EventHandler PluginReloaded;
public event EventHandler StartedLoadingPlugins;
diff --git a/src/Artemis.Core/Services/RgbService.cs b/src/Artemis.Core/Services/RgbService.cs
index c71d5fb97..8d65c2bf1 100644
--- a/src/Artemis.Core/Services/RgbService.cs
+++ b/src/Artemis.Core/Services/RgbService.cs
@@ -5,9 +5,14 @@ using Artemis.Core.Events;
using Artemis.Core.Services.Interfaces;
using RGB.NET.Brushes;
using RGB.NET.Core;
+using RGB.NET.Devices.Asus;
using RGB.NET.Devices.CoolerMaster;
using RGB.NET.Devices.Corsair;
+using RGB.NET.Devices.DMX;
using RGB.NET.Devices.Logitech;
+using RGB.NET.Devices.Msi;
+using RGB.NET.Devices.Novation;
+using RGB.NET.Devices.Razer;
using RGB.NET.Groups;
namespace Artemis.Core.Services
@@ -38,24 +43,18 @@ namespace Artemis.Core.Services
await Task.Run(() =>
{
// TODO SpoinkyNL 8-1-18: Keep settings into account
- // Surface.LoadDevices(AsusDeviceProvider.Instance);
- Surface.LoadDevices(CorsairDeviceProvider.Instance);
- Surface.LoadDevices(LogitechDeviceProvider.Instance);
+ Surface.LoadDevices(AsusDeviceProvider.Instance);
Surface.LoadDevices(CoolerMasterDeviceProvider.Instance);
- // Surface.LoadDevices(NovationDeviceProvider.Instance);
+ Surface.LoadDevices(CorsairDeviceProvider.Instance);
+ Surface.LoadDevices(DMXDeviceProvider.Instance);
+ Surface.LoadDevices(LogitechDeviceProvider.Instance);
+ Surface.LoadDevices(NovationDeviceProvider.Instance);
+ Surface.LoadDevices(MsiDeviceProvider.Instance);
+ Surface.LoadDevices(RazerDeviceProvider.Instance);
// TODO SpoinkyNL 8-1-18: Load alignment
Surface.AlignDevices();
- // Do some testing, why does this work, how does it know I want to target the surface? Check source!
- var mouse1 = Surface.Leds.First(l => l.Id == LedId.Mouse1);
- mouse1.Color = new Color(255, 0, 0);
- var mouse2 = Surface.Leds.First(l => l.Id == LedId.Mouse2);
- mouse2.Color = new Color(255, 255, 0);
- var mouse3 = Surface.Leds.First(l => l.Id == LedId.Mouse3);
- mouse3.Color = new Color(255, 255, 255);
- var mouse4 = Surface.Leds.First(l => l.Id == LedId.Mouse4);
- mouse4.Color = new Color(255, 0, 255);
Surface.UpdateMode = UpdateMode.Continuous;
});
diff --git a/src/Artemis.Core/app.config b/src/Artemis.Core/app.config
index 64c2d2698..9153e89c8 100644
--- a/src/Artemis.Core/app.config
+++ b/src/Artemis.Core/app.config
@@ -63,6 +63,10 @@
+
+
+
+
\ No newline at end of file
diff --git a/src/Artemis.Core/packages.config b/src/Artemis.Core/packages.config
index 12d122c88..04fdc42e2 100644
--- a/src/Artemis.Core/packages.config
+++ b/src/Artemis.Core/packages.config
@@ -1,14 +1,10 @@
-
-
-
-
diff --git a/src/Artemis.Plugins/Artemis.Plugins.csproj b/src/Artemis.Plugins/Artemis.Plugins.csproj
index 9c2269b82..7c4afe364 100644
--- a/src/Artemis.Plugins/Artemis.Plugins.csproj
+++ b/src/Artemis.Plugins/Artemis.Plugins.csproj
@@ -30,6 +30,24 @@
4
+
+ ..\packages\CS-Script.bin.3.28.0.1\lib\net46\CSScriptLibrary.dll
+
+
+ ..\packages\Microsoft.CodeAnalysis.Common.2.0.0\lib\netstandard1.3\Microsoft.CodeAnalysis.dll
+
+
+ ..\packages\Microsoft.CodeAnalysis.CSharp.2.0.0\lib\netstandard1.3\Microsoft.CodeAnalysis.CSharp.dll
+
+
+ ..\packages\Microsoft.CodeAnalysis.CSharp.Scripting.2.0.0\lib\netstandard1.3\Microsoft.CodeAnalysis.CSharp.Scripting.dll
+
+
+ ..\packages\Microsoft.CodeAnalysis.Scripting.Common.2.0.0\lib\netstandard1.3\Microsoft.CodeAnalysis.Scripting.dll
+
+
+ ..\packages\CS-Script.bin.3.28.0.1\lib\net46\Mono.CSharp.dll
+
..\packages\Newtonsoft.Json.11.0.1\lib\net45\Newtonsoft.Json.dll
@@ -40,16 +58,84 @@
..\packages\Stylet.1.1.21\lib\net45\Stylet.dll
+
+ ..\packages\System.AppContext.4.3.0\lib\net46\System.AppContext.dll
+ True
+
+
+ ..\packages\System.Collections.Immutable.1.3.1\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll
+ True
+
+
+
+ ..\packages\System.Console.4.3.0\lib\net46\System.Console.dll
+
+
+ ..\packages\System.Diagnostics.FileVersionInfo.4.3.0\lib\net46\System.Diagnostics.FileVersionInfo.dll
+
+
+ ..\packages\System.Diagnostics.StackTrace.4.3.0\lib\net46\System.Diagnostics.StackTrace.dll
+
+
+ ..\packages\System.IO.Compression.4.3.0\lib\net46\System.IO.Compression.dll
+ True
+
+
+ ..\packages\System.IO.FileSystem.4.3.0\lib\net46\System.IO.FileSystem.dll
+
+
+ ..\packages\System.IO.FileSystem.Primitives.4.3.0\lib\net46\System.IO.FileSystem.Primitives.dll
+
+
+
+ ..\packages\System.Reflection.Metadata.1.4.2\lib\portable-net45+win8\System.Reflection.Metadata.dll
+
+
+ ..\packages\System.Security.Cryptography.Algorithms.4.3.0\lib\net46\System.Security.Cryptography.Algorithms.dll
+ True
+
+
+ ..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll
+
+
+ ..\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll
+
+
+ ..\packages\System.Security.Cryptography.X509Certificates.4.3.0\lib\net46\System.Security.Cryptography.X509Certificates.dll
+ True
+
+
+ ..\packages\System.Text.Encoding.CodePages.4.3.0\lib\net46\System.Text.Encoding.CodePages.dll
+
+
+ ..\packages\System.Threading.Thread.4.3.0\lib\net46\System.Threading.Thread.dll
+
+
+ ..\packages\System.ValueTuple.4.3.0\lib\netstandard1.0\System.ValueTuple.dll
+
+
+ ..\packages\System.Xml.ReaderWriter.4.3.0\lib\net46\System.Xml.ReaderWriter.dll
+
+
+ ..\packages\System.Xml.XmlDocument.4.3.0\lib\net46\System.Xml.XmlDocument.dll
+
+
+ ..\packages\System.Xml.XPath.4.3.0\lib\net46\System.Xml.XPath.dll
+
+
+ ..\packages\System.Xml.XPath.XDocument.4.3.0\lib\net46\System.Xml.XPath.XDocument.dll
+
+
@@ -60,7 +146,12 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Artemis.Plugins/Exceptions/ArtemisPluginException.cs b/src/Artemis.Plugins/Exceptions/ArtemisPluginException.cs
new file mode 100644
index 000000000..7a56fd56d
--- /dev/null
+++ b/src/Artemis.Plugins/Exceptions/ArtemisPluginException.cs
@@ -0,0 +1,25 @@
+using System;
+using Artemis.Plugins.Models;
+
+namespace Artemis.Plugins.Exceptions
+{
+ public class ArtemisPluginException : Exception
+ {
+ public ArtemisPluginException(PluginInfo pluginInfo)
+ {
+ PluginInfo = pluginInfo;
+ }
+
+ public ArtemisPluginException(PluginInfo pluginInfo, string message) : base(message)
+ {
+ PluginInfo = pluginInfo;
+ }
+
+ public ArtemisPluginException(PluginInfo pluginInfo, string message, Exception inner) : base(message, inner)
+ {
+ PluginInfo = pluginInfo;
+ }
+
+ public PluginInfo PluginInfo { get; }
+ }
+}
\ No newline at end of file
diff --git a/src/Artemis.Plugins/Models/PluginInfo.cs b/src/Artemis.Plugins/Models/PluginInfo.cs
index f4819a1dc..6a1beb21a 100644
--- a/src/Artemis.Plugins/Models/PluginInfo.cs
+++ b/src/Artemis.Plugins/Models/PluginInfo.cs
@@ -1,9 +1,18 @@
-using Artemis.Plugins.Interfaces;
+using System;
+using System.Diagnostics;
+using System.IO;
+using System.Linq;
+using System.Reflection;
+using System.Threading.Tasks;
+using Artemis.Plugins.Exceptions;
+using Artemis.Plugins.Interfaces;
+using CSScriptLibrary;
using Newtonsoft.Json;
+using Ninject;
namespace Artemis.Plugins.Models
{
- public class PluginInfo
+ public class PluginInfo : IDisposable
{
///
/// The name of the plugin
@@ -36,5 +45,53 @@ namespace Artemis.Plugins.Models
///
[JsonIgnore]
public string Folder { get; set; }
+
+ ///
+ /// Indicates wether this is a built-in plugin. Built-in plugins are precompiled and have no files
+ ///
+ [JsonIgnore]
+ public bool IsBuiltIn { get; private set; }
+
+ public static async Task FromFolder(IKernel kernel, string folder)
+ {
+ if (!folder.EndsWith("\\"))
+ folder += "\\";
+ if (!File.Exists(folder + "plugin.json"))
+ throw new ArtemisPluginException(null, "Failed to load plugin, no plugin.json found in " + folder);
+
+ var pluginInfo = JsonConvert.DeserializeObject(File.ReadAllText(folder + "plugin.json"));
+ pluginInfo.Folder = folder;
+
+ // Load the main plugin which will contain a class implementing IPlugin
+ var assembly = await CSScript.Evaluator.CompileCodeAsync(File.ReadAllText(folder + pluginInfo.Main));
+ var pluginType = assembly.GetTypes().Where(t => typeof(IPlugin).IsAssignableFrom(t)).ToList();
+ if (!pluginType.Any())
+ throw new ArtemisPluginException(pluginInfo, "Failed to load plugin, no type found that implements IPlugin");
+ if (pluginType.Count > 1)
+ throw new ArtemisPluginException(pluginInfo, "Failed to load plugin, more than one type found that implements IPlugin");
+
+ pluginInfo.Plugin = (IPlugin) kernel.Get(pluginType.First());
+ pluginInfo.Plugin.LoadPlugin();
+
+ return pluginInfo;
+ }
+
+ public static PluginInfo FromBuiltInPlugin(IKernel kernel, IPlugin builtInPlugin)
+ {
+ var pluginInfo = new PluginInfo
+ {
+ Name = builtInPlugin.GetType().Name,
+ Version = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).ProductVersion,
+ Plugin = builtInPlugin,
+ IsBuiltIn = true
+ };
+ pluginInfo.Plugin.LoadPlugin();
+
+ return pluginInfo;
+ }
+
+ public void Dispose()
+ {
+ }
}
}
\ No newline at end of file
diff --git a/src/Artemis.Plugins/app.config b/src/Artemis.Plugins/app.config
new file mode 100644
index 000000000..c27651ac4
--- /dev/null
+++ b/src/Artemis.Plugins/app.config
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Artemis.Plugins/packages.config b/src/Artemis.Plugins/packages.config
index ba9e759e2..10d6362ad 100644
--- a/src/Artemis.Plugins/packages.config
+++ b/src/Artemis.Plugins/packages.config
@@ -1,6 +1,54 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Artemis.UI/App.config b/src/Artemis.UI/App.config
index 2b8f64876..46ebf0007 100644
--- a/src/Artemis.UI/App.config
+++ b/src/Artemis.UI/App.config
@@ -66,6 +66,10 @@
+
+
+
+
\ No newline at end of file
diff --git a/src/Artemis.UI/App.xaml b/src/Artemis.UI/App.xaml
index e024b2889..4f4a062fc 100644
--- a/src/Artemis.UI/App.xaml
+++ b/src/Artemis.UI/App.xaml
@@ -30,12 +30,6 @@
-
-
-
-
diff --git a/src/Artemis.UI/Artemis.UI.csproj b/src/Artemis.UI/Artemis.UI.csproj
index ffb9add02..20f4899bd 100644
--- a/src/Artemis.UI/Artemis.UI.csproj
+++ b/src/Artemis.UI/Artemis.UI.csproj
@@ -69,61 +69,47 @@
..\packages\PropertyChanged.Fody.2.2.6\lib\net452\PropertyChanged.dll
-
+
..\packages\RGB.NET.Brushes.0.0.1.38\lib\net45\RGB.NET.Brushes.dll
- True
-
+
..\packages\RGB.NET.Core.0.0.1.38\lib\net45\RGB.NET.Core.dll
- True
-
+
..\packages\RGB.NET.Decorators.0.0.1.38\lib\net45\RGB.NET.Decorators.dll
- True
-
+
..\packages\RGB.NET.Devices.Asus.0.0.1.38\lib\net45\RGB.NET.Devices.Asus.dll
- True
-
+
..\packages\RGB.NET.Devices.CoolerMaster.0.0.1.38\lib\net45\RGB.NET.Devices.CoolerMaster.dll
- True
-
+
..\packages\RGB.NET.Devices.Corsair.0.0.1.38\lib\net45\RGB.NET.Devices.Corsair.dll
- True
-
+
..\packages\RGB.NET.Devices.DMX.0.0.1.38\lib\net45\RGB.NET.Devices.DMX.dll
- True
-
+
..\packages\RGB.NET.Devices.Logitech.0.0.1.38\lib\net45\RGB.NET.Devices.Logitech.dll
- True
-
+
..\packages\RGB.NET.Devices.Msi.0.0.1.38\lib\net45\RGB.NET.Devices.Msi.dll
- True
-
+
..\packages\RGB.NET.Devices.Novation.0.0.1.38\lib\net45\RGB.NET.Devices.Novation.dll
- True
-
+
..\packages\RGB.NET.Devices.Razer.0.0.1.38\lib\net45\RGB.NET.Devices.Razer.dll
- True
-
+
..\packages\RGB.NET.Groups.0.0.1.38\lib\net45\RGB.NET.Groups.dll
- True
-
+
..\packages\RGB.NET.Input.0.0.1.38\lib\net45\RGB.NET.Input.dll
- True
-
+
..\packages\RGB.NET.Input.Corsair.0.0.1.38\lib\net45\RGB.NET.Input.Corsair.dll
- True
..\packages\Sanford.Multimedia.Midi.6.6.0\lib\net20\Sanford.Multimedia.Midi.dll
@@ -261,23 +247,23 @@
+
This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
-
+
-
+
-
-
-
+
+
\ No newline at end of file
diff --git a/src/Module.General/GeneralModule.cs b/src/Module.General/GeneralModule.cs
new file mode 100644
index 000000000..960921fa0
--- /dev/null
+++ b/src/Module.General/GeneralModule.cs
@@ -0,0 +1,28 @@
+using System;
+using Artemis.Plugins.Interfaces;
+
+namespace Artemis.BuiltIn.Module.General
+{
+ public class GeneralModule : IModule
+ {
+ public void LoadPlugin()
+ {
+ throw new NotImplementedException();
+ }
+
+ public void UnloadPlugin()
+ {
+ throw new NotImplementedException();
+ }
+
+ public void Update(double deltaTime)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void Render(double deltaTime)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Module.General/GeneralView.xaml b/src/Module.General/GeneralView.xaml
new file mode 100644
index 000000000..05e2774f6
--- /dev/null
+++ b/src/Module.General/GeneralView.xaml
@@ -0,0 +1,12 @@
+
+
+
+
+
diff --git a/src/Module.General/GeneralView.xaml.cs b/src/Module.General/GeneralView.xaml.cs
new file mode 100644
index 000000000..f8f249854
--- /dev/null
+++ b/src/Module.General/GeneralView.xaml.cs
@@ -0,0 +1,15 @@
+using System.Windows.Controls;
+
+namespace Artemis.BuiltIn.Module.General
+{
+ ///
+ /// Interaction logic for GeneralView.xaml
+ ///
+ public partial class GeneralView : UserControl
+ {
+ public GeneralView()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/src/Module.General/GeneralViewModel.cs b/src/Module.General/GeneralViewModel.cs
new file mode 100644
index 000000000..6a169469a
--- /dev/null
+++ b/src/Module.General/GeneralViewModel.cs
@@ -0,0 +1,6 @@
+namespace Artemis.BuiltIn.Module.General
+{
+ public class GeneralViewModel
+ {
+ }
+}
\ No newline at end of file
diff --git a/src/Module.General/Module.General.csproj b/src/Module.General/Module.General.csproj
new file mode 100644
index 000000000..919ad00c0
--- /dev/null
+++ b/src/Module.General/Module.General.csproj
@@ -0,0 +1,69 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {58113CC5-A9CA-4EC3-AB4E-3C94B99268D8}
+ Library
+ Properties
+ Artemis.BuiltIn.Module.General
+ Module.General
+ v4.6.1
+ 512
+
+
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ GeneralView.xaml
+
+
+
+
+
+
+ {CD23BC5E-57F0-46CE-A007-24D031146219}
+ Artemis.Plugins
+
+
+
+
+ Designer
+ MSBuild:Compile
+
+
+
+
\ No newline at end of file
diff --git a/src/Module.General/Properties/AssemblyInfo.cs b/src/Module.General/Properties/AssemblyInfo.cs
new file mode 100644
index 000000000..f07413909
--- /dev/null
+++ b/src/Module.General/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("Module.General")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Module.General")]
+[assembly: AssemblyCopyright("Copyright © 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("58113cc5-a9ca-4ec3-ab4e-3c94b99268d8")]
+
+// 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/src/Module.General/app.config b/src/Module.General/app.config
new file mode 100644
index 000000000..c27651ac4
--- /dev/null
+++ b/src/Module.General/app.config
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/TestModule/TestModuleView.xaml b/src/TestModule/GeneralView.xaml
similarity index 100%
rename from src/TestModule/TestModuleView.xaml
rename to src/TestModule/GeneralView.xaml
diff --git a/src/TestModule/TestModuleViewModel.cs b/src/TestModule/GeneralViewModel.cs
similarity index 100%
rename from src/TestModule/TestModuleViewModel.cs
rename to src/TestModule/GeneralViewModel.cs