Пример #1
0
        protected override void RegisterTypes(IContainerRegistry containerRegistry)
        {
            #region Log
            var config  = new NLog.Config.LoggingConfiguration();
            var logfile = new NLog.Targets.FileTarget("logfile")
            {
                FileName = "log/file.txt"
            };
            config.AddRule(NLog.LogLevel.Debug, NLog.LogLevel.Fatal, logfile);
            NLog.LogManager.Configuration = config;

            var factory = new NLog.Extensions.Logging.NLogLoggerFactory();
            Microsoft.Extensions.Logging.ILogger logger = factory.CreateLogger("");

            containerRegistry.RegisterInstance <Microsoft.Extensions.Logging.ILogger>(logger);

            var log = Container.Resolve <Microsoft.Extensions.Logging.ILogger>();
            log.LogInformation("Test in RegisterTypes");
            #endregion

            //containerRegistry.RegisterInstance(typeof(ILocalizerService),
            //    "LocalizerService",
            //        new LocalizerService("zh-TW"),
            //            new ContainerControlledLifetimeManager());
            //containerRegistry.RegisterInstance<ILocalizerService, LocalizerService("zh-TW")>(new ContainerControlledLifetimeManager());
            containerRegistry.RegisterSingleton <ILocalizerService, LocalizerService>();

            containerRegistry.RegisterSingleton <IMessageService, MessageService>();

            containerRegistry.RegisterSingleton <IApplicationCommands, ApplicationCommandsProxy>();
            containerRegistry.RegisterInstance <IFlyoutService>(Container.Resolve <FlyoutService>());
        }
Пример #2
0
        public GenericLogger()
        {
            var lg  = new NLog.Extensions.Logging.NLogLoggerFactory();
            var lgg = lg.CreateLogger("");

            _logger = lgg;
        }