private PropertyMapping BuildPropertyMapping(IPropertyMappingProvider provider) { var propertyMapping = new PropertyMapping( provider.PropertyInfo.DeclaringType, provider.PropertyInfo.PropertyType, provider.PropertyInfo.Name, provider.GetTerm(_mappingContext.OntologyProvider)); SetConverter(propertyMapping, provider); return propertyMapping; }
private bool SetConverter(PropertyMapping propertyMapping, IPropertyMappingProvider provider) { bool result = false; if ((provider.ConverterType != null) && (!provider.ConverterType.GetTypeInfo().ContainsGenericParameters) && (!provider.ConverterType.GetTypeInfo().IsInterface)) { propertyMapping.Converter = _converterCatalog.GetConverter(provider.ConverterType); result = true; } return(result); }
public IEntityMapping BuildMapping(IEntityMappingProvider mapping) { _currentType = mapping.EntityType; var classes = mapping.Classes.Select(BuildMapping).Distinct(); var properties = mapping.Properties.Select(BuildMapping).Distinct(); IEnumerable <PropertyMapping> hiddenProperties = new PropertyMapping[0]; var providerWithHiddenProperties = mapping as IEntityMappingProviderWithHiddenProperties; if (providerWithHiddenProperties != null) { hiddenProperties = providerWithHiddenProperties.HiddenProperties.Select(BuildMapping); } return(new EntityMapping(mapping.EntityType, classes, properties, hiddenProperties)); }
public void Setup() { _typesMapping = new TestPropertyMapping(typeof(ITypedEntity), typeof(IEnumerable<EntityId>), "Types", Vocabularies.Rdf.type); _factory = new Mock<IEntityContextFactory>(); _ontologyProvider = new TestOntologyProvider(); _mappings = new Mock<IMappingsRepository>(); _entityStore = new Mock<IEntityStore>(); _entityStore.Setup(es => es.GetObjectsForPredicate(It.IsAny<EntityId>(), Rdf.type, It.IsAny<Uri>())) .Returns(new Node[0]); _mappings.Setup(m => m.MappingFor<ITypedEntity>()).Returns(new EntityMapping(typeof(ITypedEntity), new ClassMapping[0], new[] { _typesMapping })); _mappings.Setup(m => m.MappingFor(typeof(ITypedEntity))).Returns(new EntityMapping(typeof(ITypedEntity), new ClassMapping[0], new[] { _typesMapping })); _store = new Mock<IEntitySource>(); _baseUriSelector = new Mock<IBaseUriSelectionPolicy>(MockBehavior.Strict); var mappingContext = new MappingContext(_ontologyProvider); _entityContext = new EntityContext( _factory.Object, _mappings.Object, mappingContext, _entityStore.Object, _store.Object, _baseUriSelector.Object, new TestGraphSelector(), new TestCache()); }
public DebuggerViewProxy(PropertyMapping mapping) { _mapping = mapping; }
private bool SetConverter(PropertyMapping propertyMapping, IPropertyMappingProvider provider) { bool result = false; if ((provider.ConverterType != null) && (!provider.ConverterType.ContainsGenericParameters) && (!provider.ConverterType.IsInterface)) { propertyMapping.Converter = (INodeConverter)Activator.CreateInstance(provider.ConverterType); result = true; } return result; }