Beispiel #1
0
		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 ComponentAsIdMapper(System.Type componentType, MemberInfo declaringTypeMember, HbmCompositeId id, HbmMapping mapDoc)
		{
			this.id = id;
			this.mapDoc = mapDoc;
			id.@class = componentType.GetShortClassName(mapDoc);
			accessorPropertyMapper = new AccessorPropertyMapper(declaringTypeMember.DeclaringType, declaringTypeMember.Name, x => id.access = x);
		}
		public ComponentNestedElementMapper(Type componentType, HbmMapping mapDoc, HbmNestedCompositeElement component, MemberInfo declaringComponentMember)
		{
			this.componentType = componentType;
			this.mapDoc = mapDoc;
			this.component = component;
			accessorPropertyMapper = new AccessorPropertyMapper(declaringComponentMember.DeclaringType, declaringComponentMember.Name, x => component.access = x);
		}
		protected virtual void MemberReadOnlyAccessor(IModelInspector modelInspector, PropertyPath member, IAccessorPropertyMapper propertyCustomizer)
		{
			if (MatchReadOnlyProperty(member.LocalMember))
			{
				propertyCustomizer.Access(Accessor.ReadOnly);
			}
		}
		public ComponentMapper(HbmComponent component, System.Type componentType, IAccessorPropertyMapper accessorMapper, HbmMapping mapDoc)
			: base(componentType, mapDoc)
		{
			_component = component;
			_component.@class = componentType.GetShortClassName(mapDoc);
			_accessorPropertyMapper = accessorMapper;
		}
Beispiel #6
0
		public OneToOneMapper(MemberInfo member, IAccessorPropertyMapper accessorMapper, HbmOneToOne oneToOne)
		{
			this.member = member;
			this.oneToOne = oneToOne;
			if (member == null)
			{
				this.oneToOne.access = "none";
			}
			entityPropertyMapper = member == null ? new NoMemberPropertyMapper() : accessorMapper;
		}
Beispiel #7
0
 public ManyToOneMapper(MemberInfo member, IAccessorPropertyMapper accessorPropertyMapper, HbmManyToOne manyToOne, HbmMapping mapDoc)
 {
     this.member = member;
     this.manyToOne = manyToOne;
     this.mapDoc = mapDoc;
     if (member == null)
     {
         this.manyToOne.access = "none";
     }
     entityPropertyMapper = member == null ? new NoMemberPropertyMapper() : accessorPropertyMapper;
 }
		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;
		}
Beispiel #9
0
		public static void SetAccessor(MemberInfoMetadata member, IAccessorPropertyMapper m)
		{
			if (member.Accessor == Accessors.Field)
			{
				m.Access(AccessorHelper.Translate(member.Accessor));
			}

			if (member.MemberType == MemberTypes.Property)
			{
				m.Access(Accessor.Property);
			}
		}
Beispiel #10
0
 public IdMapper(MemberInfo member, HbmId hbmId)
 {
     this.hbmId = hbmId;
     if (member != null)
     {
         var idType = member.GetPropertyOrFieldType();
         hbmId.name     = member.Name;
         hbmId.type1    = idType.GetNhTypeName();
         accessorMapper = new AccessorPropertyMapper(member.DeclaringType, member.Name, x => hbmId.access = x);
     }
     else
     {
         accessorMapper = new NoMemberPropertyMapper();
     }
 }
Beispiel #11
0
 public VersionMapper(MemberInfo member, HbmVersion hbmVersion)
 {
     if (member == null)
     {
         throw new ArgumentNullException("member");
     }
     if (hbmVersion == null)
     {
         throw new ArgumentNullException("hbmVersion");
     }
     this.member          = member;
     versionMapping       = hbmVersion;
     versionMapping.name  = member.Name;
     entityPropertyMapper = new AccessorPropertyMapper(member.DeclaringType, member.Name, x => versionMapping.access = x);
 }
 public IdMapper(MemberInfo member, HbmId hbmId)
 {
     this.hbmId = hbmId;
     if (member != null)
     {
         var idType = member.GetPropertyOrFieldType();
         hbmId.name = member.Name;
         hbmId.type1 = idType.GetNhTypeName();
         accessorMapper = new AccessorPropertyMapper(member.DeclaringType, member.Name, x => hbmId.access = x);
     }
     else
     {
         accessorMapper = new NoMemberPropertyMapper();
     }
 }
