public void CanSetAccessor() { var mapdoc = new HbmMapping(); var component = new HbmDynamicComponent(); var mapper = new DynamicComponentMapper(component, For <Person> .Property(p => p.Info), mapdoc); mapper.Access(Accessor.Field); Assert.That(component.access, Is.EqualTo("field.camelcase")); }
public void CanSetInsert() { var mapdoc = new HbmMapping(); var component = new HbmDynamicComponent(); var mapper = new DynamicComponentMapper(component, For <Person> .Property(p => p.Info), mapdoc); mapper.Insert(false); Assert.That(component.insert, Is.False); }
private void BindComponentProperty(HbmDynamicComponent dynamicComponentMapping, Property property, Component model) { property.IsUpdateable = dynamicComponentMapping.update; property.IsInsertable = dynamicComponentMapping.insert; if (dynamicComponentMapping.unique) { model.Owner.Table.CreateUniqueKey(model.ColumnIterator.OfType <Column>().ToList()); } }
public void CanSetAccessor() { var mapdoc = new HbmMapping(); var component = new HbmDynamicComponent(); var mapper = new DynamicComponentMapper(component, For <Person> .Property(p => p.Info), mapdoc); mapper.Access(Accessor.Field); component.access.Should().Be("field.camelcase"); }
public void CanSetOptimisticLock() { var mapdoc = new HbmMapping(); var component = new HbmDynamicComponent(); var mapper = new DynamicComponentMapper(component, For <Person> .Property(p => p.Info), mapdoc); mapper.OptimisticLock(false); component.OptimisticLock.Should().Be.False(); }
public void Component(MemberInfo property, Action <IDynamicComponentMapper> mapping) { var hbm = new HbmDynamicComponent { name = property.Name }; mapping(new DynamicComponentMapper(hbm, property, new NoMemberPropertyMapper(), MapDoc)); AddProperty(hbm); }
public void CanSetUpdate() { var mapdoc = new HbmMapping(); var component = new HbmDynamicComponent(); var mapper = new DynamicComponentMapper(component, For <Person> .Property(p => p.Info), mapdoc); mapper.Update(false); component.update.Should().Be.False(); }
public void WhenCustomizeAccessorThenIgnore() { var mapdoc = new HbmMapping(); var component = new HbmDynamicComponent(); var mapper = new DynamicComponentMapper(component, For <Person> .Property(p => p.Info), mapdoc); var propertyInfo = For <Person> .Property(p => p.Info); //just as another dyn-compo mapper.Component(propertyInfo, (IDynamicComponentMapper x) => x.Access(Accessor.Field)); Assert.That(component.Properties.OfType <HbmDynamicComponent>().Single().Access, Is.Null.Or.Empty); }
public void WhenAddThenHasGeneric() { var mapdoc = new HbmMapping(); var component = new HbmDynamicComponent(); var mapper = new DynamicComponentMapper(component, For <PersonWithGenericInfo> .Property(p => p.Info), mapdoc); var propertyInfo = For <PersonWithGenericInfo> .Property(p => p.Info); //just as another dyn-compo mapper.Component(propertyInfo, (IDynamicComponentMapper x) => { }); Assert.That(component.Properties.Select(x => x.Name), Is.EquivalentTo(new[] { "Info" })); }
public void WhenCustomizeAccessorThenIgnore() { var mapdoc = new HbmMapping(); var component = new HbmDynamicComponent(); var mapper = new DynamicComponentMapper(component, For <Person> .Property(p => p.Info), mapdoc); var propertyInfo = (new { A = (object)null }).GetType().GetProperty("A"); mapper.Any(propertyInfo, typeof(int), x => x.Access(Accessor.Field)); Assert.That(component.Properties.OfType <HbmAny>().Single().Access, Is.Null.Or.Empty); }
public void WhenAddThenHas() { var mapdoc = new HbmMapping(); var component = new HbmDynamicComponent(); var mapper = new DynamicComponentMapper(component, For <Person> .Property(p => p.Info), mapdoc); var propertyInfo = For <Person> .Property(p => p.Info); //just as another dyn-compo mapper.Component(propertyInfo, (IDynamicComponentMapper x) => { }); component.Properties.Select(x => x.Name).Should().Have.SameSequenceAs("Info"); }
public void WhenCustomizeAccessorThenIgnore() { var mapdoc = new HbmMapping(); var component = new HbmDynamicComponent(); var mapper = new DynamicComponentMapper(component, For <Person> .Property(p => p.Info), mapdoc); var propertyInfo = (new { A = (IDictionary <int, int>)null }).GetType().GetProperty("A"); mapper.Map(propertyInfo, x => x.Access(Accessor.Field), km => { }, rel => { }); component.Properties.OfType <HbmMap>().Single().Access.Should().Be.NullOrEmpty(); }
public void CanAddSimpleProperty() { var mapdoc = new HbmMapping(); var component = new HbmDynamicComponent(); var mapper = new DynamicComponentMapper(component, For <Person> .Property(p => p.Info), mapdoc); var dynObject = new { Pizza = 5 }; mapper.Property(dynObject.GetType().GetProperty("Pizza"), x => { }); Assert.That(component.Properties.Single(), Is.TypeOf <HbmProperty>().And.Property("Name").EqualTo("Pizza")); }
public void WhenCustomizeAccessorThenIgnore() { var mapdoc = new HbmMapping(); var component = new HbmDynamicComponent(); var mapper = new DynamicComponentMapper(component, For <Person> .Property(p => p.Info), mapdoc); var propertyInfo = (new { A = (IEnumerable <int>)null }).GetType().GetProperty("A"); mapper.List(propertyInfo, x => x.Access(Accessor.Field), rel => { }); Assert.That(component.Properties.OfType <HbmList>().Single().Access, Is.Null.Or.Empty); }
public void WhenCustomizeAccessorThenIgnoreGeneric() { var mapdoc = new HbmMapping(); var component = new HbmDynamicComponent(); var mapper = new DynamicComponentMapper(component, For <PersonWithGenericInfo> .Property(p => p.Info), mapdoc); var propertyInfo = (new { A = (MyClass)null }).GetType().GetProperty("A"); mapper.Component(propertyInfo, (IComponentMapper x) => x.Access(Accessor.Field)); Assert.That(component.Properties.OfType <HbmComponent>().Single().Access, Is.Null.Or.Empty); }
public void WhenAddThenHas() { var mapdoc = new HbmMapping(); var component = new HbmDynamicComponent(); var mapper = new DynamicComponentMapper(component, For <Person> .Property(p => p.Info), mapdoc); var propertyInfo = (new { A = (IEnumerable <int>)null }).GetType().GetProperty("A"); mapper.Set(propertyInfo, x => { }, rel => { }); component.Properties.Select(x => x.Name).Should().Have.SameSequenceAs("A"); }
public void WhenAddThenHas() { var mapdoc = new HbmMapping(); var component = new HbmDynamicComponent(); var mapper = new DynamicComponentMapper(component, For <Person> .Property(p => p.Info), mapdoc); var propertyInfo = (new { A = (IEnumerable <int>)null }).GetType().GetProperty("A"); mapper.List(propertyInfo, x => { }, rel => { }); Assert.That(component.Properties.Select(x => x.Name), Is.EquivalentTo(new[] { "A" })); }
public void CanAddSimpleProperty() { var mapdoc = new HbmMapping(); var component = new HbmDynamicComponent(); var mapper = new DynamicComponentMapper(component, For <Person> .Property(p => p.Info), mapdoc); var dynObject = new { Pizza = 5 }; mapper.Property(dynObject.GetType().GetProperty("Pizza"), x => { }); component.Properties.Single().Should().Be.OfType <HbmProperty>().And.ValueOf.Name.Should().Be.EqualTo("Pizza"); }
public void WhenCustomizeAccessorThenIgnore() { var mapdoc = new HbmMapping(); var component = new HbmDynamicComponent(); var mapper = new DynamicComponentMapper(component, For <Person> .Property(p => p.Info), mapdoc); var propertyInfo = (new { A = (MyClass)null }).GetType().GetProperty("A"); mapper.Component(propertyInfo, (IComponentMapper x) => x.Access(Accessor.Field)); component.Properties.OfType <HbmComponent>().Single().Access.Should().Be.NullOrEmpty(); }
public void WhenAddThenHasGeneric() { var mapdoc = new HbmMapping(); var component = new HbmDynamicComponent(); var mapper = new DynamicComponentMapper(component, For <PersonWithGenericInfo> .Property(p => p.Info), mapdoc); var propertyInfo = (new { A = (MyClass)null }).GetType().GetProperty("A"); mapper.Component(propertyInfo, (IComponentMapper x) => { }); Assert.That(component.Properties.Select(x => x.Name), Is.EquivalentTo(new[] { "A" })); }
public void WhenCustomizeThenCallCustomizer() { var mapdoc = new HbmMapping(); var component = new HbmDynamicComponent(); var mapper = new DynamicComponentMapper(component, For <Person> .Property(p => p.Info), mapdoc); var propertyInfo = (new { A = 5 }).GetType().GetProperty("A"); var called = false; mapper.Property(propertyInfo, x => called = true); Assert.That(called, Is.True); }
private DynamicComponentMapper(HbmDynamicComponent component, MemberInfo declaringTypeMember, IAccessorPropertyMapper accessorMapper, HbmMapping mapDoc) { if (mapDoc == null) { throw new ArgumentNullException("mapDoc"); } Container = declaringTypeMember.DeclaringType; MapDoc = mapDoc; this.component = component; accessorPropertyMapper = accessorMapper; }
public void WhenCustomizeThenCallCustomizer() { var mapdoc = new HbmMapping(); var component = new HbmDynamicComponent(); var mapper = new DynamicComponentMapper(component, For <Person> .Property(p => p.Info), mapdoc); var propertyInfo = (new { A = (IEnumerable <int>)null }).GetType().GetProperty("A"); var called = false; mapper.Set(propertyInfo, x => called = true, rel => { }); called.Should().Be.True(); }
public void WhenCustomizeThenCallCustomizerGeneric() { var mapdoc = new HbmMapping(); var component = new HbmDynamicComponent(); var mapper = new DynamicComponentMapper(component, For <PersonWithGenericInfo> .Property(p => p.Info), mapdoc); var propertyInfo = (new { A = (MyClass)null }).GetType().GetProperty("A"); var called = false; mapper.Component(propertyInfo, (IComponentMapper x) => called = true); Assert.That(called, Is.True); }
public void WhenCustomizeThenCallCustomizer() { var mapdoc = new HbmMapping(); var component = new HbmDynamicComponent(); var mapper = new DynamicComponentMapper(component, For <Person> .Property(p => p.Info), mapdoc); var propertyInfo = (new { A = (MyClass)null }).GetType().GetProperty("A"); var called = false; mapper.Component(propertyInfo, (IComponentMapper x) => called = true); called.Should().Be.True(); }
public void WhenCustomizeThenCallCustomizer() { var mapdoc = new HbmMapping(); var component = new HbmDynamicComponent(); var mapper = new DynamicComponentMapper(component, For <Person> .Property(p => p.Info), mapdoc); var propertyInfo = For <Person> .Property(p => p.Info); //just as another dyn-compo var called = false; mapper.Component(propertyInfo, (IDynamicComponentMapper x) => called = true); called.Should().Be.True(); }
public void WhenCustomizeThenCallCustomizerGeneric() { var mapdoc = new HbmMapping(); var component = new HbmDynamicComponent(); var mapper = new DynamicComponentMapper(component, For <PersonWithGenericInfo> .Property(p => p.Info), mapdoc); var propertyInfo = For <PersonWithGenericInfo> .Property(p => p.Info); //just as another dyn-compo var called = false; mapper.Component(propertyInfo, (IDynamicComponentMapper x) => called = true); Assert.That(called, Is.True); }
public virtual void Component(MemberInfo property, Action <IDynamicComponentMapper> mapping) { if (!IsMemberSupportedByMappedContainer(property)) { throw new ArgumentOutOfRangeException("property", "Can't add a property of another graph"); } var hbm = new HbmDynamicComponent { name = property.Name }; mapping(new DynamicComponentMapper(hbm, property, MapDoc)); AddProperty(hbm); }
private void MapExtensionsToCoreEntity(Dictionary <string, HbmClass> classMappingByEntityName, Dictionary <string, HbmJoinedSubclass> joinedSubclassMappingByEntityName, Dictionary <string, HbmJoin> subclassJoinMappingByEntityName) { // foreach entity name, look in core mapping file (e.mapping) for core entity mapping and if found // concat new extension HbmDynamicComponent to current set of items. foreach (string entityName in _entityExtensionHbmBagsByEntityName.Keys) { HbmClass classMapping; HbmJoinedSubclass joinedSubclassMapping = null; HbmJoin subclassJoinMapping = null; if (!classMappingByEntityName.TryGetValue(entityName, out classMapping) && !joinedSubclassMappingByEntityName.TryGetValue(entityName, out joinedSubclassMapping) && !subclassJoinMappingByEntityName.TryGetValue(entityName, out subclassJoinMapping)) { throw new MappingException( $"The entity extension to entity '{entityName}' could not be applied because the class mapping could not be found."); } var extensionComponent = new HbmDynamicComponent { name = EntityExtensionMemberName, Items = _entityExtensionHbmBagsByEntityName[entityName] .Select(x => (object)x) .ToArray() }; if (classMapping != null) { classMapping.Items = classMapping.Items.Concat(extensionComponent) .ToArray(); } else if (joinedSubclassMapping != null) { joinedSubclassMapping.Items = joinedSubclassMapping.Items.Concat(extensionComponent) .ToArray(); } else { subclassJoinMapping.Items = subclassJoinMapping.Items.Concat(extensionComponent) .ToArray(); } } }
public DynamicComponentMapper(HbmDynamicComponent component, MemberInfo declaringTypeMember, HbmMapping mapDoc) : this(component, declaringTypeMember, new AccessorPropertyMapper(declaringTypeMember.DeclaringType, declaringTypeMember.Name, x => component.access = x), mapDoc) { }