共用方式為


IFilePathToContentTypeProvider Interface

Definition

MEF export to map full file names to a content type.

public interface class IFilePathToContentTypeProvider
public interface IFilePathToContentTypeProvider
type IFilePathToContentTypeProvider = interface
Public Interface IFilePathToContentTypeProvider

Remarks

Instances of this class should define the following MEF attributes.

[Export(typeof(IFilePathToContentTypeProvider)]      -- Required
[Name("BamBam")]                                     -- Required
[Order(After = "Fred", Before="Barney")]             -- Optional, can have more than one.
[FileExtension(".abc")]                              -- Optional, but must have either a FileExtension or a FileName attribute. Can optionally be compound extension '.abc.def'.
[FileName("George")]                                 -- Optional, but must have either a FileExtension or a FileName attribute
[DeferCreation(OptionName = ...)]                    -- Optional, do not create this extension point unless OptionName is turned on.

You can use "" as the FileExtension attribute to match any file extension.

The IFilePathToContentTypeProvider will be called in order (based on the OrderAttribute) if their FileExtensionAttribute matches the extension of the file in question (or is a "") or the FileNameAttribute matches the name of the file in question.

Compound extensions, such as '.abc.def' are supported via the FileExtensionAttribute, however, if there is a mapping for a compound '.abc.def' and a simple extension 'def', the one that is first via OrderAttribute wins.

Methods

TryGetContentTypeForFilePath(String, IContentType)

Gets the content-type for the given filePath.

Applies to