Пример #1
0
        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
        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);
        }