MEF Preview 5 Released
MEF Preview 5 Released
Managed Extensibility Framework(이하 MEF) 의 Preview 5 가 릴리즈 되었습니다. 새로운 기능적인 면 보다는 기존의 체제에 약간의 변경 내역과 불필요한 기능들의 제거 등이 대부분입니다.
그리고 Caching 의 새로운 Infrastructure 로 개량되었으며, Import/Export 의 Contract 방법도 개선된 방법이 추가가 되었습니다. 아래는 MEF Preview 5 의 Release Notes 입니다.
Namespace changes
  • System.ComponentModel.Composition – For part authors. This namespace contains the import and export attributes as well as other APIs that part authors are likely to use.
  • System.ComponentModel.Composition.Hosting – For hosters. This namespace contains the CompositionContainer, catalog implementations, and other APIs that hosters are likely to use.
Part discovery changes
  • CompositionOptionsAttribute and DiscoveryMode have been removed.
  • PartNotDiscoverableAttribute replaces [CompositionOptions(DiscoveryMode = DiscoveryMode.Never)]
  • PartCreationPolicyAttribute can be used to specify part creation policy (Replaces CompositionOptionsAttribute.CreationPolicy)
  • By default, exports on a base class will not be included in the exports for a derived class.
  • The PartExportsInheritedAttribute can be applied to a base class to specify that exports on that class will be included in derived classes. NOTE: If this attribute is used, and both the base and derived class have export attributes applied to them, there will be multiple exports created for the same class. Also note that whatever metadata is applied to the export on the base class can’t be added to or overridden by the derived class
Collection imports
  • ImportManyAttribute should now be used on collection imports (in the future, an ImportAttribute will not be interpreted as a collection import even if it is applied to a collection type).
  • Array imports are now supported.
Typed Imports/Exports
  • Imports and Exports now match on type as well as contract.
  • Exporters of string contracts such as [Export(“Foo”)] must now specify the type they expect to be imported as well. e.g. [Export(“Foo”, typeof(string))]
Method exports
  • Method exports can now be imported as custom delegates in addition to Action<…> and Func<…> delegates
Directory Catalog
  • The directory watching functionality has been removed. The Refresh() method has been added to explicitly update the catalog with new assemblies in the directory.
Removal of Caching / new infrastructure
  • The old caching infrastructure has been removed. We’ve added a general purpose API that allows the implementation of catalog caching as well as supporting builders of custom programming models. The APIs are members of the static class System.ComponentModel.Composition.ReflectionModel.ReflectionModelServices. In the future we plan to ship a sample that shows how these APIs can be used to create cached catalogs.
New sample application
  • MEF Studio – a designer hosting sample.
Common compilation errors to expect when migrating previous code bases
  • System.ComponentModel.Composition.Container does not exist -> Add reference to System.ComponentModel.Composition.Hosting namespace
  • CompositionContainer does not contain method AddPart or Compose -> Need to start using CompositionBatch, or one of the helper extension methods ComposeParts or ComposeExportedObjects
  • CompositionOptionsAttribute does not exist -> For CreationPolicy use PartCreationPolicyAttribute
  • INotifyImportCompleted does not exist -> Use IPartImportsSatisfiedNotification interface and change method from ImportCompleted to OnImportsSatisfied
아래는 MEF Preview 5 에서 새롭게 추가된 MEF Studio 예제입니다. MEF 의 특징을 잘 보여주고 있는 것 같네요.
[그림1] MEF Studio Sample

'.NET > .NET Framework' 카테고리의 다른 글

[MEF] 7. Exports and Metadata  (1) 2009.04.16
[MEF] 6. Lazy Exports  (0) 2009.04.13
MEF Preview 5 Released  (0) 2009.04.09
[MEF] 4. Import 선언  (6) 2009.04.07
ASP.NET 에서 Entity Framework 바인딩 문제  (2) 2009.03.29
[MEF] 3. Export 선언  (0) 2009.03.29

+ Recent posts