locked
Extension of new file-extensions via MEF RRS feed

  • General discussion

  • Hello developers,

    I've developed the VSPackage containing an editor. The editor can be extended with new file types via MEF components.

    The only thing I am unable to do is an association of new file type extension (provided by MEF) with the given editor. 

    In fact, there is a MEF component looking like this:

        [Export(typeof(IMyEditorAddIn))]
        [ExportMetadata("Extension", ".xyz")]
        [ExportMetadata("ContentType", typeof(XYZ))]
        public class XYZAddIn : IMyEditorAddIn { ... }

    On the editor level, I would need to do something like this to associate new extension with an editor:

    [ProvideEditorExtension(typeof(EditorFactory), ".xyz", 0x40, NameResourceID = 106)]

    The problem is that this is done on the metadata level, I would need a dynamic solution for such an association. 

    I would appriciate any help,

    Thanks,

    Ondra


    • Changed type Ego Jiang Monday, October 22, 2012 9:54 AM
    Saturday, October 6, 2012 9:36 PM

All replies

  • Hi Ondra,

    >I would need a dynamic solution for such an association

    Do you mean you want the file extension as a dynamic type?

    You can add different ExportMetadata .dlls and use MEF to use them.

    Best regards,


    Ego [MSFT]
    MSDN Community Support | Feedback to us

    Monday, October 8, 2012 8:43 AM
  • Hi Ego,

    many thanks for your reply.

    >Do you mean you want the file extension as a dynamic type?

    No, I don't want a file extension as a dynamic type.

    I just meant that I am able to inject distinct file extensions to the editor, but I don't know, how

    to force the editor to register them properly within the VS.

    I am only able to register them using the metadata attribute like:

    [ProvideEditorExtension(typeof(EditorFactory), ".xyz", 0x40, NameResourceID = 106)]

    but since this is a metadata attribute, I can't use it for registration of the file-extensions that have been injected to the editor by MEF. Therefore I would need something like this:

    foreach (var extension in injectedExtensions) {

    ProvideEditorExtension(typeof(EditorFactory), extension, ....);

    }

    but I am afraid, this is a wrong way to do so.

    Many thanks,

    Ondra


    Monday, October 8, 2012 11:35 PM
  • Hi Ondra,

    We are changing the issue type to “Comment” because you have not followed up with the necessary information. If you have more time to look at the issue and provide more information, please feel free to change the issue type back to “Question” by editing your initial post and changing the radio button at the top of the post editor window. If the issue is resolved, we will appreciate it if you can share the solution so that the answer can be found and used by other community members having similar questions.

    Thanks,


    Ego [MSFT]
    MSDN Community Support | Feedback to us

    Monday, October 22, 2012 9:54 AM