| File: System\Composition\Hosting\InstanceExportDescriptorProvider.cs | Web Access |
| Project: src\runtime\src\libraries\System.Composition.TypedParts\src\System.Composition.TypedParts.csproj (System.Composition.TypedParts) |
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; using System.Composition.Hosting.Core; namespace System.Composition.Hosting { internal sealed class InstanceExportDescriptorProvider : SinglePartExportDescriptorProvider { private readonly object _exportedInstance; public InstanceExportDescriptorProvider(object exportedInstance, Type contractType, string contractName, IDictionary<string, object> metadata) : base(contractType, contractName, metadata) { _exportedInstance = exportedInstance; } public override IEnumerable<ExportDescriptorPromise> GetExportDescriptors(CompositionContract contract, DependencyAccessor descriptorAccessor) { if (IsSupportedContract(contract)) yield return new ExportDescriptorPromise(contract, _exportedInstance.ToString(), true, NoDependencies, _ => ExportDescriptor.Create((c, o) => _exportedInstance, Metadata)); } } }