public ContentPartOption AddContentPart(Type contentPartType) { if (!contentPartType.IsSubclassOf(typeof(ContentPart))) { throw new ArgumentException("The type must inherit from " + nameof(ContentPart)); } var option = new ContentPartOption(contentPartType); _contentParts.Add(option); return(option); }
internal ContentPartOption GetOrAddContentPart(Type contentPartType) { if (!contentPartType.IsSubclassOf(typeof(ContentPart))) { throw new ArgumentException("The type must inherit from " + nameof(ContentPart)); } var option = _contentParts.FirstOrDefault(x => x.Type == contentPartType); if (option == null) { option = new ContentPartOption(contentPartType); _contentParts.Add(option); } return(option); }