Beispiel #1
0
        public void SatisfyImportsOnceWithExportFactoryOfCreationPolicyAny(IContainer container)
        {
            MefV1.Hosting.CompositionContainer v1Container = GetMefV1Container(container);

            var receiver = new SatisfyImportsOnceWithExportFactoryOfCreationPolicyAnyReceiver();

            MefV1.AttributedModelServices.SatisfyImportsOnce(v1Container, receiver);
            Assert.NotNull(receiver.AppleFactory);
            MefV1.ExportLifetimeContext <ApplePartCreationAny> apple1 = receiver.AppleFactory.CreateExport();
            Assert.NotNull(apple1);
            Assert.NotNull(apple1.Value);
            MefV1.ExportLifetimeContext <ApplePartCreationAny> apple2 = receiver.AppleFactory.CreateExport();
            Assert.NotNull(apple2);
            Assert.NotNull(apple2.Value);

            Assert.NotSame(apple1, apple2);
            Assert.NotSame(apple1.Value, apple2.Value);
        }
Beispiel #2
0
        public void SatisfyImportsOnceWithListOfExportFactoryOfOpenGenericExport(IContainer container)
        {
            MefV1.Hosting.CompositionContainer v1Container = GetMefV1Container(container);

            var receiver = new SatisfyImportsOnceWithListOfExportFactoryOfOpenGenericExportReceiver();

            MefV1.AttributedModelServices.SatisfyImportsOnce(v1Container, receiver);
            Assert.NotNull(receiver.OrangeTreeFactories);
            Assert.Equal(1, receiver.OrangeTreeFactories.Count);
            MefV1.ExportLifetimeContext <Tree <Orange> > orangeTree1 = receiver.OrangeTreeFactories[0].CreateExport();
            Assert.NotNull(orangeTree1);
            Assert.NotNull(orangeTree1.Value);
            MefV1.ExportLifetimeContext <Tree <Orange> > orangeTree2 = receiver.OrangeTreeFactories[0].CreateExport();
            Assert.NotNull(orangeTree2);
            Assert.NotNull(orangeTree2.Value);

            Assert.NotSame(orangeTree1, orangeTree2);
            Assert.NotSame(orangeTree1.Value, orangeTree2.Value);
        }
Beispiel #3
0
        public void SatisfyImportsOnceWithListOfExportFactory(IContainer container)
        {
            MefV1.Hosting.CompositionContainer v1Container = GetMefV1Container(container);

            var receiver = new SatisfyImportsOnceWithListOfExportFactoryReceiver();

            MefV1.AttributedModelServices.SatisfyImportsOnce(v1Container, receiver);
            Assert.NotNull(receiver.AppleFactories);
            Assert.Equal(1, receiver.AppleFactories.Count);
            MefV1.ExportLifetimeContext <Apple> apple1 = receiver.AppleFactories[0].CreateExport();
            Assert.NotNull(apple1);
            Assert.NotNull(apple1.Value);
            MefV1.ExportLifetimeContext <Apple> apple2 = receiver.AppleFactories[0].CreateExport();
            Assert.NotNull(apple2);
            Assert.NotNull(apple2.Value);

            Assert.NotSame(apple1, apple2);
            Assert.NotSame(apple1.Value, apple2.Value);
        }
Beispiel #4
0
        public void SatisfyImportsOnceWithExportFactoryAndMetadata(IContainer container)
        {
            MefV1.Hosting.CompositionContainer v1Container = GetMefV1Container(container);

            var receiver = new SatisfyImportsOnceWithExportFactoryMetadataReceiver();

            MefV1.AttributedModelServices.SatisfyImportsOnce(v1Container, receiver);
            Assert.NotNull(receiver.TreeFactory);
            Assert.Equal("b", receiver.TreeFactory.Metadata["A"]);
            MefV1.ExportLifetimeContext <Tree> tree1 = receiver.TreeFactory.CreateExport();
            Assert.NotNull(tree1);
            Assert.NotNull(tree1.Value);
            MefV1.ExportLifetimeContext <Tree> tree2 = receiver.TreeFactory.CreateExport();
            Assert.NotNull(tree2);
            Assert.NotNull(tree2.Value);

            Assert.NotSame(tree1, tree2);
            Assert.NotSame(tree1.Value, tree2.Value);
            Assert.NotSame(tree1.Value.Apple, tree2.Value.Apple);
        }
Beispiel #5
0
 public override MefV1.Primitives.ComposablePart CreatePart()
 {
     MefV1.ExportLifetimeContext <object> value = this.exportFactory.CreateExport();
     return(new ComposablePartForExportFactory(value));
 }
Beispiel #6
0
 internal ComposablePartForExportFactory(MefV1.ExportLifetimeContext <object> value)
 {
     this.value = value;
 }