在.NET类型转发:请问类转发需要从类型类继承? [英] Type Forwarding in .Net: Does the class forwarded need to inherit from the Type class?

查看:178
本文介绍了在.NET类型转发:请问类转发需要从类型类继承?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果您要转发类引用同类型转发另一个程序集,这是否类需要从类型继承?



我想我真正之后就是 - 这是什么意思,或表示什么,在转发类型的短语和概念词类型


解决方案

如果您要转发类引用同类型转发另一个程序集,这是否类需要从类型继承?




没有




我猜我真想要的是 - 这是什么意思,或表示什么,由字转发类型的短语和概念类型。




假设你有组装阿尔法Foo类型,然后在下一版本你意识到美孚真的应该已经在装配布拉沃。你不能移动的类型,因为所有的客户谁对富的依赖关系是阿尔法将被打破。



解决方案是在Foo类型进入布拉沃,然后运阿尔法的新版本,它包含一个类型转发,告诉阿尔法的用户,如果你正在寻找Foo的,它现在在布拉沃找到。这样,你不打破任何人谁要看事情都是他们曾经的方式。




我想我是缺少在这里,是什么类型的定义是转发类型的概念。 ?作为一种什么资格




下面的东西类型的定义的:




  • 非通用或者未构造泛型类,结构,接口和委托

  • 枚举



下面的东西类型的引用的(他们所有的参考的另一种类型;没有这些的确定新的东西。)




  • 构造泛型类,结构,接口和委托

  • 阵列

  • 指针

  • nullables



(而且有一类是不属于任何一类,这是返回类型无效的。)



所有这些类型中,只有类型定义可以转发。一型转发器的目的是为了说是用于由该组件被定义的类型现在是由组件定义的,因此它才有意义转发类型的定义的。您不能转发类型 MYSTRUCT< INT> [] ;没有任何意义。您可以转发 MYSTRUCT< T>




什么叫未构造的意思泛型类?这是不是意味着只有一个通用的定义,并没有一个通用的已实例化指定的类型?




正确的。




你可以指向我,你找到了类型的引用和类型定义的信息?




这是不是从C#语言规范的概念;相反,这些都是从底层通用语言基础结构类型系统的概念对于一个广泛的技术怎么看待CLI。定义和引用类型之间的不同,阅读ECMA 335 CLI规范,特别是找对的TypeDef和TypeRef的元数据表的部分。


If you want to forward a class reference to another assembly with Type Forwarding, does that class need to inherit from Type?

I guess what I am really after is - What does it mean, or what is indicated, by the word "Type" in the phrase and concept of Type Forwarding.

解决方案

If you want to forward a class reference to another assembly with Type Forwarding, does that class need to inherit from Type?

No.

I guess what I am really after is - What does it mean, or what is indicated, by the word "Type" in the phrase and concept of Type Forwarding.

Suppose you have a type Foo in assembly Alpha, and in your next version you realize that Foo really should have been in assembly Bravo. You can't move the type because all your customers who have dependencies on Foo being in Alpha will be broken.

The solution is to move the type Foo into Bravo, and then ship a new version of Alpha that contains a type forwarder that tells users of Alpha "if you're looking for Foo, it's now found in Bravo". That way you don't break anyone who depends on things being the way they used to be.

I think what I am missing here, is what the definition of "Type" is in the concept of Type Forwarding. What qualifies as a type?

The following things are type definitions:

  • non-generic or unconstructed generic classes, structs, interfaces and delegates
  • enums

The following things are type references (they all refer to another type; none of these define something new.)

  • constructed generic classes, structs, interfaces and delegates
  • arrays
  • pointers
  • nullables

(And there is one type that does not fall into either category, which is the return type "void".)

Of all those types, only the type definitions can be forwarded. The purpose of a type forwarder is to say "the type that used to be defined by this assembly is now defined by that assembly", so it only makes sense to forward a type definition. You can't forward the type MyStruct<int>[]; that doesn't make any sense. You can forward MyStruct<T>.

what do you mean by "unconstructed generic classes? Does this mean only a generic's definition, and not a generic that has been instantiated with the type specified?

Correct.

And can you point me to where you found the information for the "type references" and "type definitions"?

These are not concepts from the C# language specification; rather, these are concepts from the underlying Common Language Infrastructure type system. For an extensive technical look at how the CLI differs between defined and referenced types, read the ECMA 335 CLI specification, particularly looking for the sections on the metadata tables for TypeDef and TypeRef.

这篇关于在.NET类型转发:请问类转发需要从类型类继承?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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