コード例 #1
0
ファイル: StartupBase.cs プロジェクト: base2art/soufflot
        private ILogger GetLogger(IApplication application)
        {
            var loggerFactory = application.CreateInstance(Class.GetClass <ILogger>(), true);

            if (loggerFactory != null)
            {
                return(loggerFactory);
            }
            var loggerFactoryClassName = application.ConfigurationValue(CommonSettings.LoggerFactoryClassNameKey);

            if (!string.IsNullOrWhiteSpace(loggerFactoryClassName))
            {
                try
                {
                    var factory = application.CreateInstance(Type.GetType(loggerFactoryClassName, false).GetClass().As <IRequestLoggerFactory>(), true);
                    if (factory != null)
                    {
                        var  logLevel = application.ConfigurationValue(CommonSettings.LogLevelKey);
                        byte logLevelByte;
                        if (!byte.TryParse(logLevel, out logLevelByte))
                        {
                            logLevelByte = 0x00;
                        }
                        return(factory.Create(new LogLevel(logLevelByte, "Default", "Default")) ?? new NullLogger());
                    }
                }
                catch (Exception)
                {
                }
            }
            return(new NullLogger());
        }
コード例 #2
0
ファイル: StartupBase.cs プロジェクト: base2art/soufflot
        private string GetSalt(IApplication application)
        {
            var salt = application.ConfigurationValue(CommonSettings.SaltKey);

            if (string.IsNullOrWhiteSpace(salt))
            {
                throw new ApplicationException("You must set the salt in the configruation 'soufflot:salt'");
            }
            return(salt);
        }