Tech Off Thread

3 posts

Using MEF with multiple user defined file extensions

Back to Forum: Tech Off
  • User profile image
    Stefanos​Anastasiou

    Hallo, 

    I am trying to implement syntax highlighting, intellisense etc. for a specialized language and I was hoping to use MEF. However since this heavily relies on providing a file extension at compile time and one requirement is that this extensions should apply to many different file extensions.. E.g. .atm, .bar, .foo .. 

    There seems to be no documentation whatsoever on the net. The only success I had was by reverese engineering IronPython tools.. 

    Thanks for any pointers..

  • User profile image
    Dr Herbie

    Not sure I understand you're question -- MEF loads DLL files (executable libraries).  MEF will load all DLLs in a given directory that have an interface marked as exported.

    If you're using MEF for syntax rules, I would expect you to have several DLLs in the same directory (one for each language supported), all exporting the same interface.  At runtime you use MEF to get a list of all the instances if found of that interface and then use the interface to interrogate each instance to see if it support the current language.

    From that point on you perform all syntax rules through that interface, using polymorphism to gloss over the fact that you don't know which specific instance you're using.

    Herbie

  • User profile image
    Stefanos​Anastasiou

    Hi Herbie,

    thanks for the answer. 

    I am referring to this : 

    http://msdn.microsoft.com/en-us/library/ee372313.aspx

    As fas as I understand, each content type can only be export for one, or more file extensions statically at compile time. 

    How do I export content types dynamically based on some user options for example? Is this not possible purely by MEF?

    Thanks!

Comments closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.