如何快速浏览 xml (DI) 配置文件?

发布于 2024-11-10 05:02:03 字数 1491 浏览 3 评论 0 原文

我正在开发一个 .net 项目,该项目使用 Spring.NET 框架进行依赖项注入 (DI)。典型的解决方案包含几十个(小)xml DI 配置文件。浏览这些文件并不像想象中那么顺利。

我想了解更多技巧,以便能够快速浏览 xml 对象定义和相应的代码。有一些你想分享的吗?

示例场景

例如,一个解决方案包含以下文件:

<!-- file1.xml -->
<object id="exampleObject" 
        type="Examples.ExampleObject, ExamplesLibrary">
  <property name="objectOne" ref="anotherExampleObject"/>    
</object>

<!-- file2.xml, somewhere in the same solution -->
<object id="anotherExampleObject" 
        type="Examples.AnotherExampleObject, ExamplesLibrary">
  <property name="Name" value="anotherExampleObject"/>    
</object>

假设您正在使用 file1.xml,您将如何快速从 ...

  • ref="anotherExampleObject" 导航到file2.xml 中的对象定义?
  • type="Examples.ExampleObject, ExamplesLibrary"Examples.ExampleObject.cs 中的 ExampleObject

注释

I' m 完全了解使用 XML 配置 DI 容器的优点和缺点。让我们接受这样一个事实:我需要使用 xml,并且我希望该过程尽可能顺畅。

答案不必特定于 Spring.NET,其他 .NET DI 框架中用于 xml 配置的导航技巧也值得赞赏。

目前我主要使用 VS 2010 和 ReSharper 6;请随意推荐任何与 VS 2008 或 2010 兼容的工具。

I'm working on a .net project that uses the Spring.NET framework for dependency injection (DI). A typical solution contains several dozens of (small) xml DI configuration files. Navigating through these files isn't as frictionless as it could be.

I would like to know more tricks to be able to quickly navigate through the xml object definitions and the corresponding code. Got some you care to share?

Example scenarios

For instance, a solution contains the following files:

<!-- file1.xml -->
<object id="exampleObject" 
        type="Examples.ExampleObject, ExamplesLibrary">
  <property name="objectOne" ref="anotherExampleObject"/>    
</object>

<!-- file2.xml, somewhere in the same solution -->
<object id="anotherExampleObject" 
        type="Examples.AnotherExampleObject, ExamplesLibrary">
  <property name="Name" value="anotherExampleObject"/>    
</object>

Assuming you are working in file1.xml, how would you quickly navigate from ...

  • ref="anotherExampleObject" to the object definition in file2.xml?
  • type="Examples.ExampleObject, ExamplesLibrary" to the ExampleObject class in Examples.ExampleObject.cs

Notes

I'm fully aware of the advantages and disadvantages of using XML for configuring a DI container. Let's just accept the fact that I'm required to use xml and that I would like the process to be as friction-less as possible.

Answers do not have to be specific to Spring.NET, navigation tricks used for xml configuration in other .NET DI frameworks are appreciated too.

Currently I work mostly with VS 2010 with ReSharper 6; feel free to recommend any tool compatible with VS 2008 or 2010.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

怎言笑 2024-11-17 05:02:03

在 DI 配置文件中,ReSharper 允许我按住 Control 键单击值类型属性,以立即跳转到相应的类:

ctrl- click to cs file

此外,将光标置于I处,我可以点击“alt-`”来显示导航菜单:

alt-backtick 显示导航菜单

In a DI configuration file, ReSharper allows me to control-click in the value type attribute to immediately jump to the corresponding class:

ctrl-click to cs file

Furthermore, with the cursor at I I can hit "alt-`" to show the navigation menu:

alt-backtick to show navigation menu

望笑 2024-11-17 05:02:03

不是一个很好的方法,但我发现自己经常使用“在解决方案中查找”。

使用 ReSharper:“查找高级用法”ctrl+shift+alt+F12,选择“文本出现”和解决方案。

Not a really good one, but I find myself using "Find in solution" a lot.

With ReSharper: "Find Usages Advanced" ctrl+shift+alt+F12, selecting "Textual occurence" and Solution.

很快妥协 2024-11-17 05:02:03

如果您已经在使用 ReSharper(并且不介意使用它/不面临 OOM 问题),那么这是最好的选择。

我发现自己求助于更轻量级的扩展,例如 PhatStudio快速打开文件 切换到不同的文件。

当然,这受到以下事实的限制:您需要知道要切换到的文件名。如果不是,则 Ctrl+Shift+F.xml[common_naming_pattern.extension] 过滤 文件就可以了。

再次,与 ReSharper 相比,这似乎很啰嗦。但是,如果您像我一样无法忍受打开 Resharper 6(我的电脑上经常出现 OOM 异常,因此我会禁用它),那么这是最好的选择。

If you're already using ReSharper (and don't mind using it/do not face OOM issues), then that's the best thing out there.

I find myself resorting to lighter extensions such as PhatStudio or Quick Open File to switch to different files.

This of course is limited by the fact that you need to be aware of the file name to switch to. If not, Ctrl+Shift+F filtered by .xml or [common_naming_ pattern.extension] files does the trick.

Again, compared to ReSharper, this seems long-winded. But if you're like me who cannot live with Resharper 6 turned on (OOM exceptions are so often on my PC that I'd to disable it), then this is the best alternative.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文