Export is a component (part) that provides a value (values) to another part through a container (Container). The Export attribute modifies a class, field, property, or method, and the Import attribute can decorate a field, property, or constructor parameter.
For the export and import to match, both parties need to use the same contract, which includes the contract name and contract Type. Both are explicit implicit. Experience the code below
Public class myclass{ [Import] publicgetset;} [Export (typeof(IMyAddin))] Public class Mylogger:imyaddin {} // Won't match the previous import! Public class Mylogger:imyaddin {} }
Import the Export field. It is important to note that the import and export need to have the same contracttype, if the contractname is consistent, the type is inconsistent and still cannot be used
Public classmyclass{[Import ("MajorRevision")] Public intMajorRevision {Get;Set; }} Public classmyexportclass{[Export ("MajorRevision")]//This one would match. Public intMajorRevision =4; [Export ("minorrevision")] Public intMinorrevision = -;}
Types of Imports
MEF Basic Concepts