Beispiel #13
0
		public OneToOneMapper(MemberInfo member, HbmOneToOne oneToOne)
		{
			this.member = member;
			this.oneToOne = oneToOne;
			if (member == null)
			{
				this.oneToOne.access = "none";
			}
			if (member == null)
			{
				entityPropertyMapper = new NoMemberPropertyMapper();
			}
			else
			{
				entityPropertyMapper = new AccessorPropertyMapper(member.DeclaringType, member.Name, x => oneToOne.access = x);
			}
		}
Beispiel #14
0
 public OneToOneMapper(MemberInfo member, HbmOneToOne oneToOne)
 {
     this.member   = member;
     this.oneToOne = oneToOne;
     if (member == null)
     {
         this.oneToOne.access = "none";
     }
     if (member == null)
     {
         entityPropertyMapper = new NoMemberPropertyMapper();
     }
     else
     {
         entityPropertyMapper = new AccessorPropertyMapper(member.DeclaringType, member.Name, x => oneToOne.access = x);
     }
 }
 public ManyToOneMapper(MemberInfo member, HbmManyToOne manyToOne, HbmMapping mapDoc)
 {
     this.member    = member;
     this.manyToOne = manyToOne;
     this.mapDoc    = mapDoc;
     if (member == null)
     {
         this.manyToOne.access = "none";
     }
     if (member == null)
     {
         entityPropertyMapper = new NoMemberPropertyMapper();
     }
     else
     {
         entityPropertyMapper = new AccessorPropertyMapper(member.DeclaringType, member.Name, x => manyToOne.access = x);
     }
 }
Beispiel #16
0
 public KeyManyToOneMapper(MemberInfo member, HbmKeyManyToOne manyToOne, HbmMapping mapDoc)
 {
     this.member = member;
     this.manyToOne = manyToOne;
     this.mapDoc = mapDoc;
     if (member == null)
     {
         this.manyToOne.access = "none";
     }
     if (member == null)
     {
         entityPropertyMapper = new NoMemberPropertyMapper();
     }
     else
     {
         entityPropertyMapper = new AccessorPropertyMapper(member.DeclaringType, member.Name, x => manyToOne.access = x);
     }
 }
        public MapMapper(System.Type ownerType, System.Type keyType, System.Type valueType, IAccessorPropertyMapper accessorMapper, HbmMap mapping, HbmMapping mapDoc)
        {
            if (ownerType == null)
            {
                throw new ArgumentNullException("ownerType");
            }
            if (keyType == null)
            {
                throw new ArgumentNullException("keyType");
            }
            if (valueType == null)
            {
                throw new ArgumentNullException("valueType");
            }
            if (mapping == null)
            {
                throw new ArgumentNullException("mapping");
            }
            OwnerType    = ownerType;
            KeyType      = keyType;
            ValueType    = valueType;
            this.mapping = mapping;
            this.mapDoc  = mapDoc;
            if (mapping.Key == null)
            {
                mapping.key = new HbmKey();
            }
            keyMapper = new KeyMapper(ownerType, mapping.Key);

            if (KeyType.IsValueType || KeyType == typeof(string))
            {
                mapping.Item = new HbmMapKey {
                    type = KeyType.GetNhTypeName()
                };
            }
            else
            {
                mapping.Item = new HbmMapKeyManyToMany {
                    @class = KeyType.GetShortClassName(mapDoc)
                };
            }
            entityPropertyMapper = accessorMapper;
        }
Beispiel #18
0
 public KeyPropertyMapper(MemberInfo member, HbmKeyProperty propertyMapping)
 {
     if (propertyMapping == null)
     {
         throw new ArgumentNullException("propertyMapping");
     }
     this.member          = member;
     this.propertyMapping = propertyMapping;
     if (member == null)
     {
         this.propertyMapping.access = "none";
     }
     if (member == null)
     {
         entityPropertyMapper = new NoMemberPropertyMapper();
     }
     else
     {
         entityPropertyMapper = new AccessorPropertyMapper(member.DeclaringType, member.Name, x => propertyMapping.access = x);
     }
 }
