Exemplo n.º 1
0
 protected override IContainer CreateContainerAdapter()
 {
     var container = new CompositionContainer();
     var adapter = new MEFAdapter(container, true).WithProxyFactory<StubProxyFactory>();
     IoC.Initialize(adapter);
     return adapter;
 }
Exemplo n.º 2
0
		public void proxycatalog_should_replace_parts()
		{
			var catalog = new AssemblyCatalog(Assembly.GetAssembly(typeof(ExportedClass)));
			var proxycatalog = new ProxyCatalog(catalog);
			var container = new CompositionContainer(proxycatalog);

			var adapter = new MEFAdapter(container).WithProxyFactory<DynamicProxyFactory>();
            IoC.Initialize(adapter);

			var vm = container.GetExportedValue<ExportedClass>();
			Assert.That(vm, Is.InstanceOfType(typeof(INotifyPropertyChanged)));
		}
Exemplo n.º 3
0
		public void can_register_through_adapter_using_proxyfactory()
		{
			var catalog = new AssemblyCatalog(Assembly.GetAssembly(typeof(ClassWithBehaviour)));
			var proxycatalog = new ProxyCatalog(catalog);
			var container = new CompositionContainer(proxycatalog);

			var adapter = new MEFAdapter(container).WithProxyFactory<DynamicProxyFactory>();
            IoC.Initialize(adapter);

			adapter.Register(new[] { new PerRequest { Service = typeof(ClassWithBehaviour), Implementation = typeof(ClassWithBehaviour) } });

			var vm = container.GetExportedValue<ClassWithBehaviour>();
			Assert.That(vm, Is.InstanceOfType(typeof(INotifyPropertyChanged)));
		}
Exemplo n.º 4
0
		public void register_through_adapter_using_proxyfactory_can_resolve_perrequest()
		{
			var catalog = new AssemblyCatalog(Assembly.GetAssembly(typeof(ClassWithBehaviour)));
			var proxycatalog = new ProxyCatalog(catalog);
			var container = new CompositionContainer(proxycatalog);

			var adapter = new MEFAdapter(container).WithProxyFactory<DynamicProxyFactory>();
            IoC.Initialize(adapter);

			adapter.Register(new[] { new PerRequest { Service = typeof(ClassWithBehaviour), Implementation = typeof(ClassWithBehaviour) } });

			var sl = (IServiceLocator)adapter;
			var instance1 = sl.GetInstance<ClassWithBehaviour>();
			var instance2 = sl.GetInstance<ClassWithBehaviour>();

			Assert.AreNotSame(instance1, instance2);
		}