private static ISource CreateGenericDelimitedSource(string id, string path, string timestampFormat, string timestampField, DirectorySourceOptions options, IPlugInContext context) { var parserOptions = new GenericDelimitedLogParserOptions(); ParseDelimitedParserOptions(context.Configuration, parserOptions); parserOptions.TimestampField = timestampField; parserOptions.TimestampFormat = timestampFormat; parserOptions.Headers = context.Configuration["Headers"]; parserOptions.HeadersPattern = context.Configuration["HeaderPattern"]; parserOptions.RecordPattern = context.Configuration["RecordPattern"]; parserOptions.CommentPattern = context.Configuration["CommentPattern"]; if (bool.TryParse(context.Configuration["CSVEscapeMode"], out var csvMode)) { parserOptions.CSVEscapeMode = csvMode; } var parser = new GenericDelimitedLogParser(context.Logger, context.Configuration["Delimiter"], parserOptions); return(CreateDirectorySource(id, path, parser, options, context)); }
private static ISource CreateDirectorySource <TData, TContext>(string id, string path, ILogParser <TData, TContext> recordParser, DirectorySourceOptions options, IPlugInContext context) where TContext : LogContext, new() { var directorySourceType = typeof(AsyncDirectorySource <,>); var genericDirectorySourceType = directorySourceType.MakeGenericType(typeof(TData), typeof(TContext)); var source = (ISource)Activator.CreateInstance(genericDirectorySourceType, id, path, recordParser, context.BookmarkManager, options, context); return(source); }