Exemple #1
0
        public void Initialize()
        {
            var appSetting = AppSetting.GetAppSettings(AppSettingPath);
            var mockLogger = new Mock <ILogger>();

            _fileUpdater = new FileUpdater(appSetting, mockLogger.Object);
        }
        public override void Load()
        {
            var settings = AppSetting.GetAppSettings("appSettings.json");

            Bind <IAppSetting>().ToConstant(settings);
            Bind <IDnsManager>().To <DnsManager>();
            Bind <IFileUpdater>().To <FileUpdater>();
            Bind <ILogger>().To <Logger>()
            .InSingletonScope()
            .WithConstructorArgument("name", "dnsResolver")
            .WithConstructorArgument("logFilePath", settings.LogDir);

            Bind <HttpClient>().ToSelf()
            .InSingletonScope();
        }
        public override void Load()
        {
            var appSetting = AppSetting.GetAppSettings("appSettings.json");

            Bind <IAppSetting>().ToConstant(appSetting)
            .NamedLikeFactoryMethod((IAppFactory f) => f.GetAppSetting());
            Bind <ILogger>().To <Logger>()
            .InSingletonScope()
            .NamedLikeFactoryMethod((IAppFactory f) => f.GetLogger())
            .WithConstructorArgument("name", "updater")
            .WithConstructorArgument("logFilePath", appSetting.LogDir);

            var logger = Kernel.Get <ILogger>();

            Bind <HttpClient>().ToSelf()
            .InSingletonScope()
            .WithConstructorArgument("handler", new LoggingHandler(logger));

            Bind <IAppFactory>().ToFactory();
        }