You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

dependency_module.cs 831 B

123456789101112131415161718192021222324252627282930
  1. public class DatabaseModule : ModuleBase<SocketCommandContext>
  2. {
  3. private readonly DatabaseService _database;
  4. // Dependencies can be injected via the constructor
  5. public DatabaseModule(DatabaseService database)
  6. {
  7. _database = database;
  8. }
  9. [Command("read")]
  10. public async Task ReadFromDbAsync()
  11. {
  12. await ReplyAsync(_database.GetData());
  13. }
  14. }
  15. public class MixModule : ModuleBase<SocketCommandContext>
  16. {
  17. // Public settable properties will be injected
  18. public AnnounceService AnnounceService { get; set; }
  19. // Public properties without setters will not be injected
  20. public ImageService ImageService { get; }
  21. // Public properties annotated with [DontInject] will not
  22. // be injected
  23. [DontInject]
  24. public NotificationService NotificationService { get; set; }
  25. }