[英]Two namespaces of the same class
we are changing the name of our product, so i also want to rename the namespaces of our framework-classes. 我们正在更改产品的名称,因此我也想重命名我们的框架类的名称空间。 But now i have the problem, that i don't know in which programms and scripts our namespaces are used.
但是现在我有了问题,我不知道我们的命名空间在哪些程序和脚本中使用。 Is there a way in c#, to locate the same class in two different namespaces?
在c#中,有没有一种方法可以在两个不同的名称空间中找到相同的类?
I know the solution, that i could inherited from my classes in the new namespace, but this is a very bad solution i think. 我知道可以从新命名空间中的类继承的解决方案,但是我认为这是一个非常糟糕的解决方案。 So I have no idea how to solve this problem, because simply renaming all namespaces doesn't help and will cause a lot trouble.
因此,我不知道如何解决此问题,因为仅重命名所有名称空间无济于事,并且会造成很多麻烦。
Thank you! 谢谢!
If external scripts are referencing your assembly using the old namespace names then those names will have to remain in your assembly in you wish to continue to use those scripts. 如果外部脚本使用旧的名称空间名称引用程序集,则这些名称将必须保留在您的程序集中,以便您继续使用这些脚本。 If you also want to create new namespace names to reflect the new name of your product, those names will also need to be hardcoded into your assembly.
如果您还想创建新的名称空间名称以反映产品的新名称,那么这些名称也需要硬编码到程序集中。 This will inevitably lead to problems!
不可避免地会导致问题!
I would recommend one of the following: 我建议以下之一:
I would definitely not recommend the faux 'inheritance' method, or any other solution which results in duplication within the assembly. 我绝对不建议您使用伪造的“继承”方法或任何其他导致程序集重复的解决方案。
You could search the whole project / solution of course, but that seems sort of messy and time-consuming too, if you've got more than a trivial project. 当然,您可以搜索整个项目/解决方案,但是如果您不只是一个琐碎的项目,那似乎也很麻烦且耗时。
Are you using Resharper? 您在使用Resharper吗? For this type of task, you definitely should be.
对于此类任务,您绝对应该如此。 If so, there is a chance this could at least help you on your way:
如果是这样,那么这至少有可能帮助您:
Alt + Enter
) to open the context meny thingy also shown below. Alt + Enter
)打开上下文菜单,也如下所示。 As for your scripts, I would guess that you best bet is to do a plain text search for the old namespaces - possibly a search and replace . 至于您的脚本,我想您最好的选择是对旧名称空间进行纯文本搜索-可能是搜索和替换 。 Perhaps you can include your scripts in a VS solution, and use the built in search there to scan and fix them.
也许您可以将脚本包括在VS解决方案中,然后使用那里的内置搜索来扫描和修复它们。 That might at least ease the pain a little..
那至少可以减轻一点痛苦。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.