Visual Studio 自定义工具:文件包装器
我想要的是对 VS.NET 解决方案中文件内容的键入访问。
我认为具有相应自定义工具名称空间的自定义工具是最容易做到的(如果有更简单的方法来完成相同的事情,请纠正我!)
这将生成如下代码:
Namespace CustomToolNamespaceInPropertiesComesHere
Public Module SomeName
Public Function GetFile() As IO.Stream
Return System.Reflection.Assembly.GetExecutingAssembly() _
.GetManifestResourceStream("RootNamespace.FileName.xml")
End Function
End Module
End Namespace
基本上,它会在文件属性中指定的“自定义工具命名空间”内创建对文件(具有构建操作:嵌入资源的 XML 文件)的类型化访问。
我不想使用 ResX,因为我希望每个 XML 文件单独出现在解决方案中,并将 XMLEditor 作为默认编辑器(因此,如果时间允许编写 XSD 验证,可以添加 XSD 验证)。
不幸的是,关于这些自定义工具命名空间的信息很少。到目前为止的每个示例似乎也引用 BaseCodeGeneratorWithSite
其中原始 URL 已失效。
我也问这个问题,希望有人提供一些更容易使用/实现的东西,而不是新的自定义工具的过度杀伤力......
What I want is typed access to the contents of a file within a VS.NET solution.
I think a custom tool with corresponding custom tool namespace would be the easiest to do (do correct me if there is a simpler way of accomplishing the same thing!)
This would generate code like so:
Namespace CustomToolNamespaceInPropertiesComesHere
Public Module SomeName
Public Function GetFile() As IO.Stream
Return System.Reflection.Assembly.GetExecutingAssembly() _
.GetManifestResourceStream("RootNamespace.FileName.xml")
End Function
End Module
End Namespace
Basically it creates typed access to a file (An XML file with Build Action: Embedded Resource) within the "Custom Tool Namespace" as specified in the properties of the file.
I do not want to use a ResX as I want each XML file to appear seperately in the solution and have the XMLEditor as default editor (So XSD validation can be added if time permits writing one).
Unfortunately little information can be found about these custom tool namespaces. Every example so far also seems to refer to BaseCodeGeneratorWithSite
of which the original URL has gone dead.
I'm also asking this in hopes of someone providing something easier to use/implement rather than the overkill of a new custom tool...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论