/// <summary>
        /// Factory method to create instance
        /// </summary>
        /// <param name="entry">Name of the factory</param>
        /// <param name="context">Context supplied by the infrastructure</param>
        /// <returns>Instance instantiated by the factory.</returns>
        public IRecordParser CreateInstance(string entry, IPlugInContext context)
        {
            IConfiguration config         = context.Configuration;
            ILogger        logger         = context.Logger;
            string         timetampFormat = config["TimestampFormat"];
            string         timestampField = config["TimestampField"];

            switch (entry.ToLower())
            {
            case SINGLE_LINE_JSON2:
                return(new SingleLineJsonParser(timestampField, timetampFormat, NullLogger.Instance));

            case DELIMITED2:
                DateTimeKind timeZoneKind       = DateTimeKind.Utc; //Default
                string       timeZoneKindConfig = Utility.ProperCase(config["TimeZoneKind"]);
                if (!string.IsNullOrWhiteSpace(timeZoneKindConfig))
                {
                    timeZoneKind = (DateTimeKind)Enum.Parse(typeof(DateTimeKind), timeZoneKindConfig);
                }
                return(DirectorySourceFactory.CreateDelimitedLogParser(context, timetampFormat, timeZoneKind));

            default:
                throw new ArgumentException($"Parser {entry} not recognized.");
            }
        }
        private static List <IEnvelope <DelimitedLogRecord> > ParseRecords(StreamReader sr, Microsoft.Extensions.Configuration.IConfigurationSection config)
        {
            string timetampFormat = config["TimestampFormat"];

            var parser = DirectorySourceFactory.CreateDelimitedLogParser(new PluginContext(config, null, null, new BookmarkManager()), timetampFormat, DateTimeKind.Utc);

            var records = parser.ParseRecords(sr, new DelimitedLogContext()).ToList();

            return(records);
        }
        public void TestNonGenericCreateEventSourceWithDelimitedParser()
        {
            var           config         = TestUtility.GetConfig("Sources", "DHCPParsed");
            string        timestampField = config["TimestampField"];
            PluginContext context        = new PluginContext(config, null, null);
            IRecordParser parser         = DirectorySourceFactory.CreateDelimitedLogParser(context, timestampField, DateTimeKind.Utc);
            var           source         = DirectorySourceFactory.CreateEventSource(context, parser);

            Assert.NotNull(source);
            Assert.IsType <DirectorySource <DelimitedLogRecord, DelimitedLogContext> >(source);
        }
        public void TestNonGenericCreateEventSource()
        {
            var           config         = TestUtility.GetConfig("Sources", "JsonLog1");
            string        timetampFormat = config["TimestampFormat"];
            string        timestampField = config["TimestampField"];
            IRecordParser parser         = new SingleLineJsonParser(timestampField, timetampFormat, NullLogger.Instance);

            PluginContext context = new PluginContext(config, null, null);
            var           source  = DirectorySourceFactory.CreateEventSource(context, parser);

            Assert.NotNull(source);
            Assert.IsType <DirectorySource <JObject, LogContext> >(source);
        }
        public ISource CreateInstance(string entry, IPlugInContext context)
        {
            IConfiguration config = context.Configuration;
            ILogger        logger = context.Logger;

            switch (entry.ToLower())
            {
            case ULSSOURCE:
                UlsLogParser ulsParser = new UlsLogParser();
                return(DirectorySourceFactory.CreateEventSource(
                           context,
                           ulsParser));

            default:
                throw new ArgumentException($"Source {entry} not recognized.");
            }
        }
        public ISource CreateInstance(string entry, IPlugInContext context)
        {
            IConfiguration config = context.Configuration;
            ILogger        logger = context.Logger;

            switch (entry.ToLower())
            {
            case "exchangelogsource":
                ExchangeLogParser exchangeLogParser = new ExchangeLogParser();
                exchangeLogParser.TimeStampField = config["TimeStampField"];
                return(DirectorySourceFactory.CreateEventSource(
                           context,
                           exchangeLogParser));

            default:
                throw new ArgumentException($"Source {entry} not recognized.");
            }
        }