コード例 #1
0
        public PerspexWiringContext(ITypeFactory typeFactory)
        {
            var featureProvider = new TypeFeatureProvider(GetContentPropertyProvider(), GetConverterProvider());

            var xamlNamespaceRegistry = CreateXamlNamespaceRegistry();
            var perspexPropertyBinder = new PerspexPropertyBinder(featureProvider.ConverterProvider);
            var xamlTypeRepository    = new PerspexTypeRepository(xamlNamespaceRegistry, typeFactory, featureProvider, perspexPropertyBinder);
            var typeContext           = new TypeContext(xamlTypeRepository, xamlNamespaceRegistry, typeFactory);

            _context = new WiringContext(typeContext, featureProvider);
        }
コード例 #2
0
        private static ITypeContext CreateTypeContext(ITypeFactory typeFactory, TypeFeatureProvider featureProvider)
        {
            var xamlNamespaceRegistry = CreateXamlNamespaceRegistry();
            var typeRepository        = new PerspexTypeRepository(xamlNamespaceRegistry, typeFactory, featureProvider);

            typeRepository.RegisterMetadata(new Metadata <Setter>().WithMemberDependency(x => x.Value, x => x.Property));
            typeRepository.RegisterMetadata(
                new Metadata <SelectingItemsControl>()
                .WithMemberDependency(x => x.SelectedIndex, x => x.Items)
                .WithMemberDependency(x => x.SelectedItem, x => x.Items));

            return(new TypeContext(typeRepository, xamlNamespaceRegistry, typeFactory));
        }
コード例 #3
0
        public TestRuntimeTypeSource()
        {
            var namespaceRegistry = CreateNamespaceRegistry();

            var featureProvider = new TypeFeatureProvider(new TypeConverterProvider());

            featureProvider.FillFromAttributes(ScannedAssemblies.AllExportedTypes());
            testTypeRepository = new TestTypeRepository(namespaceRegistry, new TypeFactory(), featureProvider);

            inner = new RuntimeTypeSource(testTypeRepository, namespaceRegistry);
            inner.RegisterPrefix(new PrefixRegistration("", "root"));
            inner.RegisterPrefix(new PrefixRegistration("x", "another"));
        }
コード例 #4
0
        private static IRuntimeTypeSource CreateRuntimeTypeSource()
        {
            var typeFactory = new MultiFactory(
                new List <TypeFactoryRegistration>
            {
                new TypeFactoryRegistration(new TypeFactory(), type => type != typeof(ChildClass)),
                new TypeFactoryRegistration(new TypeFactoryMock((type, args) => new ChildClass {
                    Name = "InnerName"
                }), type => type == typeof(ChildClass)),
            });

            var typeFeatureProvider = new TypeFeatureProvider(new TypeConverterProvider());
            var xamlTypeRepository  = new TypeRepository(new NamespaceRegistry(), typeFactory, typeFeatureProvider);
            var typeSource          = new RuntimeTypeSource(xamlTypeRepository, new NamespaceRegistry());

            typeFeatureProvider.RegisterMetadata(typeof(DummyObject), new Metadata {
                RuntimePropertyName = "Name"
            });
            return(typeSource);
        }
コード例 #5
0
 public PerspexWiringContext(ITypeFactory typeFactory, TypeFeatureProvider featureProvider)
     : base(CreateTypeContext(typeFactory, featureProvider), featureProvider)
 {
 }
コード例 #6
0
        private static IRuntimeTypeSource CreateRuntimeTypeSource()
        {
            var typeFactory = new MultiFactory(
                new List<TypeFactoryRegistration>
                {
                    new TypeFactoryRegistration(new TypeFactory(), type => type != typeof (ChildClass)),
                    new TypeFactoryRegistration(new TypeFactoryMock((type, args) => new ChildClass {Name = "InnerName"}), type => type == typeof (ChildClass)),
                });

            var typeFeatureProvider = new TypeFeatureProvider(new TypeConverterProvider());
            var xamlTypeRepository = new TypeRepository(new NamespaceRegistry(), typeFactory, typeFeatureProvider);
            var typeSource = new RuntimeTypeSource(xamlTypeRepository, new NamespaceRegistry());
            typeFeatureProvider.RegisterMetadata(typeof (DummyObject), new Metadata {RuntimePropertyName = "Name"});
            return typeSource;
        }
コード例 #7
0
 public AvaloniaWiringContext(ITypeFactory typeFactory, TypeFeatureProvider featureProvider)
     : base(CreateTypeContext(typeFactory, featureProvider), featureProvider)
 {
 }