当前位置: 首页>>代码示例>>C#>>正文


C# ContainerConfiguration.GetExport方法代码示例

本文整理汇总了C#中ContainerConfiguration.GetExport方法的典型用法代码示例。如果您正苦于以下问题:C# ContainerConfiguration.GetExport方法的具体用法?C# ContainerConfiguration.GetExport怎么用?C# ContainerConfiguration.GetExport使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ContainerConfiguration的用法示例。


在下文中一共展示了ContainerConfiguration.GetExport方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Implementation

		public void Implementation()
		{
			var types = new[] { typeof(Implemented) }.AsApplicationParts();
			var container = new ContainerConfiguration().WithParts( types.AsEnumerable() ).WithProvider( SingletonExportDescriptorProvider.Default ).CreateContainer();
			Assert.Same( Implemented.Default, container.GetExport<ISingleton>() );
			Assert.Same( Implemented.Default, container.GetExport<Implemented>() );
		}
开发者ID:DevelopersWin,项目名称:VoteReporter,代码行数:7,代码来源:SingletonExportDescriptorProviderTests.cs

示例2: Basic

		public void Basic()
		{
			var types = new[] { typeof(Singleton) }.AsApplicationParts();
			var container = new ContainerConfiguration().WithParts( types.AsEnumerable() ).WithProvider( SingletonExportDescriptorProvider.Default ).CreateContainer();
			var export = container.GetExport<Singleton>();
			Assert.Same( Singleton.Default, export );
		}
开发者ID:DevelopersWin,项目名称:VoteReporter,代码行数:7,代码来源:SingletonExportDescriptorProviderTests.cs

示例3: ProvidersCanDetectAbsenceOfAContractItSupports

        public void ProvidersCanDetectAbsenceOfAContractItSupports()
        {
            var container = new ContainerConfiguration()
                .WithProvider(new DefaultObjectExportDescriptorProvider())
                .CreateContainer();

            var o = container.GetExport<object>();
            Assert.Equal(DefaultObjectExportDescriptorProvider.DefaultObject, o);
        }
开发者ID:ChuangYang,项目名称:corefx,代码行数:9,代码来源:ExportDescriptorProviderTests.cs

示例4: ProvidersCanLocateImplementationsOfAContractItSupports

        public void ProvidersCanLocateImplementationsOfAContractItSupports()
        {
            var container = new ContainerConfiguration()
                .WithProvider(new DefaultObjectExportDescriptorProvider())
                .WithPart<ExportsObject>()
                .CreateContainer();

            var o = container.GetExport<object>();
            Assert.NotEqual(DefaultObjectExportDescriptorProvider.DefaultObject, o);
        }
开发者ID:ChuangYang,项目名称:corefx,代码行数:10,代码来源:ExportDescriptorProviderTests.cs

示例5: MetadataViewsCanCarryDefaultValues

        public void MetadataViewsCanCarryDefaultValues()
        {
            var cc = new ContainerConfiguration()
                        .WithPart<HasNoName>()
                        .CreateContainer();

            var hn = cc.GetExport<Lazy<HasNoName, OptionallyNamed>>();

            Assert.Equal("B", hn.Metadata.Name);
        }
开发者ID:ChuangYang,项目名称:corefx,代码行数:10,代码来源:MetadataViewGenerationTests.cs

示例6: AConcreteTypeWithDictionaryConstructorIsAMetadataView

        public void AConcreteTypeWithDictionaryConstructorIsAMetadataView()
        {
            var cc = new ContainerConfiguration()
                        .WithPart<HasNameA>()
                        .CreateContainer();

            var hn = cc.GetExport<Lazy<HasNameA, DictionaryName>>();

            Assert.Equal("A", hn.Metadata.RetrievedName);
        }
开发者ID:ChuangYang,项目名称:corefx,代码行数:10,代码来源:MetadataViewGenerationTests.cs

示例7: AConcreteTypeWithWritablePropertiesIsAMetadataView

        public void AConcreteTypeWithWritablePropertiesIsAMetadataView()
        {
            var cc = new ContainerConfiguration()
                        .WithPart<HasNameA>()
                        .CreateContainer();

            var hn = cc.GetExport<Lazy<HasNameA, Named>>();

            Assert.Equal("A", hn.Metadata.Name);
        }
开发者ID:ChuangYang,项目名称:corefx,代码行数:10,代码来源:MetadataViewGenerationTests.cs

