Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Needs to use static instance of sisbase bot to access a system from a command. #3

Open
roridev opened this issue Mar 21, 2021 · 0 comments

Comments

@roridev
Copy link
Member

roridev commented Mar 21, 2021

This is an oversight and an antipattern. The library should integrate the systems using DI seamlessly on SisbaseCommandContext.

It has been discussed countless times, and its a core tenant of the rewrite : to make this version static-less.
Considering cnext::UsesAttribute would stop command execution in case of an unexistent system, and its static-less, doing this should be possible.
As it currrently stands this is the only way to feasibly get a system.

[Uses(typeof(System))]
class CommandClass : ModuleBase<SisbaseCommandContext>  { 
    //Static instance of a sisbase bot stored on the main class. EEEW.
    System s = Program.botInstance.Systems.Get<System>();
}

The idea is to somehow integrate that into SCCTX's funcionality so that DI itself would make it seamless.

[Uses(typeof(System))]
class CommandClass : ModuleBase<SisbaseCommandContext>  { 
    //`s` gets injected using di. nice.
    System s;
}
@roridev roridev added this to Systens in Single File Import Mar 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

No branches or pull requests

1 participant