示例#1
0
        /// <summary>
        /// Retrieve the single <paramref name="contract"/> instance from the
        /// <see cref="CompositionContext"/>.
        /// </summary>
        /// <param name="contract">The contract to retrieve.</param>
        /// <returns>An instance of the export.</returns>
        /// <param name="export">The export if available, otherwise, null.</param>
        /// <exception cref="CompositionFailedException" />
        public override bool TryGetExport(CompositionContract contract, out object export)
        {
            ExportDescriptor defaultForExport;

            if (!_partRegistry.TryGetSingleForExport(contract, out defaultForExport))
            {
                export = null;
                return(false);
            }

            export = CompositionOperation.Run(this, defaultForExport.Activator);
            return(true);
        }