示例#1
0
        private CurrentHostContext(IHostConfig configuration, ContextSettings settings)
        {
            Audit      = configuration.Runtime.Audit;
            Config     = configuration;
            UserTokens = new List <string>();

            var logger      = LogFactory.CreateInstance(configuration.Runtime.LogInfo);
            var commandArgs = new CommandArgs(configuration.Runtime.Parameters);
            var cache       = CacheFactory.Create(configuration.Caching);

            cache.ItemRemoved += (sender, args) =>
            {
                Log.Debug("Item removed from cache: " + args.CacheKey + " Reason : " + args.RemoveReason);
                if (args.Value is AuthenticationOutput)
                {
                    // User has been removed from cache. Login expired
                    UserTokens.Remove(args.CacheKey);
                }
            };

            CurrentContext.CreateDefault(logger, commandArgs, cache);

            //override the passwords if encrypted
            if (configuration.Certificate.Encryption != null)
            {
                var certificate = configuration.Certificate.Encryption.GetX509Certificate();
                if (certificate != null)
                {
                    DecryptPasswords(configuration, certificate);
                }
            }

            CommandFactory = settings.CommandFactory;
            Provider       = GetDatabaseProviderInstance(configuration);
        }
示例#2
0
        private ClientContext(ClientConfig configuration)
        {
            _config = configuration;

            if (configuration == null)
            {
                throw new InvalidOperationException(
                          "Current Context could not be initialized. No configuration passed to the context");
            }

            var logger = LogFactory.CreateInstance(configuration.Runtime.LogInfo);

            var cache = CacheFactory.Create(configuration.Caching);

            cache.ItemRemoved +=
                (sender, args) =>
                Log.Debug("Item removed from cache: " + args.CacheKey + " Reason : " + args.RemoveReason);

            CurrentContext.CreateDefault(logger, new CommandArgs(string.Empty), cache);
        }
示例#3
0
        private UnitTestContext(IArguments arguments)
        {
            if (arguments == null)
            {
                throw new InvalidOperationException(
                          "Current Context could not be initialized. No arguments passed to the context");
            }

            var element = new LogElement
            {
                Parameters   = "-ShowOnConsole:true ",
                ProviderType = "KonfDB.Infrastructure.Logging.Logger, KonfDBC"
            };

            if (arguments.ContainsKey("runtime-logConfigPath"))
            {
                element.Parameters += "-path:" + arguments["runtime-logConfigPath"];
            }

            var logger = LogFactory.CreateInstance(element);

            CurrentContext.CreateDefault(logger, arguments, null);
        }