Beispiel #19
0
        public AnyMapper(MemberInfo member, Type foreignIdType, HbmAny any, HbmMapping mapDoc)
        {
            this.member        = member;
            this.foreignIdType = foreignIdType;
            this.any           = any;
            this.mapDoc        = mapDoc;
            if (member == null)
            {
                this.any.access = "none";
            }
            if (member == null)
            {
                entityPropertyMapper = new NoMemberPropertyMapper();
            }
            else
            {
                entityPropertyMapper = new AccessorPropertyMapper(member.DeclaringType, member.Name, x => any.access = x);
            }
            if (foreignIdType == null)
            {
                throw new ArgumentNullException("foreignIdType");
            }
            if (any == null)
            {
                throw new ArgumentNullException("any");
            }

            this.any.idtype = this.foreignIdType.GetNhTypeName();
            var idHbmColumn  = new HbmColumn();
            var idColumnName = member == null ? DefaultIdColumnNameWhenNoProperty : member.Name + "Id";

            idColumnMapper = new ColumnMapper(idHbmColumn, idColumnName);
            var classHbmColumn  = new HbmColumn();
            var classColumnName = member == null ? DefaultMetaColumnNameWhenNoProperty : member.Name + "Class";

            classColumnMapper = new ColumnMapper(classHbmColumn, classColumnName);
            any.column        = new[] { idHbmColumn, classHbmColumn };
        }
Beispiel #20
0
 public SetMapper(Type ownerType, Type elementType, HbmSet mapping)
 {
     if (ownerType == null)
     {
         throw new ArgumentNullException("ownerType");
     }
     if (elementType == null)
     {
         throw new ArgumentNullException("elementType");
     }
     if (mapping == null)
     {
         throw new ArgumentNullException("mapping");
     }
     OwnerType    = ownerType;
     ElementType  = elementType;
     this.mapping = mapping;
     if (mapping.Key == null)
     {
         mapping.key = new HbmKey();
     }
     keyMapper            = new KeyMapper(ownerType, mapping.Key);
     entityPropertyMapper = new AccessorPropertyMapper(ownerType, mapping.Name, x => mapping.access = x);
 }
Beispiel #21
0
 public BagMapper(System.Type ownerType, System.Type elementType, IAccessorPropertyMapper accessorMapper, HbmBag mapping)
 {
     if (ownerType == null)
     {
         throw new ArgumentNullException("ownerType");
     }
     if (elementType == null)
     {
         throw new ArgumentNullException("elementType");
     }
     if (mapping == null)
     {
         throw new ArgumentNullException("mapping");
     }
     OwnerType    = ownerType;
     ElementType  = elementType;
     this.mapping = mapping;
     if (mapping.Key == null)
     {
         mapping.key = new HbmKey();
     }
     keyMapper            = new KeyMapper(ownerType, mapping.Key);
     entityPropertyMapper = accessorMapper;
 }
		protected virtual void MemberToFieldAccessor(IModelInspector modelInspector, PropertyPath member, IAccessorPropertyMapper propertyCustomizer)
		{
			if (MatchPropertyToField(member.LocalMember))
			{
				propertyCustomizer.Access(Accessor.Field);
			}
		}
 protected virtual void MemberReadOnlyAccessor(IModelInspector modelInspector, PropertyPath member, IAccessorPropertyMapper propertyCustomizer)
 {
     if (MatchReadOnlyProperty(member.LocalMember))
     {
         propertyCustomizer.Access(Accessor.ReadOnly);
     }
 }
 protected virtual void MemberNoSetterToField(IModelInspector modelInspector, PropertyPath member, IAccessorPropertyMapper propertyCustomizer)
 {
     if (MatchNoSetterProperty(member.LocalMember))
     {
         propertyCustomizer.Access(Accessor.NoSetter);
     }
 }
        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;
        }