//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> Adds an extraction type. </summary> /// /// <param name="fileType"> Type of the file. </param> /// <param name="extension"> The files extension. </param> /// <param name="extractorType"> The extractor type. </param> /// <param name="jobType"> Type of the job. </param> /// <param name="childExtractors"> /// A variable-length parameters list containing child extractors. /// </param> /// /// <returns> An ExtractorEntry. </returns> private ExtractorEntry AddType(string fileType , string extension , Type extractorType , Type jobType , params ExtractorEntry[] childExtractors) { if (mExtractorDictionary.ContainsKey(extension)) { throw new ArgumentException("Attempted to add duplicate extractor entries"); } if (!typeof(IExtractor).IsAssignableFrom(extractorType)) { throw new ArgumentException("Attempted to add an extractor type that does not implement IExtractor"); } if (!typeof(IExtractionJob).IsAssignableFrom(jobType)) { throw new ArgumentException("Attempted to add an extractor job that does not implement IExtractionJob"); } var jobConstructor = jobType.GetConstructor(new Type[] { typeof(IExtractionData) }); if (jobConstructor == null) { throw new ArgumentException("Attempted to add an extractor job that does have a constructor with a single IExtractionData parameter"); } var entry = new ExtractorEntry() { mFileType = fileType, mFileExtension = extension, mExtractorType = extractorType, mExtractorJobConstructor = jobConstructor, mChildExtractors = new List <ExtractorEntry>(childExtractors) }; mExtractorDictionary.Add(extension, entry); return(entry); }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> Adds an extraction type. </summary> /// /// <param name="fileType"> Type of the file. </param> /// <param name="extension"> The files extension. </param> /// <param name="extractorType"> The extractor type. </param> /// <param name="jobType"> Type of the job. </param> /// <param name="childExtractors"> /// A variable-length parameters list containing child extractors. /// </param> /// /// <returns> An ExtractorEntry. </returns> private ExtractorEntry AddType(string fileType , string extension , Type extractorType , Type jobType , params ExtractorEntry[] childExtractors) { if (mExtractorDictionary.ContainsKey(extension)) { throw new ArgumentException("Attempted to add duplicate extractor entries"); } if (!typeof(IExtractor).IsAssignableFrom(extractorType)) { throw new ArgumentException("Attempted to add an extractor type that does not implement IExtractor"); } if (!typeof(IExtractionJob).IsAssignableFrom(jobType)) { throw new ArgumentException("Attempted to add an extractor job that does not implement IExtractionJob"); } var jobConstructor = jobType.GetConstructor(new Type[] { typeof(IExtractionData) }); if (jobConstructor == null) { throw new ArgumentException("Attempted to add an extractor job that does have a constructor with a single IExtractionData parameter"); } var entry = new ExtractorEntry() { mFileType = fileType, mFileExtension = extension, mExtractorType = extractorType, mExtractorJobConstructor = jobConstructor, mChildExtractors = new List<ExtractorEntry>(childExtractors) }; mExtractorDictionary.Add(extension, entry); return entry; }