Skip to content

Commit

Permalink
Interface for application runtime with accessible container
Browse files Browse the repository at this point in the history
  • Loading branch information
Toxantron committed Oct 6, 2021
1 parent 7607f51 commit 8c7b7d9
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/Moryx.Runtime.Kernel/HeartOfGold.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,25 @@ namespace Moryx.Runtime.Kernel
/// <summary>
/// Base kernel loader for the runtime
/// </summary>
public class HeartOfGold
public class HeartOfGold : IApplicationRuntime
{
private string[] _args;

/// <summary>
/// Current global container
/// </summary>
private IContainer _container;

/// <inheritdoc />
public IContainer GlobalContainer => _container;

/// <summary>
/// Creates an instance of the <see cref="HeartOfGold"/>
/// </summary>
public HeartOfGold(string[] args)
{
PrepareArguments(args);
}

/// <summary>
/// Starts the runtime
/// </summary>
public RuntimeErrorCode Run()
{
// Set working directory to location of this exe
// ReSharper disable once AssignNullToNotNullAttribute
Directory.SetCurrentDirectory(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location));
Expand All @@ -55,7 +53,13 @@ public RuntimeErrorCode Run()

// Prepare container
_container = CreateContainer();
}

/// <summary>
/// Starts the runtime
/// </summary>
public RuntimeErrorCode Run()
{
// Load and run environment
var loadResult = LoadEnvironment(out var env);
var returnCode = RuntimeErrorCode.NoError;
Expand Down
18 changes: 18 additions & 0 deletions src/Moryx/IApplicationRuntime.cs
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>
/// Interface for application executables like HeartOfGold or HeartOfLead
/// </summary>
public interface IApplicationRuntime
{
/// <summary>
/// Top Level container
/// </summary>
IContainer GlobalContainer { get; }
}
}

0 comments on commit 8c7b7d9

Please sign in to comment.