public static IMarcellEntity ToEntity(this LuceneDocument source, Type targetType) { if (targetType == typeof(MarcellDocument)) { return(source.ToDocument()); } else if (targetType == typeof(Section)) { return(source.ToSection()); } else if (targetType == typeof(Paragraph)) { return(source.ToParagraph()); } else if (targetType == typeof(Sentence)) { return(source.ToSentence()); } else { throw new InvalidOperationException("The requested type is unsupported!"); } }