有什么用集引用在Visual Studio 8的别名属性 [英] What use is the Aliases property of assembly references in Visual Studio 8
问题描述
当我在Visual Studio 8中的别名属性添加程序集引用到一个项目,该引用的,被设置为全局。什么是该物业的好,为什么它设置为全局?
When I add an assembly reference to a project in Visual Studio 8 the Aliases property, of that reference, is set to "global". What is this property good for and why is it set to global?
MSDN告诉我,这是别名组件的列表,但不是为什么我可能要使用此属性或为什么大多数都别名为全局。
MSDN tells me that this is a list of aliases for the assembly but not why I might want to use this property or why most are aliased as "global".
推荐答案
这是外部别名。假设你要使用两种不同类型,这两种被称为 Foo.Bar
(即酒吧
在一个命名空间富
)。这两种类型将会在不同的组件(定义) - 使用在VS的财产,以别名与每个参考相关联,那么你可以做:
This is for "extern aliases". Suppose you want to use two different types, both of which are called Foo.Bar
(i.e. Bar
in a namespace of Foo
). The two types will be in different assemblies (by definition) - you use the property in VS to associate an alias with each reference, then you can do:
extern alias FirstAlias;
extern alias SecondAlias;
using FirstBar = FirstAlias::Foo.Bar;
using SecondBar = SecondAlias::Foo.Bar;
然后用 FirstBar
和 SecondBar
在code。
所以基本上它命名的一个额外的水平 - 你不应该使用它,除非你真的不得不这样做。这会迷惑了很多人。尽量避免陷入摆在首位这种情况 - 但要知道这种解决方案对于那些时间,你就不能避免它
So basically it's an extra level of naming - and you shouldn't use it unless you really, really have to. It will confuse a lot of people. Try to avoid getting into that situation in the first place - but be aware of this solution for those times where you just can't avoid it.
这篇关于有什么用集引用在Visual Studio 8的别名属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!