Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How can I access components in my module in the `IServerModuleConsole`

I have a MORYX module with a facade and some components. In my ModuleConsole I would like to access, either the facade or one of the internal components, to access functionality of the module. I tried to rely on property injection, but the property does not get filled. Is there a way to access the module or its facade from the ModuleConsole?

Example

[ServerModuleConsole]
public class ModuleConsole : IServerModuleConsole
{
    /// Injected Facade
    public ISomeFacade Facade { get; set; }

    /// Injected component (does not compile because of inconsistent accessibility)
    public ISomeComponent Component { get; set; }

    [EntrySerialize]
    public void SomeFunction() => Facade.SomeFunction();
}

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Componets from your internal container should get injected, the facade or the module not as they are on a different level in the hierarchy.

Usually you would not need the facade in your console, since the facade itsself should only call internal components like your console.

So:

public class MyFacade : IMyFacade
{
  public ISomeComponent Component { get; set; }

  public void Foo() => Component.Foo();
}

public class MyConsole : IServerModuleConsole
{
  public ISomeComponent Component { get; set; }

  [EntrySerialize]
  public void Foo() => Component.Foo();

}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading