From 8c7b7d9db43bd73383f32e850b0c2fba5257c2b7 Mon Sep 17 00:00:00 2001 From: Thomas Fuchs Date: Wed, 6 Oct 2021 10:18:04 +0200 Subject: [PATCH] Interface for application runtime with accessible container --- src/Moryx.Runtime.Kernel/HeartOfGold.cs | 18 +++++++++++------- src/Moryx/IApplicationRuntime.cs | 18 ++++++++++++++++++ 2 files changed, 29 insertions(+), 7 deletions(-) create mode 100644 src/Moryx/IApplicationRuntime.cs diff --git a/src/Moryx.Runtime.Kernel/HeartOfGold.cs b/src/Moryx.Runtime.Kernel/HeartOfGold.cs index 9d317fcb0..2ef2af780 100644 --- a/src/Moryx.Runtime.Kernel/HeartOfGold.cs +++ b/src/Moryx.Runtime.Kernel/HeartOfGold.cs @@ -19,7 +19,7 @@ namespace Moryx.Runtime.Kernel /// /// Base kernel loader for the runtime /// - public class HeartOfGold + public class HeartOfGold : IApplicationRuntime { private string[] _args; @@ -27,19 +27,17 @@ public class HeartOfGold /// Current global container /// private IContainer _container; + + /// + public IContainer GlobalContainer => _container; + /// /// Creates an instance of the /// public HeartOfGold(string[] args) { PrepareArguments(args); - } - /// - /// Starts the runtime - /// - public RuntimeErrorCode Run() - { // Set working directory to location of this exe // ReSharper disable once AssignNullToNotNullAttribute Directory.SetCurrentDirectory(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)); @@ -55,7 +53,13 @@ public RuntimeErrorCode Run() // Prepare container _container = CreateContainer(); + } + /// + /// Starts the runtime + /// + public RuntimeErrorCode Run() + { // Load and run environment var loadResult = LoadEnvironment(out var env); var returnCode = RuntimeErrorCode.NoError; diff --git a/src/Moryx/IApplicationRuntime.cs b/src/Moryx/IApplicationRuntime.cs new file mode 100644 index 000000000..63781b9a9 --- /dev/null +++ b/src/Moryx/IApplicationRuntime.cs @@ -0,0 +1,18 @@ +// Copyright (c) 2021, Phoenix Contact GmbH & Co. KG +// Licensed under the Apache License, Version 2.0 + +using Moryx.Container; + +namespace Moryx +{ + /// + /// Interface for application executables like HeartOfGold or HeartOfLead + /// + public interface IApplicationRuntime + { + /// + /// Top Level container + /// + IContainer GlobalContainer { get; } + } +} \ No newline at end of file