Exemplo n.º 1
0
        public static ComposablePartDefinition CreatePartDefinition(Type type, ICompositionElement origin)
        {
            Requires.NotNull(type, nameof(type));
            Contract.Ensures(Contract.Result <ComposablePartDefinition>() != null);

            return(AttributedModelServices.CreatePartDefinition(type, origin, false));
        }
        public void ImportListOfExportWithOnlySingleElementsAvailable_ShouldNotFindExport()
        {
            var container = ContainerFactory.CreateWithAttributedCatalog(typeof(ExportsString), typeof(ImportsListOfExportOfString));
            var importer  = container.GetExportedValue <ImportsListOfExportOfString>();

            Assert.Null(importer.ExportedList);

            var part     = AttributedModelServices.CreatePartDefinition(typeof(ImportsListOfExportOfString), null);
            var contract = AttributedModelServices.GetContractName(typeof(List <Lazy <string> >));

            Assert.Equal(contract, ((ContractBasedImportDefinition)part.ImportDefinitions.First()).ContractName);
        }
        public static ComposablePartDefinition CreatePartDefinition(Type type, ICompositionElement?origin)
        {
            Requires.NotNull(type, nameof(type));

            return(AttributedModelServices.CreatePartDefinition(type, origin, false));
        }
Exemplo n.º 4
0
 private static string[] GetContractNames(IEnumerable <Type> types)
 {
     return(GetContractNames(types.Select(t => AttributedModelServices.CreatePartDefinition(t, null)).SelectMany(p => p.ExportDefinitions)));
 }