public void TextContentTypeIsAvailable() { var contentType = _registry.ForName("text"); Assert.AreEqual("text", contentType.Name); Assert.AreEqual("text", _registry.ForFileExtension(".txt").Name); Assert.AreEqual(new[] { ".txt" }, _registry.FileExtensionsFor(contentType)); }
/// <summary> /// Returns the content type specific implementation of service <typeparamref name="T"/> /// based on a file extension. /// </summary> /// <typeparam name="T">Service contract.</typeparam> /// <returns>Returns default(T) if either the content type or the service are not /// found.</returns> public static T ServiceForFileExtension <T>(this IContentTypeRegistry contentTypeRegistry, string fileExtension) { var contentType = contentTypeRegistry.ForFileExtension(fileExtension); return(contentType != null ? contentType.GetService <T>() : default(T)); }