Example #1
0
 public static void InitializeContainer(ApplicationSettings settings = null)
 {
     container = new Container(c =>
     {
         // c.For<UserIssueRepository>().Use<UserIssueDatabaseRepository>();
         // c.ForSingletonOf<ConnectionService>().UseIfNone<DiscordConnectionService>();
         // c.ForSingletonOf<DiscordSocketClient>().UseIfNone<DiscordSocketClient>();
         c.ForSingletonOf <Logger>().UseIfNone <Logger>();
         c.ForSingletonOf <TriviaGame>().UseIfNone <TriviaGame>();
         c.ForSingletonOf <DiscordEventHandler>().UseIfNone <DiscordEventHandler>();
         c.ForSingletonOf <CommandHandler>().UseIfNone <CommandHandler>();
         c.ForSingletonOf <CommandService>().UseIfNone <CommandService>();
         c.ForSingletonOf <DiscordSocketClient>().UseIfNone(DiscordClientFactory.GetBySettings(settings));
         c.ForSingletonOf <ApplicationSettings>().UseIfNone(settings);
     });
 }
 public static void InitializeContainer(ApplicationSettings settings = null)
 {
     container = new Container(c =>
     {
         // c.For<UserIssueRepository>().Use<UserIssueDatabaseRepository>();
         // c.ForSingletonOf<ConnectionService>().UseIfNone<DiscordConnectionService>();
         // c.ForSingletonOf<DiscordSocketClient>().UseIfNone<DiscordSocketClient>();
         c.ForSingletonOf <Logger>().UseIfNone <Logger>();
         c.ForSingletonOf <TriviaGames>().UseIfNone <TriviaGames>();
         c.ForSingletonOf <DiscordEventHandler>().UseIfNone <DiscordEventHandler>();
         c.ForSingletonOf <CommandHandler>().UseIfNone <CommandHandler>();
         c.ForSingletonOf <CommandService>().UseIfNone <CommandService>();
         c.ForSingletonOf <DiscordSocketClient>().UseIfNone(DiscordClientFactory.GetBySettings(settings));
         c.ForSingletonOf <ApplicationSettings>().UseIfNone(settings);
         c.ForSingletonOf <IDataStorage>().UseIfNone <JsonDataStorage>();
         c.ForSingletonOf <ListManager>().UseIfNone <ListManager>();
         c.ForSingletonOf <IOnboarding>().UseIfNone <Onboarding>();
         c.ForSingletonOf <Features.Onboarding.Tasks.HelloWorldTask>().UseIfNone <Features.Onboarding.Tasks.HelloWorldTask>();
     });
 }
        private static void ConfigureServices(IServiceCollection serviceCollection, string[] args)
        {
            // no objects are created within this function; nor are any initializers executed
            // BotSettings and ApplicationSettings are created once they are first requested, not before

            serviceCollection.AddSingleton <Logger>();
            serviceCollection.AddSingleton <TriviaGames>();
            serviceCollection.AddSingleton <DiscordEventHandler>();
            serviceCollection.AddSingleton <CommandHandler>();
            serviceCollection.AddSingleton <CommandService>();
            serviceCollection.AddSingleton <ApplicationSettings>((s) =>
            {
                BotSettings botSettings = s.GetRequiredService <BotSettings>();
                return(new ApplicationSettings(args, botSettings));
            });
            serviceCollection.AddSingleton <DiscordSocketClient>((s) =>
            {
                ApplicationSettings appSettings = s.GetRequiredService <ApplicationSettings>();
                return(DiscordClientFactory.GetBySettings(appSettings));
            });
            serviceCollection.AddSingleton <IDataStorage, JsonDataStorage>();
            serviceCollection.AddSingleton <ListManager>();
            serviceCollection.AddSingleton <IOnboarding, Onboarding>();
            serviceCollection.AddSingleton <HelloWorldTask>();
            serviceCollection.AddSingleton <IGlobalUserAccounts, GlobalUserAccounts>();
            serviceCollection.AddSingleton <IDiscordSocketClient, DiscordSocketClientAbstraction>();
            serviceCollection.AddSingleton <IDailyMiunies, Daily>();
            serviceCollection.AddSingleton <IMiuniesTransfer, Transfer>();

            serviceCollection.AddSingleton <BlogHandler>();
            serviceCollection.AddSingleton <GlobalGuildAccounts>();
            serviceCollection.AddSingleton <GlobalUserAccounts>();
            serviceCollection.AddSingleton <Announcements>();
            serviceCollection.AddSingleton <RoleByPhraseProvider>();
            serviceCollection.AddSingleton <MessageRewardHandler>();
            serviceCollection.AddSingleton <RepeatedTaskFunctions>();
            serviceCollection.AddSingleton <BotSettings>();
            serviceCollection.AddSingleton <JsonDataStorage>();
        }