IMediaBasedReaderFactory CreateFactory(string formatDescription) { var repo = new SingleEntryFormatsRepository(formatDescription); ITempFilesManager tempFilesManager = new TempFilesManager(); ILogProviderFactoryRegistry reg = new LogProviderFactoryRegistry(); IUserDefinedFormatsManager formatsManager = new UserDefinedFormatsManager(repo, reg, tempFilesManager, new TraceSourceFactory(), RegularExpressions.FCLRegexFactory.Instance, Mocks.SetupFieldsProcessorFactory()); JsonFormat.UserDefinedFormatFactory.Register(formatsManager); formatsManager.ReloadFactories(); var factory = reg.Items.FirstOrDefault(); Assert.IsNotNull(factory); return(factory as IMediaBasedReaderFactory); }
public static IMediaBasedReaderFactory CreateFactoryFromAssemblyResource(Assembly asm, string companyName, string formatName) { var repo = new DirectoryFormatsRepository(Path.Combine(Path.GetDirectoryName(asm.Location), "formats")); ILogProviderFactoryRegistry reg = new LogProviderFactoryRegistry(); IUserDefinedFormatsManager formatsManager = new UserDefinedFormatsManager(repo, reg, tempFilesManager, new TraceSourceFactory(), RegularExpressions.FCLRegexFactory.Instance, Mocks.SetupFieldsProcessorFactory()); LogJoint.RegularGrammar.UserDefinedFormatFactory.Register(formatsManager); LogJoint.XmlFormat.UserDefinedFormatFactory.Register(formatsManager); formatsManager.ReloadFactories(); var factory = reg.Find(companyName, formatName); Assert.IsNotNull(factory); return(factory as IMediaBasedReaderFactory); }