示例#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
        public void NullTarget_Throws()
        {
            var typeConverter = new Mock<ITypeConverterProvider>();
            var perspexPropertyBinder = new PerspexPropertyBinder(typeConverter.Object);
            var bindingDefinitionBuilder = new BindingDefinitionBuilder();
            var binding = bindingDefinitionBuilder
                .WithNullTarget()
                .Build();

            var exception = Assert.Throws<InvalidOperationException>(() => perspexPropertyBinder.Create(binding));
        }
        private static ITypeContext CreateTypeContext(ITypeFactory typeFactory, TypeFeatureProvider featureProvider)
        {
            var xamlNamespaceRegistry = CreateXamlNamespaceRegistry();
            var perspexPropertyBinder = new PerspexPropertyBinder(featureProvider.ConverterProvider);
            var typeRepository = new PerspexTypeRepository(xamlNamespaceRegistry, typeFactory, featureProvider, perspexPropertyBinder);

            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);
        }