Пример #1
0
        public BotClient(IDependencyFactory factory, Action <IDependencyFactory> mapper)
        {
            Owner             = new Lazy <IUser>(() => DiscordClient.GetApplicationInfoAsync().Result.Owner);
            mapper            = mapper ?? (f => { });
            DependencyFactory = factory ?? new DependencyFactory();
            MapDefaults();
            mapper(DependencyFactory);

            Logger = DependencyFactory.GetOrStore <ILogger>();
            DependencyFactory.GetOrStore <IDownloader>();
            DependencyFactory.GetOrStore <IReplier>();
            DependencyFactory.GetOrStore <ValueFormatter>();
            Database        = DependencyFactory.GetOrStore <IDatabase>();
            SettingsManager = DependencyFactory.GetOrStore <ISettingManager>();
            DependencyFactory.GetOrStore <IPermissionManager>();
            DiscordClient       = DependencyFactory.GetOrStore <DiscordSocketClient>();
            TypeReaders         = DependencyFactory.GetOrStore <ITypeReaderCollection>();
            Scheduler           = DependencyFactory.GetOrStore <IScheduler>();
            CommandService      = DependencyFactory.GetOrStore <ICommandService>();
            TextResourceManager = DependencyFactory.GetOrStore <ITextResourceManager>();

            SetupFeatures();
            InstallSettingEditors();
            SubscribeEvents();

            InstallHandlers(Assembly.GetExecutingAssembly());
        }