Visual Studio中 - 工具,以取代资源硬codeD字符串 [英] Visual Studio - Tool to replace hard coded strings with resources

查看:169
本文介绍了Visual Studio中 - 工具,以取代资源硬codeD字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个很大的ASP.NET项目全硬codeD字符串,现在要提取到的资源。这样的字符串可以几乎随处可见(在的.cs文件,.aspx文件,.ascx文件等),文件的数量是巨大的。我正在寻找的是一个工具(或任何方式)来查找一次性这些硬codeD字符串,并把它们放在一起的资源文件,而不是我手动经历的每一个文件。难道这样的事情存在吗?

I have a big ASP.NET project full of hard coded strings, that now have to be extracted to resources. Such strings can be found almost anywhere (in .cs files, .aspx files, .ascx files, etc.) and the amount of files is huge. What I'm looking for is a tool (or any way) to find all these hard coded strings in one shot and put them all together in the resource file, instead of me going manually through each file. Does anything like this exist?

注:我知道,那将是更好地把资源字符串马上当他们需要在第一时间,但是这是一个2岁的项目中,没有人真正关心(的不典型例子我问题的理念)。

Note: I'm aware that it would have been better to put the strings in resources straight away when they were needed the first time, but this is a 2 years old project where nobody really cared (typical example of "not my problem" philosophy).

非常感谢你。

更新:我尝试codeRUSH(我不能尝试RGreatEx出于显而易见的原因),而且我用它有困难。主要的问题是,我在寻找主要分布在.aspx文件中的字符串和字符串这些文件中没有重构资源命令可用。

UPDATE: I tried CodeRush (I couldn't try RGreatEx for obvious reasons), and I'm having difficulties using it. The main issue is that the strings I'm looking for are located mainly in .aspx files, and strings in those files don't have the "Refactor to resource" command available.

例如,我能有这样的内容:

For example, I can have elements like this:

<dxwgv:ASPxSummaryItem DisplayFormat="{0}" FieldName="TOTAL" ShowInColumn="Total" SummaryType="Sum" />

我需要改变的部分的 ShowInColumn =总计的并使其像的 ShowInColumn =&LT;%$资源:PortalResource,合计%>的。这不是一个严格的方式串分配,但是一个属性分配,因此,重构! $ C $美眉命令不会出现。

The part I need to change is ShowInColumn="Total" and make it like ShowInColumn="<%$ Resources:PortalResource, Total %>". This is not a string assignment in a strict way, but an attribute assignment, so the "Refactor!" command of CodeRush doesn't appear.

我的目标是要找到所有的人都在一杆,并在特定接口的改变(即像一个本地化工具),而不是找他们一一和手动创建相应的资源。重构逐一每一个文件将是一个进步,但仍然非常耗时...

My target is to find all of them in one shot and change them in a specific interface (i.e. like a localization tool) instead of looking for them one by one and manually creating the corresponding resource. Refactoring one by one inside each file would be an improvement, but still very time consuming...

推荐答案

的VisualStudio能让您搜索与正则表达式替换。它不会是修复所有在一杆的解决方案,但它应该削减显著量手动工作。

VisualStudio lets you search and replace with RegEx. It won't be the "fix all in one shot" solution, but it should cut back on the amount manual work significantly.

只是一个想法。

这篇关于Visual Studio中 - 工具,以取代资源硬codeD字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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