从暴露装配不同类型名(别名)别名、不同类型

2023-09-03 13:27:33 作者:用微笑伪装自己的悲伤

这个问题是关系到 previous,矿山的悬而未决的问题,因为我还在解决一样的问题;这是一个不同的方法,但。

This question is related to a previous, unanswered question of mine, as I'm still solving the same problem; this is about a different approach though.

我目前消费在C#.NET项目第三方SOAP的Web服务。不幸的是,生成的客户端代理类和类成员的名字是我目前的约定不一致的。

I'm currently consuming a third-party SOAP web service in a C# .NET project. Unfortunately, the generated client proxy classes and class members have names that are inconsistent with my current conventions.

直至另行建议,否则,我留下来presume说的 SvcUtil工具不支持别名(不过,它肯定看起来这将是最容易实现在该水平的)

Until advised otherwise, I'm left to presume that Svcutil doesn't support aliasing (though, it certainly seem it would be most easily accomplished at that level)

我现在在考虑包装的Web服务消费到它自己的项目,从而组装,并简单地引用来自其他项目。我正在考虑这考虑到有可能增加一些( presumably,汇编级的)声明揭露公共类型有不同的名字比那些组件中的定义。

I'm now considering wrapping the web service consumption into it's own project, thus assembly, and simply referencing that from other projects. I'm considering this given that it's possible to add some (presumably, assembly-level) declarations to expose the public types with different names than those defined within the assembly.

我的问题是; 是有可能暴露比在装配中定义的不同类型/成员的名字,基本上是走样呢?

例如,赋予了神奇的组装属性:

For example, given a magical assembly attribute:

[assembly: AssemblyTypeAlias(
    Type = typeof(Foo.Bar.qux),
    Name = "Qux"
)]

因此​​,项目参照本次大会将访问 Foo.Bar.qux Foo.Bar.Qux

当然,类似的类级别的属性将是巨大的,看到所生成的代理是部分

Of course, a similar class-level attribute would be great too, seeing as the generated proxies are partial:

namespace Foo.Bar
{
    [Alias("Qux")]
    public partial class qux 
    {
    }
}

屈服同样的效果。

Yielding the same effect.

虽然我只覆盖类型名称与我的理论的例子,一个解决方案,允许成员名称的混淆会的壮观的。

While I've only covered type names with my theoretical examples, a solution that allows the aliasing of member names would be spectacular.

修改:我说的别名,其中更适用期限将是重命名,为了掩盖原来的名称; preferably后者,但前者会工作。

Edit: I've said "alias", where the more applicable term would be "rename", in order to hide the original name; preferably the latter, but the former will work.

推荐答案

我搬到这个答案建议使用进XML属性的引用到服务到您的其他问题,因为这个人是真的问走样组件,无论它们是从服务还是不行。

I've moved this answer suggesting use of the XmlType Attribute in the Reference to the Service to your other question, since this one is really asking about aliasing assemblies, whether they come from a service or not.