예제 #1
0
        private object GetExportedValue(ComposablePart part, ExportDefinition export)
        {
            ThrowIfDisposed();
            EnsureRunning();

            return(CompositionServices.GetExportedValueFromComposedPart(ImportEngine, part, export));
        }
        private object GetExportedValue(CatalogPart part, ExportDefinition export, bool isSharedPart)
        {
            ThrowIfDisposed();
            EnsureRunning();

            Assumes.NotNull(part, export);

            // We don't protect against thread racing here, as "importsSatisfied" is merely an optimization
            // if two threads satisfy imports twice, the results is the same, just the perf hit is heavier.

            bool         importsSatisfied = part.ImportsSatisfied;
            ImportEngine importEngine     = importsSatisfied ? null : _importEngine;

            object exportedValue = CompositionServices.GetExportedValueFromComposedPart(
                importEngine, part.Part, export);

            if (!importsSatisfied)
            {
                // and set "ImportsSatisfied" to true
                part.ImportsSatisfied = true;
            }

            // Only hold conditional references for recomposable non-shared parts because we are
            // already holding strong references to the shared parts.
            if (exportedValue != null && !isSharedPart && part.Part.IsRecomposable())
            {
                PreventPartCollection(exportedValue, part.Part);
            }

            return(exportedValue);
        }
예제 #3
0
        private object GetExportedValue(ComposablePart part, ExportDefinition export, bool isSharedPart)
        {
            this.ThrowIfDisposed();
            this.EnsureRunning();

            Assumes.NotNull(part, export);

            object exportedValue = CompositionServices.GetExportedValueFromComposedPart(
                this._importEngine, part, export);

            // Only hold conditional references for recomposable non-shared parts because we are
            // already holding strong references to the shared parts.
            if (exportedValue != null && !isSharedPart && part.IsRecomposable())
            {
                SetConditionalReferenceForRecomposablePart(exportedValue, part);
            }

            return(exportedValue);
        }