Exemplo n.º 1
0
        private void GetAppenders()
        {
            var numberOFAppeders = int.Parse(Console.ReadLine());

            for (int i = 0; i < numberOFAppeders; i++)
            {
                string[] inputArgs = Console.ReadLine().Split(" ");

                AppendersType appenderType = Enum.Parse <AppendersType>(inputArgs[0]);
                LayoutsType   layoutType   = Enum.Parse <LayoutsType>(inputArgs[1]);

                ILayout   layout   = layoutFactory.CreateLayout(layoutType);
                IAppender appender = appenderFactory.CreateAppender(appenderType, layout);

                if (inputArgs.Length == 3)
                {
                    string      reportLevelType = inputArgs[2];
                    ReportLevel level           = Enum.Parse <ReportLevel>(reportLevelType);

                    appender.ReportLevel = level;
                }

                if (appenderType == AppendersType.FileAppender)
                {
                    ((FileAppender)appender).File = new LogFile();
                }

                appenders.Add(appender);
            }
        }
Exemplo n.º 2
0
        public ILayout CreateLayout(LayoutsType type)
        {
            switch (type)
            {
            case LayoutsType.SimpleLayout:
                return(new SimpleLayout());

            case LayoutsType.XmlLayout:
                return(new XmlLayout());

            default:
                throw new ArgumentException("Invalid layout type!");
            }
        }