[英]what exactly does CompositionContainer.ComposeExportedValue method do?
Does the CompositionContainer.ComposeExportedValue method take an object and make the object's export method available? CompositionContainer.ComposeExportedValue方法是否可以使用对象并使该对象的导出方法可用? I am kind of confused what this method does. 我对这种方法的功能感到困惑。 All I know is that this method regsiters object with the container. 我所知道的是,此方法注册者将容器作为对象。 How does it register objects with the container? 它如何在容器中注册对象? Does this method majically somehow make an object's export methods, or an object that has the export attribute available for other classess? 这个方法是否在某种程度上可以使对象的导出方法或具有export属性可用于其他类的对象?
AFAIK the AttributedModelServices.ComposeExportedValue<T>
extension method for CompositionContainer
registers the given object as a part satisfying contract T
. AFAIK CompositionContainer
的AttributedModelServices.ComposeExportedValue<T>
扩展方法将给定对象注册为满足合同T
的一部分。 This means that the object will indeed be used to compose other objects which import T
. 这意味着该对象确实将用于组成其他导入T
对象。
Perhaps more important is what it doesn't do : 也许更重要的是它不做的事情 :
AttributedModelServices.ComposeParts
. 您可以使用AttributedModelServices.ComposeParts
做到这一点。 IDisposable
, it will not be disposed when the container is disposed. 如果对象是IDisposable
,则在处理容器时将不会处理该对象。 In general you should avoid these methods. 通常,您应避免使用这些方法。 Typically you would just add the necessary attributes to your class and add it to the container via a AssemblyCatalog
. 通常,您只需将必要的属性添加到类中,然后通过AssemblyCatalog
将其添加到容器中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.