コード例 #1
0
ファイル: ClientContext.cs プロジェクト: ugurak/KonfDB
        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);
        }
コード例 #2
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);
        }