public ComponentMapper(HbmComponent component, System.Type componentType, IAccessorPropertyMapper accessorMapper, HbmMapping mapDoc) : base(componentType, mapDoc) { _component = component; _component.@class = componentType.GetShortClassName(mapDoc); _accessorPropertyMapper = accessorMapper; }
public ComponentMapper(HbmComponent component, Type componentType, MemberInfo declaringTypeMember, HbmMapping mapDoc) : base(componentType, mapDoc) { this.component = component; component.@class = componentType.GetShortClassName(mapDoc); accessorPropertyMapper = new AccessorPropertyMapper(declaringTypeMember.DeclaringType, declaringTypeMember.Name, x => component.access = x); }
public void CanSetParentAccessor() { var mapdoc = new HbmMapping(); var component = new HbmComponent(); var mapper = new ComponentMapper(component, typeof(Name), ForClass<Person>.Property(p => p.Name), mapdoc); mapper.Parent(typeof(Address).GetProperty("Parent"), pm=> pm.Access(Accessor.Field)); component.Parent.access.Should().Contain("field"); }
public void CanSetOptimisticLock() { var mapdoc = new HbmMapping(); var component = new HbmComponent(); var mapper = new ComponentMapper(component, typeof(Name), ForClass<Person>.Property(p => p.Name), mapdoc); mapper.OptimisticLock(false); component.optimisticlock.Should().Be.False(); }
public void CanSetLazy() { var mapdoc = new HbmMapping(); var component = new HbmComponent(); var mapper = new ComponentMapper(component, typeof(Name), ForClass<Person>.Property(p => p.Name), mapdoc); mapper.Lazy(true); component.lazy.Should().Be.True(); }
public void CanSetInsert() { var mapdoc = new HbmMapping(); var component = new HbmComponent(); var mapper = new ComponentMapper(component, typeof(Name), ForClass<Person>.Property(p => p.Name), mapdoc); mapper.Insert(false); component.insert.Should().Be.False(); }
public void CallingParentSetTheParentNode() { var mapdoc = new HbmMapping(); var component = new HbmComponent(); var mapper = new ComponentMapper(component, typeof(Name), ForClass<Person>.Property(p => p.Name), mapdoc); mapper.Parent(typeof (Address).GetProperty("Parent")); component.Parent.Should().Not.Be.Null(); component.Parent.name.Should().Be.EqualTo("Parent"); }
public virtual void Component(MemberInfo property, Action<IComponentMapper> mapping) { if (!IsMemberSupportedByMappedContainer(property)) { throw new ArgumentOutOfRangeException("property", "Can't add a property of another graph"); } var hbm = new HbmComponent { name = property.Name }; mapping(new ComponentMapper(hbm, property.GetPropertyOrFieldType(), property, MapDoc)); AddProperty(hbm); }
public void Should_get_the_correct_value() { const string expected = "System.String"; HbmComponent component = new HbmComponent { @class = expected + ", mscorlib" }; string result = component.GetReturnType(); result.ShouldBeEqualTo(expected); }
public void Should_get_the_correct_value() { const string expected = "FirstName"; HbmComponent component = new HbmComponent { name = expected }; string result = component.GetPropertyName(); result.ShouldBeEqualTo(expected); }
private void BindComponentProperty(HbmComponent componentMapping, Property property) { property.IsUpdateable = componentMapping.update; property.IsInsertable = componentMapping.insert; }
public virtual void Component(MemberInfo property, Action<IComponentMapper> mapping) { var hbm = new HbmComponent { name = property.Name }; mapping(new ComponentMapper(hbm, property.GetPropertyOrFieldType(), property, MapDoc)); AddProperty(hbm); }
private void BindComponentProperty(HbmComponent componentMapping, Property property, Component model) { property.IsUpdateable = componentMapping.update; property.IsInsertable = componentMapping.insert; if (componentMapping.unique) { model.Owner.Table.CreateUniqueKey(model.ColumnIterator.OfType<Column>().ToList()); } HbmTuplizer[] tuplizers = componentMapping.tuplizer; if (tuplizers != null) { Array.ForEach(tuplizers.Select(tuplizer => new { TuplizerClassName = FullQualifiedClassName(tuplizer.@class, mappings), Mode = tuplizer.entitymode.ToEntityMode() }).ToArray(), x => model.AddTuplizer(x.Mode, x.TuplizerClassName)); } }
public void WhenMapDocHasDefaultHasClassName() { var entityType = typeof (Person); var mapdoc = new HbmMapping { assembly = entityType.Assembly.FullName, @namespace = entityType.Namespace }; var component = new HbmComponent(); new ComponentMapper(component, typeof(Name), ForClass<Person>.Property(p=> p.Name), mapdoc); component.Class.Should().Be.EqualTo(typeof(Name).Name); }
public ComponentMapper(HbmComponent component, System.Type componentType, MemberInfo declaringTypeMember, HbmMapping mapDoc) : this(component,componentType, new AccessorPropertyMapper(declaringTypeMember.DeclaringType, declaringTypeMember.Name, x => component.access = x), mapDoc) { }