private object CreateExportFactory(RuntimePartLifecycleTracker importingPartTracker, RuntimeComposition.RuntimeImport import, RuntimeComposition.RuntimeExport export) { Requires.NotNull(importingPartTracker, nameof(importingPartTracker)); Requires.NotNull(import, nameof(import)); Requires.NotNull(export, nameof(export)); Type importingSiteElementType = import.ImportingSiteElementType; ImmutableHashSet <string> sharingBoundaries = import.ExportFactorySharingBoundaries.ToImmutableHashSet(); bool newSharingScope = sharingBoundaries.Count > 0; Func <KeyValuePair <object?, IDisposable?> > valueFactory = () => { RuntimeExportProvider scope = newSharingScope ? new RuntimeExportProvider(this.composition, this, sharingBoundaries) : this; var exportedValueConstructor = scope.GetExportedValue(import, export, importingPartTracker); exportedValueConstructor.ExportingPart !.GetValueReadyToExpose(); object?constructedValue = exportedValueConstructor.ValueConstructor(); var disposableValue = newSharingScope ? scope : exportedValueConstructor.ExportingPart as IDisposable; return(new KeyValuePair <object?, IDisposable?>(constructedValue, disposableValue)); }; Type?exportFactoryType = import.ImportingSiteTypeWithoutCollection !; var exportMetadata = export.Metadata; return(this.CreateExportFactory(importingSiteElementType, sharingBoundaries, valueFactory, exportFactoryType, exportMetadata)); }
public RuntimePartLifecycleTracker(RuntimeExportProvider owningExportProvider, RuntimeComposition.RuntimePart partDefinition, IReadOnlyDictionary <string, object?> importMetadata, PartLifecycleTracker nonSharedPartOwner) : base(owningExportProvider, nonSharedPartOwner) { Requires.NotNull(partDefinition, nameof(partDefinition)); Requires.NotNull(importMetadata, nameof(importMetadata)); this.partDefinition = partDefinition; this.importMetadata = importMetadata; }