private static void SetImports(IComponentContext context, ComposablePart composablePart, bool prerequisite)
        {
            foreach (var import in composablePart
                     .ImportDefinitions
                     .Where(id => id.IsPrerequisite == prerequisite))
            {
                if (!(import is ContractBasedImportDefinition cbid))
                {
                    throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, RegistrationExtensionsResources.ContractBasedOnly, import));
                }

                var exportsForContract = context.ResolveExports(cbid);
                composablePart.SetImport(import, exportsForContract);
            }
        }
Exemple #2
0
        static void SetImports(IComponentContext context, ComposablePart composablePart, bool prerequisite)
        {
            foreach (var import in composablePart
                     .ImportDefinitions
                     .Where(id => id.IsPrerequisite == prerequisite))
            {
                var cbid = import as ContractBasedImportDefinition;
                if (cbid == null)
                {
                    throw new NotSupportedException(string.Format(Revenj.Extensibility.Autofac.Integration.Mef.RegistrationExtensionsResources.ContractBasedOnly, import));
                }

                var exportsForContract = context.ResolveExports(cbid);
                composablePart.SetImport(import, exportsForContract);
            }
        }
        static void SetImports(IComponentContext context, ComposablePart composablePart, bool prerequisite)
        {
            foreach (var import in composablePart
                     .ImportDefinitions
                     .Where(id => id.IsPrerequisite == prerequisite))
            {
                var cbid = import as ContractBasedImportDefinition;
                if (cbid == null)
                {
                    throw new NotSupportedException(string.Format("Import '{0}' is not supported: only contract-based imports are supported.", import));
                }

                var exportsForContract = context.ResolveExports(cbid);
                composablePart.SetImport(import, exportsForContract);
            }
        }
Exemple #4
0
 /// <summary>
 /// Locate all of the MEF exports registered as supplying contract type T.
 /// </summary>
 /// <typeparam name="T">The contract type.</typeparam>
 /// <param name="context">The context to resolve exports from.</param>
 /// <returns>A list of exports.</returns>
 public static IEnumerable <Export> ResolveExports <T>(this IComponentContext context)
 {
     return(context.ResolveExports <T>(AttributedModelServices.GetContractName(typeof(T))));
 }