示例8: AConcreteTypeWithUnsupportedConstructorsCannotBeUsedAsAMetadataView

        public void AConcreteTypeWithUnsupportedConstructorsCannotBeUsedAsAMetadataView()
        {
            var cc = new ContainerConfiguration()
                        .WithPart<HasNameA>()
                        .CreateContainer();

            var x = Assert.Throws<CompositionFailedException>(() => cc.GetExport<Lazy<HasNoName, InvalidConcreteView>>());

            Assert.Equal("The type 'InvalidConcreteView' cannot be used as a metadata view. A metadata view must be a concrete class with a parameterless or dictionary constructor.", x.Message);
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:10,代码来源:MetadataViewGenerationTests.cs

示例9: Application_Start

        protected void Application_Start()
        {
            SetupAutoMapper();
            var container = new ContainerConfiguration()
                                    .WithAssembly(typeof(WebApiApplication).Assembly)
                                    .CreateContainer();

            var resolver = new StandaloneDependencyResolver(container);
            GlobalConfiguration.Configuration.DependencyResolver = resolver;
            GlobalConfiguration.Configure(container.GetExport<WebApiConfig>().Register);
        }
开发者ID:mimipaskova,项目名称:Azure-Tech-Entrepreneurship-Course,代码行数:11,代码来源:Global.asax.cs

示例10: GetOperation

        public override Action GetOperation()
        {
            var c = new ContainerConfiguration()
                .WithPart(typeof(X))
                .CreateContainer();

            return () =>
            {
                c.GetExport<X>();
            };
        }
开发者ID:ChuangYang,项目名称:corefx,代码行数:11,代码来源:ShootoutWithNewBenchmark.cs

示例11: Basic

		public void Basic()
		{
			var parts = this.Adapt().WithNested().Append( typeof(Protected) ).AsApplicationParts();
			var builder = ConventionBuilderFactory.Default.Get();
			var container = new ContainerConfiguration().WithParts( parts.AsEnumerable(), builder ).WithProvider( ServicesExportDescriptorProvider.Default ).CreateContainer();
			new EnableServicesCommand().Execute();
			var dependency = container.GetExport<Dependency>();
			Assert.NotNull( dependency );

			var export = container.GetExport<IPrimary>();
			var primary = Assert.IsType<Primary>( export );
			Assert.Equal( 2, primary.Selected.GetParameters().Length );

			var exported = container.GetExport<Exported>();
			Assert.Equal( 3, exported.Selected.GetParameters().Length );

			var external = container.GetExport<ExternalDependencyExport>();
			Assert.Equal( 3, external.Selected.GetParameters().Length );

			Assert.Throws<CompositionFailedException>( () => container.GetExport<Protected>() );
		}
开发者ID:DevelopersWin,项目名称:VoteReporter,代码行数:21,代码来源:ConstructorSelectorTests.cs

示例12: Shared

		public void Shared()
		{
			var parts = new[] { typeof(IHelloWorldShared), typeof(HelloWorldShared) }.AsApplicationParts();
			
			var container = new ContainerConfiguration().WithParts( parts.ToArray(), ConventionBuilderFactory.Default.Get() ).CreateContainer();
			var export = container.GetExport<IHelloWorldShared>();
			Assert.IsType<HelloWorldShared>( export );
			Assert.Same( export, container.GetExport<IHelloWorldShared>() );
			Assert.Same( container.GetExport<HelloWorldShared>(), container.GetExport<HelloWorldShared>() );
			Assert.Same( container.GetExport<HelloWorldShared>(), container.GetExport<IHelloWorldShared>() );
			
		}
开发者ID:DevelopersWin,项目名称:VoteReporter,代码行数:12,代码来源:ConventionTests.cs

示例13: GetCompositionOperation

        public override Func<Tuple<object, Action>> GetCompositionOperation()
        {
            var container = new ContainerConfiguration()
                .WithParts(new[]{
                    typeof(WebServer),
                    typeof(Web.OperationRoot),
                    typeof(Web.GlobalA),
                    typeof(Web.GlobalB),
                    typeof(Web.Transient),
                    typeof(Web.Wide),
                    typeof(Web.A),
                    typeof(Web.B),
                    typeof(Web.Long),
                    typeof(Web.TailA),
                    typeof(Web.TailB),
                    typeof(Web.TailC)})
                .CreateContainer();

            var sf = container.GetExport<WebServer>().WebScopeFactory;
            return () =>
            {
                var x = sf.CreateExport();
                return Tuple.Create<object, Action>(x.Value, x.Dispose);
            };
        }
开发者ID:ChuangYang,项目名称:corefx,代码行数:25,代码来源:WebBenchmarks.cs

示例14: WithoutConvention

		public void WithoutConvention()
		{
			var parts = new[] { typeof(IHelloWorld), typeof(HelloWorld) }.AsApplicationParts();
			var container = new ContainerConfiguration().WithParts( parts.ToArray() ).CreateContainer();
			Assert.Throws<CompositionFailedException>( () => container.GetExport<IHelloWorld>() );
		}
开发者ID:DevelopersWin,项目名称:VoteReporter,代码行数:6,代码来源:ConventionTests.cs

示例15: UnsupportedMetadataViewMessageIsInformative

 public void UnsupportedMetadataViewMessageIsInformative()
 {
     var cc = new ContainerConfiguration().WithParts(typeof(ImportsWithMetadataInterface), typeof(ExportsWithMetadata)).CreateContainer();
     var x = Assert.Throws<CompositionFailedException>(() => cc.GetExport<ImportsWithMetadataInterface>());
     Assert.Equal("The type 'INamed' cannot be used as a metadata view. A metadata view must be a concrete class with a parameterless or dictionary constructor.", x.Message);
 }
开发者ID:ChuangYang,项目名称:corefx,代码行数:6,代码来源:MetadataViewGenerationTests.cs


注:本文中的ContainerConfiguration.GetExport方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。