1
// -----------------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation. All rights reserved.
3 // -----------------------------------------------------------------------
5 using System
.Collections
.Generic
;
6 using System
.ComponentModel
.Composition
.Primitives
;
8 using Microsoft
.Internal
;
10 namespace System
.ComponentModel
.Composition
.Hosting
12 partial class CompositionBatch
14 // Represents a part that exports a single export
15 private class SingleExportComposablePart
: ComposablePart
17 private readonly Export _export
;
19 public SingleExportComposablePart(Export export
)
21 Assumes
.NotNull(export
);
23 this._export
= export
;
26 public override IDictionary
<string, object> Metadata
28 get { return MetadataServices.EmptyMetadata; }
31 public override IEnumerable
<ExportDefinition
> ExportDefinitions
33 get { return new ExportDefinition[] { _export.Definition }
; }
36 public override IEnumerable
<ImportDefinition
> ImportDefinitions
38 get { return Enumerable.Empty<ImportDefinition>(); }
41 public override object GetExportedValue(ExportDefinition definition
)
43 Requires
.NotNull(definition
, "definition");
45 if (definition
!= _export
.Definition
)
47 throw ExceptionBuilder
.CreateExportDefinitionNotOnThisComposablePart("definition");
53 public override void SetImport(ImportDefinition definition
, IEnumerable
<Export
> exports
)
55 Requires
.NotNull(definition
, "definition");
56 Requires
.NotNullOrNullElements(exports
, "exports");
58 throw ExceptionBuilder
.CreateImportDefinitionNotOnThisComposablePart("definition");