示例#1
0
        public NonEmptyRegistry()
        {
            Part()
            .ForTypesMatching(x => x.Equals(typeof(FakePart)))
            .AddMetadata(new { Foo = "Bar" })
            .MakeShared()
            .ImportConstructor()
            .Exports(x =>
            {
                x.Export()
                .Members(m => new[] { ReflectionServices.GetProperty <FakePart>(z => z.Delegate) })
                .AddMetadata(new { Name = "Delegate" });
                x.Export()
                .Members(m => new[] { ReflectionServices.GetProperty <FakePart>(z => z.Name) })
                .AddMetadata(new { Name = "Name" });
            })
            .Imports(x =>
            {
                x.Import()
                .Members(m => new[] { ReflectionServices.GetProperty <FakePart>(z => z.Delegate) })
                .RequireMetadata <string>("Name")
                .AllowDefaultValue()
                .Recomposable();
                x.Import()
                .Members(m => new[] { ReflectionServices.GetProperty <FakePart>(z => z.Name) })
                .RequireMetadata <string>("Description");
                x.Import()
                .Members(m => new[] { ReflectionServices.GetProperty <FakePart>(z => z.Values) });
            });

            Part()
            .ForTypesMatching(x => false);

            ContractService.Configure(x => {
                x.ForType <Func <string, string, object> >().ContractType <FakePart>().ContractName("Test");
                x.ForType <string>().ContractType <FakePart>().ContractName("Test");
            });

            //Scan(x => {
            //    x.ExecutingAssembly();
            //    x.Assembly
            //})

            var scanner =
                new TypeScanner();

            scanner.AddTypes(() => Assembly.GetExecutingAssembly().GetExportedTypes());

            this.TypeScanner = scanner;
        }
        public NonEmptyRegistry()
        {
            Part()
                .ForTypesMatching(x => x.Equals(typeof(FakePart)))
                .AddMetadata(new { Foo = "Bar" })
                .MakeShared()
                .ImportConstructor()
                .Exports(x =>
                {
                    x.Export()
                        .Members(m => new[] { ReflectionServices.GetProperty<FakePart>(z => z.Delegate) })
                        .AddMetadata(new { Name = "Delegate" });
                    x.Export()
                        .Members(m => new[] { ReflectionServices.GetProperty<FakePart>(z => z.Name) })
                        .AddMetadata(new { Name = "Name" });
                })
                .Imports(x =>
                {
                    x.Import()
                        .Members(m => new[] { ReflectionServices.GetProperty<FakePart>(z => z.Delegate) })
                        .RequireMetadata<string>("Name")
                        .AllowDefaultValue()
                        .Recomposable();
                    x.Import()
                        .Members(m => new[] { ReflectionServices.GetProperty<FakePart>(z => z.Name) })
                        .RequireMetadata<string>("Description");
                    x.Import()
                        .Members(m => new[] { ReflectionServices.GetProperty<FakePart>(z => z.Values) });
                });

            Part()
                .ForTypesMatching(x => false);

            ContractService.Configure(x => {
                x.ForType<Func<string, string, object>>().ContractType<FakePart>().ContractName("Test");
                x.ForType<string>().ContractType<FakePart>().ContractName("Test");
            });

            //Scan(x => {
            //    x.ExecutingAssembly();
            //    x.Assembly
            //})

            var scanner =
                 new TypeScanner();
            scanner.AddTypes(() => Assembly.GetExecutingAssembly().GetExportedTypes());

            this.TypeScanner = scanner;
        }