protected override IEnumerable <MefV1.Primitives.Export> GetExportsCore(MefV1.Primitives.ImportDefinition definition, MefV1.Hosting.AtomicComposition atomicComposition) { var v3ImportDefinition = WrapImportDefinition(definition); var result = ImmutableList.CreateBuilder <MefV1.Primitives.Export>(); var exports = this.exportProvider.GetExports(v3ImportDefinition); return(exports.Select(UnwrapExport).ToArray()); }
/// <summary> /// Recupera o politica de criação requerida. /// </summary> /// <param name="definition"></param> /// <returns></returns> internal static CreationPolicy GetRequiredCreationPolicy(this System.ComponentModel.Composition.Primitives.ImportDefinition definition) { var definition2 = definition as System.ComponentModel.Composition.Primitives.ContractBasedImportDefinition; if (definition2 != null) { return(definition2.RequiredCreationPolicy); } return(CreationPolicy.Any); }
protected override IEnumerable <MefV1.Primitives.Export> GetExportsCore(MefV1.Primitives.ImportDefinition definition, MefV1.Hosting.AtomicComposition atomicComposition) { var result = base.GetExportsCore(definition, atomicComposition); if ((definition.Cardinality == MefV1.Primitives.ImportCardinality.ExactlyOne && result.Count() != 1) || (definition.Cardinality == MefV1.Primitives.ImportCardinality.ZeroOrOne && result.Count() > 1)) { // Set breakpoint here } return(result); }
private static ImportDefinition WrapImportDefinition(MefV1.Primitives.ImportDefinition definition) { Requires.NotNull(definition, nameof(definition)); var contractImportDefinition = definition as MefV1.Primitives.ContractBasedImportDefinition; var constraints = ImmutableHashSet <IImportSatisfiabilityConstraint> .Empty .Add(new ImportConstraint(definition)); if (contractImportDefinition != null) { constraints = constraints.Union(PartCreationPolicyConstraint.GetRequiredCreationPolicyConstraints(WrapCreationPolicy(contractImportDefinition.RequiredCreationPolicy))); } // Do NOT propagate the cardinality otherwise the export provider will throw // if the cardinality is not met. But it's not our job to throw, since the caller // is going to aggregate our response with other export providers and finally // be responsible for throwing if the ultimate receiver of the result doesn't // get what they expect. // We use ZeroOrMore to indicate we'll accept any response. var cardinality = ImportCardinality.ZeroOrMore; var metadata = (IReadOnlyDictionary <string, object>)definition.Metadata; MefV1.Primitives.ImportDefinition productImportDefinitionV1 = GetExportFactoryProductImportDefinitionIfApplicable(definition); if (productImportDefinitionV1 != null) { var productImportDefinitionV3 = WrapImportDefinition(productImportDefinitionV1); metadata = metadata.ToImmutableDictionary() .Add(CompositionConstants.ExportFactoryProductImportDefinition, productImportDefinitionV3) .Add(CompositionConstants.ExportFactoryTypeMetadataName, ExportFactoryV1Type); } return(new ImportDefinition(definition.ContractName, cardinality, metadata, constraints)); }
internal ImportConstraint(MefV1.Primitives.ImportDefinition definition) { Requires.NotNull(definition, nameof(definition)); this.definition = definition; }
public override void SetImport(MefV1.Primitives.ImportDefinition definition, IEnumerable <MefV1.Primitives.Export> exports) { throw new NotImplementedException(); }
/// <summary> /// Extracts the ImportDefinition for the T in an ExportFactory{T} import, if applicable. /// </summary> /// <param name="definition">The ImportDefinition which may be an ExportFactory.</param> /// <returns>The import definition that describes the created part, or <c>null</c> if the import definition isn't an ExportFactory.</returns> private static MefV1.Primitives.ImportDefinition GetExportFactoryProductImportDefinitionIfApplicable(MefV1.Primitives.ImportDefinition definition) { #if NET45 // The optimal path that we can code for at the moment is using the internal interface. if (IPartCreatorImportDefinition_MightFail != null && ProductImportDefinition_MightFail != null) { if (IPartCreatorImportDefinition_MightFail.IsInstanceOfType(definition)) { return((MefV1.Primitives.ImportDefinition)ProductImportDefinition_MightFail.GetValue(definition)); } } else { // The internal interface, or its member, is gone. Fallback to using the public API that throws. try { if (ReflectionModelServices.IsExportFactoryImportDefinition(definition)) { return(ReflectionModelServices.GetExportFactoryProductImportDefinition(definition)); } } catch (ArgumentException) { // In .NET 4.5, ReflectionModelServices.IsExportFactoryImportDefinition throws // rather than simply returning false when the ImportDefinition is of the incorrect type. // This was fixed in .NET 4.6 with this bug: // Bug 1005218: ReflectionModelServices.IsExportFactoryImportDefinition should not throw ArgumentException } } return(null); #else return(ReflectionModelServices.IsExportFactoryImportDefinition(definition) ? ReflectionModelServices.GetExportFactoryProductImportDefinition(definition) : null); #endif }
public override IEnumerable <Tuple <System.ComponentModel.Composition.Primitives.ComposablePartDefinition, System.ComponentModel.Composition.Primitives.ExportDefinition> > GetExports(System.ComponentModel.Composition.Primitives.ImportDefinition definition) { return(default(IEnumerable <Tuple <System.ComponentModel.Composition.Primitives.ComposablePartDefinition, System.ComponentModel.Composition.Primitives.ExportDefinition> >)); }
/// <summary> /// Extracts the ImportDefinition for the T in an ExportFactory{T} import, if applicable. /// </summary> /// <param name="definition">The ImportDefinition which may be an ExportFactory.</param> /// <returns>The import definition that describes the created part, or <c>null</c> if the import definition isn't an ExportFactory.</returns> private static MefV1.Primitives.ImportDefinition GetExportFactoryProductImportDefinitionIfApplicable(MefV1.Primitives.ImportDefinition definition) { // The optimal path that we can code for at the moment is using the internal interface. if (IPartCreatorImportDefinition_MightFail != null && ProductImportDefinition_MightFail != null) { if (IPartCreatorImportDefinition_MightFail.IsInstanceOfType(definition)) { return((MefV1.Primitives.ImportDefinition)ProductImportDefinition_MightFail.GetValue(definition)); } } else { // The internal interface, or its member, is gone. Fallback to using the public API that throws. try { if (ReflectionModelServices.IsExportFactoryImportDefinition(definition)) { return(ReflectionModelServices.GetExportFactoryProductImportDefinition(definition)); } } catch (ArgumentException) { // MEFv1 throws rather than simply returning false when the ImportDefinition is of the incorrect type. } } return(null); }
public static Lazy <System.Reflection.ParameterInfo> GetImportingParameter(System.ComponentModel.Composition.Primitives.ImportDefinition importDefinition) { return(default(Lazy <System.Reflection.ParameterInfo>)); }
/// <summary> /// Extracts the ImportDefinition for the T in an ExportFactory{T} import, if applicable. /// </summary> /// <param name="definition">The ImportDefinition which may be an ExportFactory.</param> /// <returns>The import definition that describes the created part, or <c>null</c> if the import definition isn't an ExportFactory.</returns> private static MefV1.Primitives.ImportDefinition GetExportFactoryProductImportDefinitionIfApplicable(MefV1.Primitives.ImportDefinition definition) { return(ReflectionModelServices.IsExportFactoryImportDefinition(definition) ? ReflectionModelServices.GetExportFactoryProductImportDefinition(definition) : null); }
public bool TryGetExports(System.ComponentModel.Composition.Primitives.ImportDefinition definition, AtomicComposition atomicComposition, out IEnumerable <System.ComponentModel.Composition.Primitives.Export> exports) { exports = default(IEnumerable <System.ComponentModel.Composition.Primitives.Export>); return(default(bool)); }
protected abstract IEnumerable <System.ComponentModel.Composition.Primitives.Export> GetExportsCore(System.ComponentModel.Composition.Primitives.ImportDefinition definition, AtomicComposition atomicComposition);
public IEnumerable <System.ComponentModel.Composition.Primitives.Export> GetExports(System.ComponentModel.Composition.Primitives.ImportDefinition definition, AtomicComposition atomicComposition) { return(default(IEnumerable <System.ComponentModel.Composition.Primitives.Export>)); }
public static bool IsImportingParameter(System.ComponentModel.Composition.Primitives.ImportDefinition importDefinition) { return(default(bool)); }
protected override IEnumerable <System.ComponentModel.Composition.Primitives.Export> GetExportsCore(System.ComponentModel.Composition.Primitives.ImportDefinition definition, AtomicComposition atomicComposition) { return(default(IEnumerable <System.ComponentModel.Composition.Primitives.Export>)); }
public static LazyMemberInfo GetImportingMember(System.ComponentModel.Composition.Primitives.ImportDefinition importDefinition) { return(default(LazyMemberInfo)); }