Esempio n. 1
0
 public void Should_create_an_instance_from_iri_attribute_with_graph_iri()
 {
     AttributePropertyMappingProvider.FromAttribute(EntityType, Property, new PropertyAttribute()
     {
         Iri = "test", Graph = "graph", ValueConverterType = typeof(TestConverter)
     })
     .Should().BeOfType <AttributePropertyMappingProvider>().Which.MatchesMapped <TestConverter>(Property, new Iri("test"), new Iri("graph"));
 }
 protected override void ScenarioSetup()
 {
     Visitor = new Mock <IMappingProviderVisitor>(MockBehavior.Strict);
     Visitor.Setup(instance => instance.Visit(It.IsAny <IPropertyMappingProvider>()));
     Provider = AttributePropertyMappingProvider.FromAttribute(EntityType, Property, new PropertyAttribute()
     {
         Iri = "test"
     });
 }
Esempio n. 3
0
 public void Should_create_an_instance_from_qiri_attribute()
 {
     AttributePropertyMappingProvider.FromAttribute(EntityType, Property, new PropertyAttribute("test", "term")
     {
         ValueConverterType = typeof(TestConverter)
     })
     .Should().BeOfType <AttributePropertyMappingProvider>()
     .Which.MatchesMapped <TestConverter>(Property, new QIriMapping("test", new Iri("test_")), new Iri("test_term"));
 }
        private void BuildPropertyMappings(Type type)
        {
            var propertyAttributes = from property in type.GetProperties(BindingFlags.Instance | BindingFlags.Public)
                                     from attribute in property.GetCustomAttributes()
                                     select new { Property = property, Attribute = attribute };

            foreach (var definition in propertyAttributes)
            {
                //// TODO: Add support for dictionaries.
                var collectionAttribute = definition.Attribute as CollectionAttribute;
                if (collectionAttribute != null)
                {
                    _entityMappingProviders.Add(AttributeCollectionMappingProvider.FromAttribute(type, definition.Property, collectionAttribute));
                    continue;
                }

                var propertyAttribute = definition.Attribute as PropertyAttribute;
                if (propertyAttribute != null)
                {
                    _entityMappingProviders.Add(AttributePropertyMappingProvider.FromAttribute(type, definition.Property, propertyAttribute));
                }
            }
        }