English 中文(简体)
进口到堆肥后制造的物体
原标题:Mef import into objects created after compose

我在集装箱的开端和后来制造了具有进口财产的物体。 当我试图使用该财产时,该财产就属于纽尔。

How does MEF handle objects created later on. I refuse to believe you have to instantiate all objects at startup.

最佳回答

当你创建集装箱时,你就不必制造这样的情况,这对任何人都没有任何真正的帮助。 你如何制造你的事例? 以下是一些例子:

[Export]
public class MyClass
{
    [Import]
    public MyOtherClass OtherClass { get; set; }
}

我可以:

var myClass = container.GetExportedValue<MyClass>(); // This would automatically compose.

var myExport = container.GetExport<MyClass>();
var myClass = myExport.Value; // This would automatically compose.

var myClass = new MyClass();
container.SatisfyImportsOnce(myClass); // Manually compose your part.

或人工风能,全方使用<条码>CompositionBatch等。

问题回答

暂无回答




相关问题
Can t load multiple MEF parts

I have a Winforms desktop application that is loading multiple MEF parts with the same Interface type. Problem: When I try to load more than one of the same type I get the following exception: The ...

MEF + WCF Service Host?

I am just getting into MEF and I have come across a problem that I cannot resolve. I have a windows service that is reading in my DLLs (via MEF) and each DLL is a WCF Service Host. When I run my ...

MEF: Where should I put the CompositionContainer?

I have been using the Windsor IoC Container for my web-based application, to resolve the data access layer implementation the application should use. The web application s UI will consist of pages, ...

MEF如何确定其进口顺序?

MEF允许你通过使用进口管理特性进口多个部件。 如何确定它收回相关出口的顺序,并增加这些出口量,以达到你所知道的数量......

How-To Prevent Module Duplicates with MEF?

How can i prevent from MEF to load duplicates Modules in the case of the presence of 2 copies of the same Assembly (maybe by mistake) Assembly1.dll Assembly2.dll (copy of Assembly1) [ImportMany] ...

Basic MEF workflow/usage

I m looking to a framework which will allow me to have a simple plugin system in my .NET application. It seems MEF is the framework which Microsoft is endorsing, and will become part of .NET 4 (it ...

热门标签