如何将我的DSL与XAML文档类型相关联 [英] How to Associate my DSL to XAML Document type

查看:74
本文介绍了如何将我的DSL与XAML文档类型相关联的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能是一个非常基本的问题所以请提前原谅我。


背景


最初,C#项目中的XAML文件具有与之关联的.cs(代码隐藏)文件。我想创建一个包,将另一个文件扩展名类型与每个.XAML文件相关联。


文件类型基于我构建的DSL模型,它枚举XAML并从中导出特定的Domain元素,并根据用户执行一些T4代码生成对于他们的模型的更改。 假设我的DSL模型文件扩展名
被称为* .myDsl。


目前,为了将新的MyDSL模型添加到  ;我的项目 我必须调用AddNew命令并从已安装的软件包列表中选择将DSL模型添加到我的项目中,然后在我的DSL代码中启动时,我需要枚举
VS项目获取XAML类型的所有文件,然后提供一个对话框,供用户将新的DSL编辑器与该模型相关联。 


我想要做的是右键单击任何XAML文件,并有一个菜单选项,显示添加新的MyDSL。 此外,我希望新的DSL文件与XAML相关联,就像.cs一样。这样,如果开发人员希望编辑以前
保存的DSL文件,他们只需展开xaml,不仅可以查看相关的.cs文件,还可以查看.myDSL文件(如果存在)。


鉴于我已经有.myDSL文件的编辑器,这是我的问题;


  1. 使用菜单选项如何在没有开发人员需要调用AddNew的情况下安装新的DSL?
  2. 如何将我的扩展名与.XAML文件关联?




Johnny Larue,http://www.softlandingcanada.com

解决方案

嗨约翰尼。除非我遗漏了什么,否则我觉得这个帖子类似于

http://social.msdn.microsoft.com/Forums/vstudio/en-US / eed1c360-1a5c-4505-9d3b-d02afd1f55c7 / will-like-an-an-custom-file-type-to-xaml-files
 我在那里提供了答案。


问候



This is likely a very basic question so please forgive me in advance.

BACKGROUND

Initially a XAML file in a C# project has a .cs (code behind) file associated to it. I would like to create a package that associates another file extension type to each .XAML file.

The file type is based on a DSL model I have built that enumerates the XAML and derives specific Domain elements from it, and performs some T4 code gen as a result of user changes to their model. Assume for this discussion that my DSL model file extension is called *.myDsl.

Currently, in order to add a new MyDSL model into my project  I have to invoke the AddNew command and select from list of installed packages to add a DSL Model to my project, then upon startup in my DSL code, I need to enumerate the VS project to obtain all files of type XAML then provide a dialog for the user to associate the new DSL editor to that model. 

What I'd like to do instead is to right-click any XAML file, and have a Menu option that says Add New MyDSL.  Further I would like that new DSL file to be associated to the XAML much like .cs. In that way if the developer wishes to edit a previously saved DSL file they simply expand the xaml and see not only the related .cs file but also the .myDSL file (if one exists).

Given that I already have an editor for the .myDSL files, here are my questions;

  1. With a Menu option how can I install a new DSL without the developer needing to invoke AddNew?
  2. How do I associate my extension to .XAML files?


Johnny Larue, http://www.softlandingcanada.com

解决方案

Hi Johnny. Unless I'm missing something, I think that this thread is similar to http://social.msdn.microsoft.com/Forums/vstudio/en-US/eed1c360-1a5c-4505-9d3b-d02afd1f55c7/would-like-to-associate-an-custom-file-type-to-xaml-files where I provided an answer.

Regards


这篇关于如何将我的DSL与XAML文档类型相关联的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